diff --git a/test-requirements.txt b/test-requirements.txt index dfe6062b..32d85882 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,6 +8,3 @@ ansible<2.4.0 ansible-lint bashate>=0.2 zuul-sphinx>=0.2.0 - -# zuul-jobs is required to supply the ansible roles for ansible-lint --e git://git.openstack.org/openstack-infra/zuul-jobs#egg=zuul-jobs diff --git a/tox.ini b/tox.ini index 01636e3c..1097ece3 100644 --- a/tox.ini +++ b/tox.ini @@ -22,11 +22,19 @@ commands = bindep test commands = python setup.py build_sphinx [testenv:linters] -setenv = - ANSIBLE_ROLES_PATH = {toxinidir}/roles:{envdir}/src/zuul-jobs/roles whitelist_externals = bash +passenv = + # NOTE(pabelanger): if you'd like to run tox -elinters locally, you'll need + # to export ANSIBLE_ROLES_PATH pointing to the currect repos. + # see infra-zuul-jobs-linters job for more information. + ANSIBLE_ROLES_PATH commands = flake8 {posargs} + # Ansible lint + # [ANSIBLE0012] Commands should not change things if nothing needs doing + bash -c "find playbooks -type d -name "legacy" -prune -o \ + -type f -regex '.*.y[a]ml' -print0 | xargs -t -n1 -0 \ + ansible-lint -xANSIBLE0012" # Ansible Syntax Check bash -c "cd playbooks; find . -type f -regex '.*.y[a]?ml' -exec \ ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null" diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 0765bdc4..12fa8110 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -770,3 +770,18 @@ parent: legacy-base required-projects: - openstack/requirements + +- job: + name: openstack-zuul-jobs-linters + parent: tox + description: | + This job runs against project-config, openstack-zuul-jobs and zuul-jobs + so we can properly lint our ansible playbooks / roles + required-projects: + - openstack-infra/openstack-zuul-jobs + - openstack-infra/project-config + - openstack-infra/zuul-jobs + vars: + tox_envlist: linters + tox_environment: + ANSIBLE_ROLES_PATH: ~/src/git.openstack.org/openstack-infra/zuul-jobs/roles:~/src/git.openstack.org/openstack-infra/openstack-zuul-jobs/roles:~/src/git.openstack.org/openstack-infra/project-config/roles diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 9c6b5312..e4ffb737 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -17,9 +17,8 @@ - multinode-integration-ubuntu-xenial - multinode-integration-opensuse423 - build-openstack-sphinx-docs - - tox-linters: - required-projects: - - openstack-infra/zuul-jobs + - openstack-zuul-jobs-linters: + voting: false gate: jobs: - base-integration-centos-7 @@ -34,6 +33,3 @@ - multinode-integration-ubuntu-xenial - multinode-integration-opensuse423 - build-openstack-sphinx-docs - - tox-linters: - required-projects: - - openstack-infra/zuul-jobs