[tox]
envlist = linters
minversion = 2.3
skipsdist = True

[testenv]
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/pike} {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
         OS_STDOUT_CAPTURE=1
         OS_STDERR_CAPTURE=1
         OS_TEST_TIMEOUT=60
deps = -r{toxinidir}/test-requirements.txt
whitelist_externals = reno

[testenv:linters]
basepython = python3
whitelist_externals = bash
commands =
  bash -c "find {toxinidir}          \
         -not \( -type d -name .?\* -prune \) \
         -type f                              \
         -not -name \*~                       \
         -not -name \*.md                     \
         -name \*.sh                          \
         -print0 | xargs -0 bashate -v -e E*  \
         -i E006,E010"

  bash -c "find {toxinidir}        \
        \( -name .tox \
           -o -path {toxinidir}/kubernetes \) -prune \
        -o -type f -name '*.yaml'       \
        -print0 | xargs -0 yamllint -f parsable \
        -c {toxinidir}/.yamllint"

  bash -c "find {toxinidir}/kubernetes/applications/*/*/*/manifests \
        -type f -name '*.yaml'       \
        -print0 | xargs -0 yamllint -f parsable \
        -c {toxinidir}/.yamllint"

[testenv:pep8]
basepython = python3
usedevelop = False
skip_install = True
deps = -r{toxinidir}/test-requirements.txt
commands =
    flake8

[testenv:venv]
basepython = python3
commands = {posargs}

[testenv:flake8]
basepython = python3
description = Dummy environment to allow flake8 to be run in subdir tox

[testenv:pylint]
basepython = python3
description = Dummy environment to allow pylint to be run in subdir tox

[testenv:puppetlint]
basepython = python3
description = Dummy environment to allow puppetlint to be run in subdir tox

[testenv:api-ref]
basepython = python3
install_command = pip install -U {opts} {packages}
deps = -r{toxinidir}/doc/requirements.txt
commands =
  rm -rf api-ref/build
  sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html
whitelist_externals = rm

[testenv:docs]
basepython = python3
install_command = pip install -U {opts} {packages}
deps = -r{toxinidir}/doc/requirements.txt
commands =
    rm -rf doc/build
    sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html
whitelist_externals = rm

[testenv:releasenotes]
basepython = python3
install_command = pip install -U {opts} {packages}
deps = -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
whitelist_externals = rm

[testenv:newnote]
basepython = python3
# Re-use the releasenotes venv
envdir = {toxworkdir}/releasenotes
deps = -r{toxinidir}/doc/requirements.txt
commands = reno new {posargs}