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:
parent
5b194d277e
commit
5e9f91764e
@ -1,11 +1,10 @@
|
|||||||
exclude_paths:
|
exclude_paths:
|
||||||
- playbooks/legacy
|
- test-playbooks/ # TODO(ssbarnea): remove skip in follow-up
|
||||||
parseable: true
|
parseable: true
|
||||||
# [204] Lines should be no longer than 160 chars
|
quiet: false
|
||||||
# [301] Commands should not change things if nothing needs doing
|
|
||||||
skip_list:
|
skip_list:
|
||||||
- '204'
|
- '204' # Lines should be no longer than 160 chars
|
||||||
- '301'
|
- '301' # Commands should not change things if nothing needs doing
|
||||||
rulesdir:
|
rulesdir:
|
||||||
- ./.rules/
|
- ./.rules/
|
||||||
use_default_rules: true
|
use_default_rules: true
|
||||||
|
5
linters-requirements.txt
Normal file
5
linters-requirements.txt
Normal 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
|
@ -7,9 +7,9 @@
|
|||||||
state: directory
|
state: directory
|
||||||
register: ansible_lint_tempdir
|
register: ansible_lint_tempdir
|
||||||
|
|
||||||
- name: Install test-requirements.txt
|
- name: Install linters-requirements.txt
|
||||||
pip:
|
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 }}"
|
virtualenv: "{{ ansible_lint_tempdir.path }}"
|
||||||
|
|
||||||
- name: Make sure ansible-lint is installed
|
- name: Make sure ansible-lint is installed
|
||||||
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
- name: Make sure faulty roles fail linting
|
- name: Make sure faulty roles fail linting
|
||||||
command: >-
|
command: >-
|
||||||
{{ ansible_lint_tempdir.path }}/bin/ansible-lint
|
{{ ansible_lint_tempdir.path }}/bin/ansible-lint -c /dev/null
|
||||||
-t {{ item | regex_replace('.*/(ZUULJOBS.*?)/.*', '\1') }}
|
-t {{ item | regex_replace('.*/(ZUULJOBS.*?)/.*', '\1') }}
|
||||||
{{ item }}
|
{{ item }}
|
||||||
args:
|
args:
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
# The order of packages is significant, because pip processes them in the order
|
# 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
|
# of appearance. Changing the order has an impact on the overall integration
|
||||||
# process, which may cause wedges in the gate later.
|
# 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
|
# We need to pin the ansible version directly here; per the
|
||||||
# deprecation policy it should trail the version used by Zuul by 4
|
# 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
|
# dependency solver and the uncapped ansible requirement from
|
||||||
# ansible-lint pull in the latest version.
|
# ansible-lint pull in the latest version.
|
||||||
ansible>=2.6,<2.7 # https://review.opendev.org/#/c/650431/
|
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,<3.0.0;python_version<'3.5' # Apache-2.0
|
||||||
stestr>=1.0.0;python_version>='3.5' # Apache-2.0
|
stestr>=1.0.0;python_version>='3.5' # Apache-2.0
|
||||||
# For upload-logs-swift:
|
# For upload-logs-swift:
|
||||||
|
9
tox.ini
9
tox.ini
@ -41,13 +41,14 @@ passenv =
|
|||||||
setenv =
|
setenv =
|
||||||
ANSIBLE_LIBRARY= {toxinidir}/tests/fake-ansible
|
ANSIBLE_LIBRARY= {toxinidir}/tests/fake-ansible
|
||||||
whitelist_externals = bash
|
whitelist_externals = bash
|
||||||
|
deps =
|
||||||
|
-r{toxinidir}/linters-requirements.txt
|
||||||
|
|
||||||
commands =
|
commands =
|
||||||
flake8 {posargs}
|
flake8 {posargs}
|
||||||
yamllint -s -f parsable .
|
yamllint -s -f parsable .
|
||||||
bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -print0 | \
|
python -m ansiblelint --version
|
||||||
xargs -t -0 ansible-lint"
|
python -m ansiblelint {env:ANSIBLELINT_OPTS:}
|
||||||
bash -c 'find roles -maxdepth 1 -mindepth 1 -type d | \
|
|
||||||
xargs -t ansible-lint'
|
|
||||||
# Ansible Syntax Check
|
# Ansible Syntax Check
|
||||||
bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -exec \
|
bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -exec \
|
||||||
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null"
|
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user