[tox]
minversion = 2.0
envlist = py38,pep8,docs
skipsdist = True

[testenv]
basepython = python3
usedevelop = True
install_command = pip install -U {opts} {packages}
setenv =
   VIRTUAL_ENV={envdir}
   DJANGO_SETTINGS_MODULE=searchlight_ui.tests.settings
deps =
  -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
  -r{toxinidir}/requirements.txt
  -r{toxinidir}/test-requirements.txt
commands =
  python manage.py test

[testenv:pep8]
commands = flake8

[testenv:npm]
passenv =
  HOME
  DISPLAY
commands =
  nodeenv -p
  npm install
  npm run {posargs:test}

[testenv:venv]
commands = {posargs}

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

[testenv:docs]
whitelist_externals =
  rm
deps = -r{toxinidir}/doc/requirements.txt
commands =
  rm -rf rm -rf doc/build
  sphinx-build -W --keep-going -b html -d doc/build/doctrees doc/source doc/build/html

[testenv:pdf-docs]
deps = -r{toxinidir}/doc/requirements.txt
envdir = {toxworkdir}/docs
whitelist_externals =
  make
commands =
  sphinx-build -W --keep-going -b latex doc/source doc/build/pdf
  make -C doc/build/pdf

[testenv:debug]
commands = oslo_debug_helper -t searchlight_ui/tests {posargs}

[testenv:releasenotes]
whitelist_externals =
  rm
deps = -r{toxinidir}/doc/requirements.txt
commands =
  rm -rf releasenotes/build
  sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html

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

[flake8]
# E123, E125 skipped as they are invalid PEP-8.
show-source = True
ignore = E123,E125
builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,releasenotes
