[tox]
minversion = 3.1.1
envlist = py{36,37},pep8,docs,releasenotes,cover
# Automatic envs (pyXX) will only use the python version appropriate to that
# env and ignore basepython inherited from [testenv] if we set
# ignore_basepython_conflict.
ignore_basepython_conflict = True
skipsdist = True
skip_missing_interpreters = True
sitepackages=False

[testenv]
basepython = python3
usedevelop = True
install_command = pip install -r requirements.txt -U {opts} {packages} -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}

setenv =
   VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
whitelist_externals =
  sh
  rm
  make
commands =
  sh tools/pretty_tox.sh '{posargs}'
# TODO(sean-k-mooney): stop using pretty_tox and convert to stestr

[testenv:venv]
commands = {posargs}

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

[testenv:cover]
envdir = {toxworkdir}/venv
commands =
  coverage erase
  python setup.py test --coverage --coverage-package-name=networking_ovs_dpdk --testr-args='{posargs}'
  coverage report

[testenv:docs]
deps =
  -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
  -r{toxinidir}/doc/requirements.txt
commands =
  rm -rf doc/build/*
  # TODO(sean-k-mooney): add -W when warnings are fixed
  sphinx-build --keep-going -b html -d doc/build/doctrees doc/source doc/build/html

[testenv:pdf-docs]
description =
  Build PDF documentation.
envdir = {toxworkdir}/docs
deps = {[testenv:docs]deps}
commands =
  rm -rf doc/build/pdf
  # TODO(sean-k-mooney): add -W when warnings are fixed
  sphinx-build -b latex doc/source doc/build/pdf
  make -C doc/build/pdf

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

[testenv:bindep]
usedevelop = False
deps = bindep
commands =
  bindep pdf-docs

[flake8]
# H803 skipped on purpose per list discussion.
# E123, E125 skipped as they are invalid PEP-8.
# 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 ‘# ‘
# H301  one import per line
# H305 imports not grouped correctly
# H307 like imports should be grouped together
# H404 multi line docstring should start with a summary
# H405 multi line docstring summary not separated with an empty line
# H904 Wrap long lines in parentheses instead of a backslash
ignore = E123,E125,E126,E128,E129,E265,H301,H305,H307,H404,H405,H904,H803
show-source = True
builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
