Files
sahara/tox.ini
Elod Illes ae4f27fe0f Preinstall requirements for docs build and fix lower constraints
Sphinx installs the package with its dependencies, but it does not use
the constraints. This can lead to errors if a dependency introduces any
backward incompatible changes. To avoid this the dependencies needs to
be installed prior to sphinx run by tox with the correct constraints.

Conflicts:
    tox.ini

NOTE(elod.illes):
* conflict is due to branch specific upper constraints setting patch.
* this patch also corrects the contradicting lower constraints to make
  the lower-constraints job pass (with the new pip dependency resolver,
  introduced in pip 20.3, the job started to show the contradictions
  and thus started to fail):
  - pycodestyle 2.0.0 is required by flake8 2.6.2
  - MarkupSafe 1.1 is required by some not so old setuptools (this is
    not required in zuul gate, but fails locally usually)
  - warlock 1.3.0 is disallowed by python-glanceclient
* requirements-check job fails with error at bindep install:
    No package matching 'python-guestfs' is available
  and the job runs on ubuntu-focal node. This patch changes the nodeset
  to ubuntu-bionic where 'python-guestfs' still exists.

Change-Id: I4ba83f1007dd11801b8e32c6d7566769e005480b
(cherry picked from commit e0136189fc)
(cherry picked from commit 0900fc028c)
(cherry picked from commit 44ac39ad4d)
(cherry picked from commit 699744e863)
2021-10-26 20:22:31 +02:00

163 lines
5.2 KiB
INI

[tox]
envlist = py27,py37,pep8,genpolicy
minversion = 1.6
skipsdist = True
[testenv]
usedevelop = True
install_command = pip install {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
DISCOVER_DIRECTORY=sahara/tests/unit
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/train}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = stestr run {posargs}
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
[testenv:cover]
basepython = python3
setenv =
PACKAGE_NAME=sahara
commands = {toxinidir}/tools/cover.sh {posargs}
[testenv:debug-py27]
basepython = python2.7
commands = oslo_debug_helper -t sahara/tests/unit {posargs}
[testenv:debug-py36]
basepython = python3.6
commands = oslo_debug_helper -t sahara/tests/unit {posargs}
[testenv:debug-py37]
basepython = python3.7
commands = oslo_debug_helper -t sahara/tests/unit {posargs}
[testenv:pep8]
basepython = python3
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/train}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/doc/requirements.txt
commands =
flake8 {posargs}
doc8 doc/source
# Run bashate checks
bash -c "find devstack -not -name \*.template -and -not -name README.rst -and -not -name \*.json -type f -print0 | xargs -0 bashate -v"
# Run security linter
bandit -c bandit.yaml -r sahara -n5 -p sahara_default -x tests
[testenv:genpolicy]
basepython = python3
commands = oslopolicy-sample-generator --config-file tools/config/sahara-policy-generator.conf
[testenv:venv]
basepython = python3
commands = {posargs}
[testenv:images]
sitepackages = True
commands = {posargs}
[testenv:docs]
basepython = python3
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/train}
-r{toxinidir}/requirements.txt
-r{toxinidir}/doc/requirements.txt
commands =
rm -rf doc/html doc/build
rm -rf api-ref/build api-ref/html
rm -rf doc/source/apidoc doc/source/api
sphinx-build -W -b html doc/source doc/build/html
sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html
whereto doc/source/_extra/.htaccess doc/test/redirect-tests.txt
whitelist_externals = rm
[testenv:api-ref]
basepython = python3
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/train}
-r{toxinidir}/doc/requirements.txt
install_command = pip install -U --force-reinstall {opts} {packages}
commands =
rm -rf api-ref/build api-ref/html
sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html
whitelist_externals = rm
[testenv:pylint]
basepython = python3
setenv = VIRTUAL_ENV={envdir}
commands = bash tools/lintstack.sh
[testenv:genconfig]
basepython = python3
commands =
oslo-config-generator --config-file tools/config/config-generator.sahara.conf \
--output-file etc/sahara/sahara.conf.sample
[testenv:releasenotes]
basepython = python3
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/train}
-r{toxinidir}/doc/requirements.txt
commands =
rm -rf releasenotes/build releasenotes/html
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
whitelist_externals = rm
[testenv:debug]
basepython = python3
# It runs tests from the specified dir (default is sahara/tests)
# in interactive mode, so, you could use pbr for tests debug.
# Example usage: tox -e debug -- -t sahara/tests/unit some.test.path
# https://docs.openstack.org/oslotest/latest/features.html#debugging-with-oslo-debug-helper
commands = oslo_debug_helper -t sahara/tests/unit {posargs}
[testenv:bandit]
basepython = python3
deps = -r{toxinidir}/test-requirements.txt
commands = bandit -c bandit.yaml -r sahara -n5 -p sahara_default -x tests
[flake8]
show-source = true
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,tools
# [H904] Delay string interpolations at logging calls
# [H106] Don't put vim configuration in source files
# [H203] Use assertIs(Not)None to check for None.
# [H204] Use assert(Not)Equal to check for equality
# [H205] Use assert(Greater|Less)(Equal) for comparison
enable-extensions=H904,H106,H203,H204,H205
# [E123] Closing bracket does not match indentation of opening bracket's line
# [E226] Missing whitespace around arithmetic operator
# [E402] Module level import not at top of file
# [E731] Do not assign a lambda expression, use a def
# [W503] Line break occurred before a binary operator
# [W504] Line break occurred after a binary operator
# [W605] Invalid escape sequence 'x'
ignore=E123,E226,E402,E731,W503,W504,W605
[hacking]
import_exceptions = sahara.i18n
local-check-factory = sahara.utils.hacking.checks.factory
[testenv:bindep]
basepython = python3
# Do not install any requirements. We want this to be fast and work even if
# system dependencies are missing, since it's used to tell you what system
# dependencies are missing! This also means that bindep must be installed
# separately, outside of the requirements files.
deps = bindep
commands = bindep test
[testenv:lower-constraints]
basepython = python3
deps =
-c{toxinidir}/lower-constraints.txt
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt