Move linters dependencies to tox.ini

One of suggestions discussed in the mailling thread [1] is to decouple
linters from test-requirements.txt. We uses specific versions of linters
(hacking, flake8, pylint and bandit) and they are potentially incompatbile
with other libraries in test-requirements.txt.
One example is bandit incompatibility detected by the new pip resolver.
This commit moves linters to tox.ini and introduces a new tox envdir
shared by linter related tox envs.

Note that we have a unit test for a local hacking rule so hacking needs
to be installed as part of the default dependencies. We can have it in
test-requirements.txt but I think it is better to have it in tox.ini
as hacking is a part of linters and other linter dependencies are
declared in tox.ini now.

[1] http://lists.openstack.org/pipermail/openstack-discuss/2020-December/thread.html#19362

Change-Id: Ia41c5f665f01bdab187c9256b2319885998d12c3
This commit is contained in:
Akihiro Motoki 2021-01-14 07:26:59 +09:00
parent 792ffb3cfd
commit ffe84dbf9d
3 changed files with 15 additions and 13 deletions

View File

@ -3,7 +3,6 @@ amqp==2.1.1
appdirs==1.4.0
asn1crypto==0.23.0
Babel==2.6.0
bandit==1.4.0
cachetools==2.0.0
cffi==1.14.0
chardet==3.0.4
@ -78,7 +77,6 @@ positional==1.2.1
prettytable==0.7.2
pycodestyle==2.5.0
pycparser==2.18
pyflakes==2.1.0
Pygments==2.2.0
pyinotify==0.9.6
pymongo==3.0.2

View File

@ -6,19 +6,13 @@
# added in alphabetical order, however, some dependencies may need to
# be installed in a specific order.
#
# Hacking should appear first in case something else depends on pep8
hacking>=3.0.1,<3.1.0 # Apache-2.0
#
bandit!=1.6.0,>=1.4.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
flake8-import-order==0.12 # LGPLv3
freezegun>=0.3.15 # Apache-2.0
nodeenv>=0.9.4 # BSD
pytest>=5.3.5 # MIT
pytest-django>=3.8.0 # BSD (3 clause)
pytest-html>=2.0.1 #MPL-2.0
python-memcached>=1.59 # PSF
pylint==2.6.0 # GPLv2
selenium>=2.50.1 # Apache-2.0
testscenarios>=0.4 # Apache-2.0/BSD
testtools>=2.2.0 # MIT

20
tox.ini
View File

@ -23,6 +23,8 @@ deps =
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
# Unit test for a local hacking rule requires hacking.
hacking>=3.0.1,<3.1.0 # Apache-2.0
commands =
find . -type f -name "*.pyc" -delete
bash {toxinidir}/tools/unit_tests.sh {toxinidir} {posargs}
@ -32,13 +34,20 @@ deps =
-c{toxinidir}/lower-constraints.txt
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
# Unit test for a local hacking rule requires hacking.
hacking>=3.0.1,<3.1.0 # Apache-2.0
[testenv:venv]
envdir = {toxworkdir}/venv
commands = {posargs}
[testenv:pep8]
envdir = {toxworkdir}/venv
envdir = {toxworkdir}/linters
deps =
{[testenv]deps}
flake8-import-order==0.12 # LGPLv3
pylint==2.6.0 # GPLv2
bandit!=1.6.0,>=1.4.0 # Apache-2.0
setenv =
DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings
commands =
@ -131,7 +140,6 @@ commands =
doc8 doc/source
[testenv:pdf-docs]
basepython = python3
envdir = {toxworkdir}/docs
deps = {[testenv:docs]deps}
whitelist_externals =
@ -164,12 +172,14 @@ commands =
{envpython} {toxinidir}/manage.py compilemessages -v 0 --traceback
[testenv:bandit]
envdir = {toxworkdir}/venv
envdir = {toxworkdir}/linters
deps = {[testenv:pep8]deps}
commands = bandit -r horizon openstack_auth openstack_dashboard -n5 -x tests -ll
[testenv:bandit-baseline]
envdir = {toxworkdir}/venv
commands = bandit-baseline -r horizon openstack_auth openstack_dashboard -n5 -x tests -ii -ll
envdir = {toxworkdir}/linters
deps = {[testenv:pep8]deps}
commands = bandit-baseline -r horizon openstack_auth openstack_dashboard -n5 -x tests -ii -ll
[flake8]
filename = *.py,django.wsgi