[tox]
minversion = 2.0
skipsdist = True
envlist = py36,py27,pep8,pypy

[testenv]
usedevelop=True
whitelist_externals = find
                      rm
install_command = pip install {opts} {packages}
deps = -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
       -r{toxinidir}/requirements.txt
       -r{toxinidir}/test-requirements.txt
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
          OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE OS_TEST_TIMEOUT
          PYTHON OS_TEST_PATH LISTOPT IDOPTION
commands =
  find . -type f -name "*.py[c|o]" -delete -o -type l -name "*.py[c|o]" -delete
  find . -type d -name "__pycache__" -delete
  stestr run --slowest {posargs}

[testenv:debug]
basepython = python3
commands = oslo_debug_helper -t tests {posargs}

[testenv:cover]
basepython = python3
setenv = VIRTUAL_ENV={envdir}
         NOSE_WITH_COVERAGE=1
         NOSE_COVER_BRANCHES=1
         NOSE_COVER_HTML=1
         NOSE_COVER_HTML_DIR={toxinidir}/cover
         PYTHON=coverage run --source kolla_ansible,ansible/action_plugins,ansible/library --parallel-mode
commands =
    stestr run {posargs}
    coverage combine
    coverage html -d cover
    coverage xml -o cover/coverage.xml

[testenv:pep8]
basepython = python3
# sphinx needs to be installed to make doc8 work properly
deps =
    {[testenv]deps}
    -r{toxinidir}/doc/requirements.txt
    yamllint
commands =
  {toxinidir}/tools/run-bashate.sh
  flake8 {posargs}
  doc8 doc/source
  python {toxinidir}/tools/validate-all-file.py
  bandit --skip B303 -r ansible kolla_ansible tests tools
  yamllint -s .

[testenv:bandit]
# B303: Use of insecure MD2, MD4, MD5, or SHA1 hash function.
basepython = python3
commands = bandit --skip B303 -r ansible kolla_ansible tests tools

[testenv:venv]
basepython = python3
deps =
  -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
  -r{toxinidir}/test-requirements.txt
  -r{toxinidir}/doc/requirements.txt
commands = {posargs}

[testenv:docs]
basepython = python3
deps =
   -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
   -r{toxinidir}/requirements.txt
   -r{toxinidir}/doc/requirements.txt
commands =
  rm -rf doc/build
  sphinx-build -W -b html doc/source doc/build/html

[testenv:deploy-guide]
basepython = python3
deps =
   -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
   -r{toxinidir}/requirements.txt
   -r{toxinidir}/doc/requirements.txt

commands =
  rm -rf deploy-guide/build
  sphinx-build -a -E -W -d deploy-guide/build/doctrees -b html deploy-guide/source deploy-guide/build/html

[testenv:setupenv]
basepython = python3
commands =
  {toxinidir}/tools/setup_gate.sh
  {toxinidir}/tools/dump_info.sh

[testenv:releasenotes]
basepython = python3
deps =
   -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
   -r{toxinidir}/requirements.txt
   -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

[flake8]
show-source = True
exclude=.eggs,.git,.tox,doc

[testenv:lower-constraints]
basepython = python3
deps =
  -c{toxinidir}/lower-constraints.txt
  -r{toxinidir}/test-requirements.txt
  -r{toxinidir}/requirements.txt