[tox]
minversion = 3.1.1
envlist = py27,py37,functional,functional-py36,pep8
skipsdist = True
# Automatic envs (pyXX) will use the python version appropriate to that
# env and ignore basepython inherited from [testenv]. That's what we
# want, and we don't need to be warned about it.
ignore_basepython_conflict = True

[testenv]
basepython = python3
usedevelop = True
whitelist_externals =
  rm
install_command = pip install {opts} {packages}
setenv =
   VIRTUAL_ENV={envdir}
   PYTHONWARNINGS=ignore::DeprecationWarning:distutils,ignore::DeprecationWarning:site
   PYTHONDONTWRITEBYTECODE=1
deps =
   -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
   -r{toxinidir}/test-requirements.txt
   -r{toxinidir}/requirements.txt
commands = stestr run {posargs}

# NOTE(cdent): Do not set envdir here as it confuses tox-siblings.
# gate functional jobs, which use the 'functional' path when
# copying files.
[testenv:functional]
basepython = python2.7
deps =
  {[testenv]deps}
  git+https://opendev.org/openstack/placement.git#egg=openstack-placement
commands = stestr --test-path=./osc_placement/tests/functional run {posargs}

[testenv:functional-py36]
deps =
  {[testenv:functional]deps}
commands =
  {[testenv:functional]commands}

[testenv:functional-py37]
deps =
  {[testenv:functional]deps}
commands =
  {[testenv:functional]commands}

[testenv:pep8]
envdir = {toxworkdir}/shared
commands = flake8 {posargs}

[testenv:venv]
commands = {posargs}
# The docs requirements are included here for creating release notes, e.g.:
#   tox -e venv -- reno new <slug>
deps =
  {[testenv]deps}
  -r{toxinidir}/doc/requirements.txt

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

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

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

[testenv:releasenotes]
deps = {[testenv:docs]deps}
commands =
  rm -rf releasenotes/build
  sphinx-build -W -b html -d releasenotes/build/doctrees releasenotes/source releasenotes/build/html

[testenv:debug]
commands = oslo_debug_helper {posargs}

[flake8]
# E123, E125 skipped as they are invalid PEP-8.

show-source = True
ignore = E123,E125
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
