Improve linters execution

- Avoid calling ansible-lint for each argument as this slows down
  its execution time considerably (105s -> 41s)
- Prints list of offending files when git reports dirty, avoiding
  confusions errors.

Change-Id: I4b6c6a7935febc4934d0fc6a55f7f9d3e6e87942
This commit is contained in:
Sorin Sbarnea 2020-04-23 13:58:43 +01:00
parent 5cf7470fa9
commit 0c3ab1ce8d

View File

@ -40,9 +40,9 @@ whitelist_externals = bash
commands = commands =
flake8 {posargs} flake8 {posargs}
bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -print0 | \ bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -print0 | \
xargs -t -n1 -0 ansible-lint" xargs -t -0 ansible-lint"
bash -c 'find roles -maxdepth 1 -mindepth 1 -type d | \ bash -c 'find roles -maxdepth 1 -mindepth 1 -type d | \
xargs -t -n1 ansible-lint' 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"
@ -50,7 +50,7 @@ commands =
{toxinidir}/tools/update-test-platforms.py {toxinidir}/tools/update-test-platforms.py
bash -c "(( $(find playbooks -name *.yml | wc -l) == 0)) || \{ echo 'Use .yaml'; exit 1; \}" bash -c "(( $(find playbooks -name *.yml | wc -l) == 0)) || \{ echo 'Use .yaml'; exit 1; \}"
bash -c "(( $(find roles -name *.yml | wc -l) == 0)) || \{ echo 'Use .yaml'; exit 1; \}" bash -c "(( $(find roles -name *.yml | wc -l) == 0)) || \{ echo 'Use .yaml'; exit 1; \}"
bash -c "git diff --quiet || \{ echo 'ERROR: git in dirty status, reporting as failure'; exit 1; \}" bash -c "git diff --quiet || \{ git status --porcelain; echo 'ERROR: git in dirty status, reporting as failure'; exit 1; \}"
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}