From 0c3ab1ce8db352ca06cc011fc618bf161aae191a Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 23 Apr 2020 13:58:43 +0100 Subject: [PATCH] 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 --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 818d1c677..ef78d7e69 100644 --- a/tox.ini +++ b/tox.ini @@ -40,9 +40,9 @@ whitelist_externals = bash commands = flake8 {posargs} 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 | \ - xargs -t -n1 ansible-lint' + xargs -t ansible-lint' # 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" @@ -50,7 +50,7 @@ commands = {toxinidir}/tools/update-test-platforms.py 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 "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] commands = {posargs}