[tox] envlist = linters,pep8,pylint minversion = 2.3 skipsdist = True [testenv] basepython = python3 install_command = pip install \ -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \ {opts} {packages} setenv = VIRTUAL_ENV={envdir} OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=60 deps = -r{toxinidir}/test-requirements.txt allowlist_externals = reno [trixie] basepython = python3 setenv = {[testenv]setenv} UPPER_CONSTRAINTS_FILE=https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/trixie/upper-constraints.txt install_command = pip install \ -c{env:UPPER_CONSTRAINTS_FILE} \ {opts} {packages} [testenv:bashate] allowlist_externals = bash commands = bash -c "find {toxinidir} \ -not \( -type d -name .?\* -prune \) \ -type f \ -not -name \*~ \ -not -name \*.md \ \( \ -name \*.sh \ -or -not -wholename \*/devstack/files/\* \ -wholename \*/devstack/\* \ \) \ -print0 | xargs -r -n 1 -0 bashate -v -e E* -i E006" [testenv:yamllint] allowlist_externals = bash commands = bash -c "find {toxinidir} \ \( -name .tox -prune \) \ -o -type f -name '*.yaml' \ -print0 | xargs -0 yamllint" [testenv:linters] allowlist_externals = bash install_command = pip install {opts} {packages} commands = {[testenv:bashate]commands} {[testenv:yamllint]commands} [testenv:pylint] install_command = pip install {opts} {packages} deps = {[testenv]deps} eventlet httplib2 iso8601 jsonpatch keystonemiddleware kombu oslo.config pecan prettytable psutil sqlalchemy sqlalchemy-migrate wsme pylint commands = pylint --rcfile=./pylint.rc --extension-pkg-whitelist=greenlet \ --disable=import-error,possibly-used-before-assignment \ ./service-mgmt-api/sm-api/sm_api/ \ ./service-mgmt-tools/sm-tools/sm_tools/ \ ./service-mgmt-client/sm-client/sm_client/ [flake8] # E275 missing whitespace after keyword # E402 module level import not at top of file # E721 do not compare types, use isinstance() # E741 ambiguous variable name # F811 redefinition of unused variable from line # F821 undefined name # F824 unused global variable # F841 local variable is assigned to but never used # F901 raise NotImplemented should be raise NotImplementedError # H102 Apache 2.0 license header not found # H104 File contains nothing but comments # H105 Do not use author tags # H106 Do not put vim configuration in source files # H216 The unittest.mock module should be used rather than third party mock # H306 imports not in alphabetical order # H401 docstring should not start with a space # H403 multi line docstrings should end on a new line # H404 multi line docstring should start without a leading new line # H405 multi line docstring summary not separated with an empty line # H501 Do not use locals() for string formatting # W503 line break before binary operator # W504 line break after binary operator # W605 invalid escape sequence # B008 Do not perform calls in argument defaults # B009 Do not call getattr with a constant attribute value # B014 Redundant exception types # B017 assertRaises(Exception) too broad # H906 LOG.warn used in application source (deprecated alias, not our code to fix) show-source = True ignore= E275,E402,E721,E741,H906, F811,F821,F824,F841,F901, H102,H104,H105,H106,H216,H306,H401,H403,H404,H405,H501, W503,W504,W605, B008,B009,B014,B017 exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-* # H203 Use assertIs(Not)None to check for None (off by default). # TODO(pk10): H904 Delay string interpolations at logging calls (off by default). enable-extensions = H203 max-line-length = 110 [testenv:pep8] usedevelop = False skip_install = True deps = -r{toxinidir}/test-requirements.txt flake8-bugbear<23.2.13 install_command = pip install {opts} {packages} commands = flake8 [testenv:venv] commands = {posargs} [testenv:docs] 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 allowlist_externals = rm [testenv:releasenotes] 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 allowlist_externals = rm [testenv:newnote] # Re-use the releasenotes venv install_command = pip install -U {opts} {packages} envdir = {toxworkdir}/releasenotes deps = -r{toxinidir}/doc/requirements.txt commands = reno new {posargs} [testenv:api-ref] 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 allowlist_externals = rm [bandit] # B324: hashlib # B411: blacklist Using xmlrpclib skips = B324,B411 [testenv:bandit] description = Bandit code scan for *.py files under config folder deps = -r{toxinidir}/test-requirements.txt install_command = pip install {opts} {packages} commands = bandit --ini tox.ini -r {toxinidir}/ -x '**/.tox/**',**/.eggs/** -lll [testenv:bindep] # 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. skip_install = True deps = bindep commands = bindep test [coverage-deps] deps = -r{toxinidir}/test-requirements.txt pytest pytest-cov psutil netaddr six prettytable oslo.utils oslo.config httplib2 python-keystoneclient iso8601 eventlet pecan wsme sqlalchemy sqlalchemy-migrate jsonpatch keystonemiddleware kombu redis fixtures mock [testenv:coverage] basepython = python3 setenv = {[testenv]setenv} install_command = pip install {opts} {packages} deps = {[coverage-deps]deps} setuptools<71 allowlist_externals = bash mkdir cp commands = mkdir -p {toxinidir}/UTCoverage pytest {toxinidir}/tests/ \ --cov={toxinidir}/service-mgmt-tools/sm-tools \ --cov={toxinidir}/service-mgmt-client/sm-client \ --cov={toxinidir}/service-mgmt-api/sm-api \ --cov-report=term-missing \ --cov-report=html:{toxinidir}/UTCoverage/htmlcov \ --cov-config={toxinidir}/.coveragerc \ -v --tb=short \ {posargs} [testenv:security] basepython = python3 setenv = {[testenv]setenv} deps = {[testenv]deps} install_command = pip install {opts} {packages} allowlist_externals = bash mkdir commands = mkdir -p {toxinidir}/UTCoverage bash -c "bandit --ini tox.ini -r \ {toxinidir}/service-mgmt-tools/sm-tools/sm_tools \ {toxinidir}/service-mgmt-client/sm-client/sm_client \ -lll -f txt -o {toxinidir}/UTCoverage/security_report.txt" bash -c "bandit --ini tox.ini -r \ {toxinidir}/service-mgmt-tools/sm-tools/sm_tools \ {toxinidir}/service-mgmt-client/sm-client/sm_client \ -lll -f json -o {toxinidir}/UTCoverage/bandit-report.json" [testenv:coverage-c] basepython = python3 setenv = {[testenv]setenv} install_command = pip install {opts} {packages} allowlist_externals = bash mkdir which commands = mkdir -p {toxinidir}/UTCoverage bash -c "if ! which gcc >/dev/null 2>&1; then \ echo 'gcc not found - skipping C/C++ coverage' > {toxinidir}/UTCoverage/coverage-c_skipped.txt; \ exit 0; \ fi; \ echo 'C/C++ coverage analysis' > {toxinidir}/UTCoverage/coverage_c_report.txt; \ c_count=$(find {toxinidir}/service-mgmt/sm/src -name '*.c' | wc -l); \ cpp_count=$(find {toxinidir}/service-mgmt/sm/src -name '*.cpp' | wc -l); \ h_count=$(find {toxinidir}/service-mgmt/sm/src -name '*.h' | wc -l); \ echo \"C files: $c_count\" >> {toxinidir}/UTCoverage/coverage_c_report.txt; \ echo \"C++ files: $cpp_count\" >> {toxinidir}/UTCoverage/coverage_c_report.txt; \ echo \"Header files: $h_count\" >> {toxinidir}/UTCoverage/coverage_c_report.txt; \ echo 'Note: Full C/C++ coverage requires build environment with gcov/lcov' >> {toxinidir}/UTCoverage/coverage_c_report.txt" [testenv:pylint-trixie] basepython = {[trixie]basepython} usedevelop = False description = Pylint check (Trixie) setenv = {[trixie]setenv} install_command = {[trixie]install_command} deps = {[testenv]deps} eventlet httplib2 iso8601 jsonpatch keystonemiddleware kombu oslo.config pecan prettytable psutil sqlalchemy sqlalchemy-migrate wsme pylint commands = {[testenv:pylint]commands} [testenv:coverage-trixie] basepython = {[trixie]basepython} usedevelop = False description = Run all tests with coverage analysis (Trixie) setenv = {[trixie]setenv} install_command = {[trixie]install_command} deps = {[coverage-deps]deps} setuptools allowlist_externals = {[testenv:coverage]allowlist_externals} commands = {[testenv:coverage]commands} [testenv:bandit-trixie] basepython = {[trixie]basepython} usedevelop = False description = Run security analysis with bandit (Trixie) setenv = {[trixie]setenv} install_command = {[trixie]install_command} deps = {[testenv]deps} bandit allowlist_externals = {[testenv:security]allowlist_externals} commands = {[testenv:security]commands} [testenv:linters-trixie] basepython = {[trixie]basepython} description = Run linters (Trixie) setenv = {[trixie]setenv} install_command = {[trixie]install_command} allowlist_externals = {[testenv:linters]allowlist_externals} commands = {[testenv:linters]commands} [testenv:pep8-trixie] basepython = {[trixie]basepython} usedevelop = False skip_install = True description = Run style checks (Trixie) deps = -r{toxinidir}/test-requirements.txt flake8-bugbear<23.2.13 install_command = {[trixie]install_command} # H906: LOG.warn used in application source (deprecated alias, not our code to fix) commands = flake8 --extend-ignore=H906 [testenv:coverage-c-trixie] basepython = {[trixie]basepython} description = Run C/C++ coverage analysis (Trixie) allowlist_externals = {[testenv:coverage-c]allowlist_externals} commands = {[testenv:coverage-c]commands}