[tox]
minversion = 2.0
skipsdist = True
envlist = py{37}{,-mongodb,-mysql,-postgresql,-elasticsearch},pep8
ignore_basepython_conflict = True

[testenv]
basepython = python3
deps = -r{toxinidir}/requirements.txt
       -r{toxinidir}/test-requirements.txt
install_command = pip install -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/ussuri} {opts} {packages}
usedevelop = True
setenv =
    PANKO_BACKENDS=mongodb mysql postgresql
    mongodb: PANKO_BACKENDS=mongodb
    mysql: PANKO_BACKENDS=mysql
    postgresql: PANKO_BACKENDS=postgresql
    elasticsearch: PANKO_BACKENDS=elasticsearch
# NOTE(tonyb): This project has chosen to *NOT* consume upper-constraints.txt
passenv = OS_TEST_TIMEOUT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE
whitelist_externals = bash
commands =
   oslo-config-generator --config-file=etc/panko/panko-config-generator.conf
   bash run-tests.sh {posargs}

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

[testenv:pep8]
deps = hacking<3.1.0,>=3.0.0
       doc8
commands = flake8
           doc8 {posargs}

[testenv:releasenotes]
commands = sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html

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

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

[testenv:docs]
deps = -r{toxinidir}/requirements.txt
       -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b html doc/source doc/build/html

[testenv:pdf-docs]
deps = {[testenv:docs]deps}
whitelist_externals =
  rm
  make
commands =
  rm -rf doc/build/pdf
  sphinx-build -W -b latex doc/source doc/build/pdf
  make -C doc/build/pdf

[testenv:venv]
commands = {posargs}
setenv = PYTHONHASHSEED=0

[doc8]
ignore = D000
ignore-path = .venv,.git,.tox,*panko/locale*,*lib/python*,panko.egg*,doc/build,doc/source/api,releasenotes/*

[flake8]
# W503 line break before binary operator
# W504 line break after binary operator
ignore = W503,W504
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
show-source = True

[hacking]
import_exceptions =
    panko.i18n

[flake8:local-plugins]
extension =
    C301 = checks:no_log_warn
    C302 = checks:no_os_popen
paths = ./panko/hacking
