aboutsummaryrefslogtreecommitdiff
path: root/tox.ini
diff options
context:
space:
mode:
authorMichal Nasiadka <mnasiadka@gmail.com>2019-11-18 14:04:40 +0000
committerRadosław Piliszek <radoslaw.piliszek@gmail.com>2020-05-17 17:02:38 +0200
commitd8f31e0a5ef28dcc2325fd5951657e211c39a465 (patch)
tree6df955916790c96c9144506331ac612ae693d55b /tox.ini
parentfe54fdbc347cac4820e51c4bbd44ad71f6dd4e74 (diff)
downloadkolla-ansible-d8f31e0a5ef28dcc2325fd5951657e211c39a465.tar.gz
kolla-ansible-d8f31e0a5ef28dcc2325fd5951657e211c39a465.zip
CI: Add ansible-lint to tox
* Reworked tox pep8 into linters job, that runs: - pep8 - bandit - bashate - doc8 - yamllint - ansible-lint (validate-all-files.py + ansible-lint) * Skip E701 - missing galaxy_info in meta and E602 see [1]. * Skip E301 and E503 - followup later in a separate change * Added ansible-role-jobs to zuul.d/project.yaml which will run openstack-tox-linters job in check queue * Fixed remaining style issue * Made tox and docs reference the new env for linters * Dropped pype environment (not supported) [1]: https://github.com/ansible/ansible-lint/issues/457 Change-Id: I494b4b151804aac8173120e6c6e42bc2fdb00234
Diffstat (limited to 'tox.ini')
-rw-r--r--tox.ini96
1 files changed, 64 insertions, 32 deletions
diff --git a/tox.ini b/tox.ini
index 38a521b4e..184078823 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,12 +1,12 @@
[tox]
minversion = 3.1
skipsdist = True
-envlist = py37,pep8,pypy
+envlist = py37,linters
ignore_basepython_conflict = True
[testenv]
basepython = python3
-usedevelop=True
+usedevelop = True
whitelist_externals = find
rm
deps = -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
@@ -31,29 +31,10 @@ setenv = VIRTUAL_ENV={envdir}
NOSE_COVER_HTML_DIR={toxinidir}/cover
PYTHON=coverage run --source kolla_ansible,ansible/action_plugins,ansible/library,ansible/roles/keystone/files/ --parallel-mode
commands =
- stestr run {posargs}
- coverage combine
- coverage html -d cover
- coverage xml -o cover/coverage.xml
-
-[testenv:pep8]
-# sphinx needs to be installed to make doc8 work properly
-deps =
- {[testenv]deps}
- -r{toxinidir}/doc/requirements.txt
- yamllint
-commands =
- {toxinidir}/tools/run-bashate.sh
- flake8 {posargs}
- doc8 doc/source
- doc8 -e '.yaml' releasenotes/notes/
- python {toxinidir}/tools/validate-all-file.py
- bandit --skip B303 -r ansible kolla_ansible tests tools
- yamllint -s .
-
-[testenv:bandit]
-# B303: Use of insecure MD2, MD4, MD5, or SHA1 hash function.
-commands = bandit --skip B303 -r ansible kolla_ansible tests tools
+ stestr run {posargs}
+ coverage combine
+ coverage html -d cover
+ coverage xml -o cover/coverage.xml
[testenv:venv]
deps =
@@ -74,7 +55,6 @@ commands =
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/doc/requirements.txt
-
commands =
rm -rf deploy-guide/build
sphinx-build -a -E -W -d deploy-guide/build/doctrees --keep-going -b html deploy-guide/source deploy-guide/build/html
@@ -95,6 +75,36 @@ commands =
rm -rf releasenotes/build
sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html
+[testenv:lower-constraints]
+deps =
+ -c{toxinidir}/lower-constraints.txt
+ -r{toxinidir}/test-requirements.txt
+ -r{toxinidir}/requirements.txt
+
+[testenv:linters]
+# Env vars and deps need to be defined in top level tox env
+setenv =
+ ANSIBLE_LIBRARY = {toxinidir}/ansible/library
+ ANSIBLE_ACTION_PLUGINS = {toxinidir}/ansible/action_plugins
+ ANSIBLE_FILTER_PLUGINS = {toxinidir}/ansible/filter_plugins
+deps =
+ -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
+ -r{toxinidir}/test-requirements.txt
+ -r{toxinidir}/doc/requirements.txt
+whitelist_externals = bash
+commands =
+ {[testenv:pep8]commands}
+ {[testenv:doc8]commands}
+ {[testenv:bandit]commands}
+ {[testenv:bashate]commands}
+ {[testenv:yamllint]commands}
+ {[testenv:ansible-lint]commands}
+
+[testenv:pep8]
+deps = {[testenv:linters]deps}
+commands =
+ flake8 {posargs}
+
[flake8]
show-source = True
# NOTE: Default ignore list is *not* empty!
@@ -102,10 +112,32 @@ show-source = True
# (W503 and W504 are incompatible and we need to choose one of them.
# Existing codes follows W503, so we disable W504.):
ignore = W504
-exclude=.eggs,.git,.tox,doc
+exclude = .eggs,.git,.tox,doc
-[testenv:lower-constraints]
-deps =
- -c{toxinidir}/lower-constraints.txt
- -r{toxinidir}/test-requirements.txt
- -r{toxinidir}/requirements.txt
+[testenv:doc8]
+deps = {[testenv:linters]deps}
+commands =
+ doc8 doc/source
+ doc8 -e '.yaml' releasenotes/notes/
+
+[testenv:bashate]
+deps = {[testenv:linters]deps}
+commands =
+ bash -c "{toxinidir}/tools/run-bashate.sh"
+
+[testenv:bandit]
+# B303: Use of insecure MD2, MD4, MD5, or SHA1 hash function.
+deps = {[testenv:linters]deps}
+commands = bandit --skip B303 -r ansible kolla_ansible tests tools
+
+[testenv:ansible-lint]
+# Lint only code in ansible/* - ignore tests/ and roles/ used by CI
+setenv = {[testenv:linters]setenv}
+deps = {[testenv:linters]deps}
+commands =
+ python {toxinidir}/tools/validate-all-file.py
+ ansible-lint -p --exclude {toxinidir}/tests --exclude {toxinidir}/roles
+
+[testenv:yamllint]
+deps = {[testenv:linters]deps}
+commands = yamllint -s .