Files
distcloud/distributedcloud/tox.ini
BoYuan Chang b19d706e44 Make Tox compatible to Debian Python3.9 Environment
A different version of astroid is required for python3.9, pylint,
and pep8. The pylint setup related to pip and upper constraints
is different for python3.9. Updated the requirement packages'
software version(to versions that support python3.9) Updated
'cover' tox.ini target to be python3.9

This flake8 suppresion is added:
  H126: flag use of third party mock

These pylint disable/enable alarm checks are removed due to deprecation:
-Enable
  E1606: execfile-builtin
  E1607: old-ne-operator
  E1608: old-octal-literal
  E1610: non-ascii-bytes-literal
  E1611: invalid-unicode-literal
  W1641: eq-without-hash

-Disable
  W0403: relative-import

These pylint suppressions need to be added
  W0707: raise-missing-from
  W1406: redundant-u-string-prefix
  W1514: unspecified-encoding
  E1101: no-member

The explicit addition of python3 checks that were required
when running pylint in python2 to test python3 are removed
since pylint is now running in python3 and gets those
checks implicitly.

Removed config keys from the pylint.rc that are no longer
valid for the version of pylint executed by python3.9.

The zuul target explicitly specifies python3.9 and the
ubuntu-focal node to ensure it has the correct interpreter.

Depends-On: https://review.opendev.org/c/starlingx/distcloud/+/850543
Story: 2008943
Task: 45692

Signed-off-by: BoYuan Chang <boyuan.chang@windriver.com>
Change-Id: I70280a5fee178c228e138d4ac1c047dae7696c85
2022-07-28 12:48:25 -04:00

245 lines
7.5 KiB
INI

[tox]
envlist = pep8,py27,py39,pylint,pep8_Debian,pylint_Debian
minversion = 2.3
skipsdist = True
# move tox work directory out of the source tree
toxworkdir = /tmp/{env:USER}_dctox
[dc]
dc_base_dir = .
stx_fault_dir = ../../fault
nfv_client_src_dir = ../../nfv/nfv/nfv-client
fmclient_src_dir = {[dc]stx_fault_dir}/python-fmclient/fmclient
fm_api_src_dir = {[dc]stx_fault_dir}/fm-api/source
tsconfig_src_dir = ../../config/tsconfig/tsconfig
cgtsclient_src_dir = ../../config/sysinv/cgts-client/cgts-client
cgcs_patch_src_dir = ../../update/cgcs-patch/cgcs-patch
stx_root_dir = ../../root
[testenv]
sitepackages = False
install_command = pip install -v -v -v \
-c https://opendev.org/openstack/requirements/raw/branch/stable/stein/upper-constraints.txt \
{opts} {packages}
# If a target such as pylint requires executing the code, install these modules
# using the -e option (without using sdist. ie: developer mode)
# Note: usedevelop=True and skipsdist=True cannot both be used
install_runtime =
pip install -e {[dc]nfv_client_src_dir} \
-e {[dc]tsconfig_src_dir} \
-e {[dc]fmclient_src_dir} \
-e {[dc]fm_api_src_dir} \
-e {[dc]cgtsclient_src_dir} \
-e {[dc]cgcs_patch_src_dir}
setenv =
VIRTUAL_ENV={envdir}
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
CURRENT_CFG_FILE={toxinidir}/.current.cfg
SINGLE_REPO=True
OSLO_LOCK_PATH={toxinidir}
deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
whitelist_externals =
rm
find
reno
[testenv:py27]
basepython = python2.7
commands =
{[testenv]install_runtime}
find {toxinidir} -not -path '{toxinidir}/.tox/*' -name '*.py[c|o]' -delete
python setup.py testr --slowest --testr-args='{posargs}'
[testenv:py36]
basepython = python3.6
commands =
{[testenv]install_runtime}
find {toxinidir} -not -path '{toxinidir}/.tox/*' -name '*.py[c|o]' -delete
python setup.py testr --slowest --testr-args='{posargs}'
[testenv:py39]
basepython = python3.9
install_command = pip install -v -v -v \
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
{opts} {packages}
deps = -r{toxinidir}/test-requirements-debian.txt
-r{toxinidir}/requirements.txt
keyring
-e{[dc]nfv_client_src_dir}
-e{[dc]tsconfig_src_dir}
-e{[dc]fmclient_src_dir}
-e{[dc]fm_api_src_dir}
-e{[dc]cgtsclient_src_dir}
commands =
find {toxinidir} -not -path '{toxinidir}/.tox/*' -name '*.py[c|o]' -delete
python setup.py testr --slowest --testr-args='{posargs}'
[testenv:debug-py27]
basepython = python2.7
commands = oslo_debug_helper {posargs}
[testenv:pep8]
basepython = python3
commands = flake8
[testenv:pep8_Debian]
basepython = python3.9
deps = -r{toxinidir}/test-requirements-debian.txt
install_command = pip install -v -v -v \
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
{opts} {packages}
commands = flake8
[testenv:venv]
basepython = python3
commands = {posargs}
[testenv:cover]
basepython = python2.7
commands =
{[testenv]install_runtime}
coverage erase
rm -Rf cover
rm -f coverage.xml
find {toxinidir} -not -path '{toxinidir}/.tox/*' -name '*.py[c|o]' -delete
python setup.py testr --coverage --testr-args='{posargs}'
coverage html -d cover
coverage xml --rcfile=.coveragerc_xml
coverage report
[testenv:cover_Debian]
basepython = python3.9
install_command = pip install -v -v -v \
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
{opts} {packages}
deps = -r{toxinidir}/test-requirements-debian.txt
-r{toxinidir}/requirements.txt
keyring
-e{[dc]nfv_client_src_dir}
-e{[dc]tsconfig_src_dir}
-e{[dc]fmclient_src_dir}
-e{[dc]fm_api_src_dir}
-e{[dc]cgtsclient_src_dir}
commands =
coverage erase
rm -Rf cover
rm -f coverage.xml
find {toxinidir} -not -path '{toxinidir}/.tox/*' -name '*.py[c|o]' -delete
python setup.py testr --coverage --testr-args='{posargs}'
coverage html -d cover
coverage xml --rcfile=.coveragerc_xml
coverage report
[testenv:docs]
basepython = python3
install_command = pip install -U {opts} {packages}
deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf doc/build
sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html
whitelist_externals = rm
[testenv:releasenotes]
basepython = python3
install_command = pip install -U {opts} {packages}
deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf releasenotes/build
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
whitelist_externals = rm
[testenv:newnote]
basepython = python3
# Re-use the releasenotes venv
envdir = {toxworkdir}/releasenotes
deps = -r{toxinidir}/doc/requirements.txt
commands = reno new {posargs}
[testenv:api-ref]
basepython = python3
install_command = pip install -U {opts} {packages}
deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf api-ref/build
sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html
whitelist_externals = rm
[testenv:debug]
basepython = python3
commands = oslo_debug_helper {posargs}
[flake8]
show-source = True
# Suppressed flake8 codes
# W503 line break before binary operator
# W504 line break after binary operator
# W605 invalid escape sequence
# E117 over-indented
# E123 closing bracket does not match indentation of opening bracket's line
# E125 continuation line with same indent as next logical line
# E305 expected 2 blank lines after class or function definition
# E402 module level import not at top of file
# E501 line too long
# E731 do not assign a lambda expression, use a def
# H216 flag use of third party mock
ignore = W503,W504,W605,H216,
E117,E123,E125,E305,E402,E501,E731
builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
[testenv:genconfig]
basepython = python3
commands =
oslo-config-generator --config-file=tools/config-generator.conf
[hacking]
import_exceptions = dcmanager.common.i18n,dcorch.common.i18n
[testenv:pylint]
basepython = python3
commands =
{[testenv]install_runtime}
pylint {posargs} dccommon dcmanager dcorch dcdbsync --rcfile=./pylint.rc
[testenv:pylint_Debian]
basepython = python3.9
deps = -r{toxinidir}/test-requirements-debian.txt
-r{toxinidir}/requirements.txt
-e{[dc]nfv_client_src_dir}
-e{[dc]tsconfig_src_dir}
-e{[dc]fmclient_src_dir}
-e{[dc]fm_api_src_dir}
-e{[dc]cgtsclient_src_dir}
-e{[dc]cgcs_patch_src_dir}
install_command = pip install -v -v -v \
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
{opts} {packages}
setenv =
{[testenv]setenv}
PYTHONPATH = {toxinidir}
commands =
pylint {posargs} dccommon dcmanager dcorch dcdbsync --rcfile=./pylint.rc
[testenv:linters]
basepython = python3
# bashate ignore:
# E006 - accept long lines
# E040 - false positive on |& syntax (new in bash 4)
whitelist_externals = bash
commands =
bash -c "find {toxinidir} \
\( -name .tox -prune \) \
-o -type f -name '*.yaml' \
-print0 | xargs -r -0 yamllint"