Bump ansible-lint to 4.3.0

- Bumps linter and make use of its auto-detection
- Temporary skips linting test-playbooks/ to match previous behavior
- Documents skips in a way that makes it easy to maintain the rules
- Keeps linter config in standard location, so it can be loaded
  regardless how is called.

Change-Id: Ic379c91fa9385473f6ec2af91e61953dc10c1f54
This commit is contained in:
Sorin Sbarnea 2020-05-28 09:14:04 +01:00
parent 5b194d277e
commit 5e9f91764e
5 changed files with 17 additions and 17 deletions

View File

@ -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

5
linters-requirements.txt Normal file
View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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"