[tox]

envlist = pep8,pylint,py36,py27,docs
minversion = 2.3.2


# --- unit test environments -------------------------------------------------

[base]

deps =
    -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt}
    -r{toxinidir}/requirements.txt
passenv =
setenv =
    VIRTUAL_ENV={envdir}
    PYTHONWARNINGS=ignore::Warning,{env:PYTHONWARNINGS:}
    OS_LOG_CAPTURE={env:OS_LOG_CAPTURE:true}
    OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true}
    OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:true}
    PYTHON=python
commands =
    stestr run {posargs}


[testenv]

usedevelop = True
deps =
    {[base]deps}
    -r{toxinidir}/test-requirements.txt
passenv = {[base]passenv}
setenv =
    {[base]setenv}
    OS_TEST_PATH={toxinidir}/tobiko/tests/unit
commands = {[base]commands}


[testenv:cover]

setenv =
    {[testenv]setenv}
    PYTHON=coverage run --parallel-mode
commands =
    find . -type f -name ".coverage.*" -delete
    coverage erase
    stestr run --no-subunit-trace {posargs}
    coverage combine
    coverage html -d cover
    coverage xml -o cover/coverage.xml
    coverage report --fail-under=55 --skip-covered
    find . -type f -name ".coverage.*" -delete
whitelist_externals =
    find


# --- static analisys environments -------------------------------------------

[testenv:pep8]

commands = flake8
deps =
    {[testenv]deps}
    -r{toxinidir}/pep8-requirements.txt


[testenv:pylint]

envdir = {toxworkdir}/pep8
deps = {[testenv:pep8]deps}
commands = pylint -j0 -E --rcfile=.pylintrc -e W,E tobiko


[flake8]
# E125 continuation line does not distinguish itself from next logical line
# E126 continuation line over-indented for hanging indent
# E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line
# E265 block comment should start with '# '
# H404 multi line docstring should start with a summary
# H405 multi line docstring summary not separated with an empty line
# N530 direct neutron imports not allowed
ignore = E125,E126,E128,E129,E265,H404,H405,N530

# H106: Don't put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
# H904: Delay string interpolations at logging calls
enable-extensions = H106,H203,H904
show-source = true
exclude = ./.*,build,dist,doc,*egg*,releasenotes
import-order-style = pep8


# --- integration test environments ------------------------------------------

[openstack]

deps = {[base]deps}
passenv = {[base]passenv}
    *_proxy
    OS_*
setenv = {[base]setenv}
commands = {[base]commands}


[testenv:functional]

deps = {[openstack]deps}
passenv = {[openstack]passenv}
setenv = {[openstack]setenv}
    OS_TEST_PATH={toxinidir}/tobiko/tests/functional


[testenv:scenario]

deps = {[openstack]deps}
passenv = {[openstack]passenv}
setenv = {[openstack]setenv}
    OS_TEST_PATH={toxinidir}/tobiko/tests/scenario


[testenv:neutron]

envdir = {toxworkdir}/scenario
deps = {[testenv:scenario]deps}
passenv = {[testenv:scenario]passenv}
setenv = {[testenv:scenario]setenv}
    OS_TEST_PATH={toxinidir}/tobiko/tests/scenario/neutron


[testenv:venv]

envdir = {toxworkdir}/scenario
deps = {[testenv:scenario]deps}
passenv = {[testenv:scenario]passenv}
setenv = {[testenv:scenario]setenv}
whitelist_externals = *
commands = {posargs}


# --- documentation environments ----------------------------------------------

[testenv:docs]

basepython = python3
envdir = {toxworkdir}/docs
deps = -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b html doc/source doc/build/html


[testenv:linkcheck]

basepython = python3
envdir = {toxworkdir}/docs
deps = {[testenv:docs]deps}
commands = sphinx-build -W -b linkcheck doc/source doc/build/linkcheck


[testenv:releasenotes]

basepython = python3
envdir = {toxworkdir}/docs
deps = {[testenv:docs]deps}
commands =
    sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html


# --- CI report environments --------------------------------------------------

[testenv:report]
deps = -r {toxinidir}/report/requirements.txt
commands = {toxinidir}/report/build.sh