[tox]
minversion = 3.18.0
envlist = py3,pep8
ignore_basepython_conflict = True

[testenv]
basepython = python3
usedevelop = True
allowlist_externals = find
setenv =
   VIRTUAL_ENV={envdir}
deps =
   -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2024.2}
   -r{toxinidir}/test-requirements.txt
   -r{toxinidir}/requirements.txt
commands =
    stestr run --serial {posargs}
    stestr slowest
    oslo-config-generator --config-file=etc/vitrage/vitrage-config-generator.conf
    find . -type f -name "test-*.db" -delete
passenv =
    http_proxy
    HTTP_PROXY
    https_proxy
    HTTPS_PROXY
    no_proxy
    NO_PROXY

[testenv:pep8]
commands = flake8

[testenv:genconfig]
commands = oslo-config-generator --config-file=etc/vitrage/vitrage-config-generator.conf

[testenv:genpolicy]
commands = oslopolicy-sample-generator --config-file=etc/vitrage/vitrage-policy-generator.conf

[testenv:venv]
commands = {posargs}

[testenv:cover]
setenv =
    PYTHON=coverage run --source $project --parallel-mode
commands =
    stestr run {posargs}
    coverage combine
    coverage html -d cover
    coverage xml -o cover/coverage.xml
    coverage report

[testenv:docs]
deps =
    -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2024.2}
    -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b html doc/source doc/build/html

[testenv:debug]
commands = oslo_debug_helper {posargs}

[flake8]
# E123, E125 skipped as they are invalid PEP-8.
# H106: Don't put vim configuration in source files
# H203: Use assertIs(Not)None to check for None

show-source = True
ignore = E123,E125,E402,W503,W504,E731
enable-extensions=H104,H106,H203
builtins = _
filename = *.py,app.wsgi
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools/datasource-scaffold

[hacking]
import_exceptions = vitrage.i18n

[flake8:local-plugins]
extension =
    V316 = checks:assert_true_instance
    V329 = checks:check_assert_true_false
    V317 = checks:assert_equal_type
    V319 = checks:no_translate_logs
    V327 = checks:no_mutable_default_args
    V321 = checks:check_no_contextlib_nested
    V322 = checks:dict_constructor_with_list_copy
    V323 = checks:check_python3_xrange
    V324 = checks:check_python3_no_iteritems
    V325 = checks:check_python3_no_iterkeys
    V326 = checks:check_python3_no_itervalues
    V328 = checks:no_log_warn
paths = ./vitrage/hacking

[testenv:releasenotes]
deps =
  -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2024.2}
  -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html

