diff --git a/.ansible-lint b/.ansible-lint index 056d0c2e2..68c8a982c 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,11 +1,10 @@ exclude_paths: - - playbooks/legacy + - test-playbooks/ # TODO(ssbarnea): remove skip in follow-up parseable: true -# [204] Lines should be no longer than 160 chars -# [301] Commands should not change things if nothing needs doing +quiet: false skip_list: - - '204' - - '301' + - '204' # Lines should be no longer than 160 chars + - '301' # Commands should not change things if nothing needs doing rulesdir: - ./.rules/ use_default_rules: true diff --git a/linters-requirements.txt b/linters-requirements.txt new file mode 100644 index 000000000..d29346d45 --- /dev/null +++ b/linters-requirements.txt @@ -0,0 +1,5 @@ +# linters have different requirements than test ones, some would +# conflict, like ansible version required by ansible-lint. +flake8 +yamllint>=1.23.0 +ansible-lint>=4.3.0a1,<5 diff --git a/test-playbooks/ansible-lint-rules/run.yaml b/test-playbooks/ansible-lint-rules/run.yaml index b2f1d0c08..3581612bd 100644 --- a/test-playbooks/ansible-lint-rules/run.yaml +++ b/test-playbooks/ansible-lint-rules/run.yaml @@ -7,9 +7,9 @@ state: directory register: ansible_lint_tempdir - - name: Install test-requirements.txt + - name: Install linters-requirements.txt pip: - requirements: "{{ansible_user_dir}}/{{ zuul.project.src_dir }}/test-requirements.txt" + requirements: "{{ansible_user_dir}}/{{ zuul.project.src_dir }}/linters-requirements.txt" virtualenv: "{{ ansible_lint_tempdir.path }}" - name: Make sure ansible-lint is installed @@ -37,7 +37,7 @@ - name: Make sure faulty roles fail linting command: >- - {{ ansible_lint_tempdir.path }}/bin/ansible-lint + {{ ansible_lint_tempdir.path }}/bin/ansible-lint -c /dev/null -t {{ item | regex_replace('.*/(ZUULJOBS.*?)/.*', '\1') }} {{ item }} args: diff --git a/test-requirements.txt b/test-requirements.txt index 867929351..bb9d8d22e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,8 +1,6 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -flake8 -yamllint>=1.23.0 # We need to pin the ansible version directly here; per the # deprecation policy it should trail the version used by Zuul by 4 @@ -12,9 +10,6 @@ yamllint>=1.23.0 # dependency solver and the uncapped ansible requirement from # ansible-lint pull in the latest version. ansible>=2.6,<2.7 # https://review.opendev.org/#/c/650431/ -# Don't automatically switch to ansible-lint 5 when it becomes -# available, so that it can be evaluated for an orderly transition. -ansible-lint>=4.1.1a0,<5 stestr>=1.0.0,<3.0.0;python_version<'3.5' # Apache-2.0 stestr>=1.0.0;python_version>='3.5' # Apache-2.0 # For upload-logs-swift: diff --git a/tox.ini b/tox.ini index c88cd6f74..f9af04466 100644 --- a/tox.ini +++ b/tox.ini @@ -41,13 +41,14 @@ passenv = setenv = ANSIBLE_LIBRARY= {toxinidir}/tests/fake-ansible whitelist_externals = bash +deps = + -r{toxinidir}/linters-requirements.txt + commands = flake8 {posargs} yamllint -s -f parsable . - bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -print0 | \ - xargs -t -0 ansible-lint" - bash -c 'find roles -maxdepth 1 -mindepth 1 -type d | \ - xargs -t ansible-lint' + python -m ansiblelint --version + python -m ansiblelint {env:ANSIBLELINT_OPTS:} # Ansible Syntax Check bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -exec \ ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null"