Fix tox.ini misconfigurations
Previous setup introduce several problems because pre-commit was never run with all configured hooks. New setup does not require any changes to tox.ini when new linters/hooks are added. - openstack-tox-pep8 removed, replaced by generic linters - fixed bug where CI did not run all linters, mainly because of tox.ini env layout - kept only one linters environment with its sole requirement - saved considerable amount of time wasted installing unused dependencies - moved doc8 config to setup.cfg (standard location) Change-Id: Idda6418ea1dcc3877e078f3cd9c59631fcc2ec68
This commit is contained in:
committed by
Sagi Shnaidman
parent
b8301c2493
commit
48946e8588
@@ -50,3 +50,8 @@ skip_changelog = True
|
||||
# based on https://github.com/psf/black
|
||||
ignore = E203,E501,W503,W504,D
|
||||
# "D" added because we do not use docstrings checks, yet
|
||||
|
||||
[doc8]
|
||||
# Settings for doc8:
|
||||
extensions = .rst
|
||||
ignore = D001
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
pre-commit # MIT
|
||||
netaddr # BSD
|
||||
mock>=2.0.0 # BSD
|
||||
stestr>=2.0.0 # Apache-2.0
|
||||
|
||||
65
tox.ini
65
tox.ini
@@ -42,55 +42,21 @@ whitelist_externals =
|
||||
deps = bindep
|
||||
commands = bindep test
|
||||
|
||||
[testenv:linters]
|
||||
description =
|
||||
Runs all linters, if you want to run a single one, use posargs to mention
|
||||
it. Example `tox -e linters -- ansible-lint`
|
||||
deps =
|
||||
pre-commit>=1.20 # MIT
|
||||
commands =
|
||||
python -m pre_commit run -a {posargs}
|
||||
|
||||
# Use 'linters' instead, kept only for compatibility with:
|
||||
# https://opendev.org/openstack/openstack-zuul-jobs/src/branch/master/zuul.d/project-templates.yaml#L459
|
||||
[testenv:pep8]
|
||||
envdir = {toxworkdir}/linters
|
||||
commands =
|
||||
python -m pre_commit run flake8 -a
|
||||
|
||||
[testenv:ansible-lint]
|
||||
envdir = {toxworkdir}/linters
|
||||
deps =
|
||||
{[testenv:linters]deps}
|
||||
commands =
|
||||
python -m pre_commit run ansible-lint -a
|
||||
# bash -c "ANSIBLE_ROLES_PATH='{toxinidir}/roles' \
|
||||
# ansible-galaxy install -fr {toxinidir}/ansible-role-requirements.yml"
|
||||
|
||||
[testenv:yamllint]
|
||||
envdir = {toxworkdir}/linters
|
||||
deps = {[testenv:linters]deps}
|
||||
commands =
|
||||
python -m pre_commit run yamllint -a
|
||||
|
||||
[testenv:bashate]
|
||||
envdir = {toxworkdir}/linters
|
||||
deps = {[testenv:linters]deps}
|
||||
commands =
|
||||
python -m pre_commit run bashate -a
|
||||
|
||||
[testenv:whitespace]
|
||||
envdir = {toxworkdir}/linters
|
||||
deps = {[testenv:linters]deps}
|
||||
commands =
|
||||
python -m pre_commit run trailing-whitespace -a
|
||||
|
||||
[testenv:shebangs]
|
||||
envdir = {toxworkdir}/linters
|
||||
deps = {[testenv:linters]deps}
|
||||
commands =
|
||||
python -m pre_commit run check-executables-have-shebangs -a
|
||||
|
||||
[testenv:linters]
|
||||
deps =
|
||||
-r {toxinidir}/requirements.txt
|
||||
-r {toxinidir}/test-requirements.txt
|
||||
commands =
|
||||
{[testenv:pep8]commands}
|
||||
{[testenv:ansible-lint]commands}
|
||||
{[testenv:bashate]commands}
|
||||
{[testenv:yamllint]commands}
|
||||
{[testenv:whitespace]commands}
|
||||
{[testenv:shebangs]commands}
|
||||
commands = {[testenv:linters]commands}
|
||||
|
||||
[testenv:releasenotes]
|
||||
basepython = python3
|
||||
@@ -106,11 +72,6 @@ commands=
|
||||
doc8 doc
|
||||
sphinx-build -a -E -W -d doc/build/doctrees --keep-going -b html doc/source doc/build/html -T
|
||||
|
||||
[doc8]
|
||||
# Settings for doc8:
|
||||
extensions = .rst
|
||||
ignore = D001
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
||||
@@ -140,3 +101,5 @@ deps =
|
||||
oslotest
|
||||
commands =
|
||||
python -m pytest -ra --continue-on-collection-errors -v --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} -k {posargs}
|
||||
|
||||
# do not put tool config in tox.ini, use setup.cfg or tool specific files
|
||||
|
||||
Reference in New Issue
Block a user