[tox]
minversion = 2.0
envlist = linters
skipdist = True

[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
whitelist_externals = bash

[testenv:bindep]
basepython = python3
# Do not install any requirements. We want this to be fast and work even if
# system dependencies are missing, since it's used to tell you what system
# dependencies are missing! This also means that bindep must be installed
# separately, outside of the requirements files.
deps = bindep
commands = bindep test

[testenv:docs]
basepython = python3
commands = python setup.py build_sphinx

[testenv:bashate]
envdir = {toxworkdir}/linters
commands =
    python -m pre_commit run bashate --all-files

[testenv:pep8]
basepython = python3
envdir = {toxworkdir}/linters
commands =
    python -m pre_commit run flake8 --all-files

[testenv:ansible-lint]
envdir = {toxworkdir}/linters
commands =
    python -m pre_commit run ansible-lint -a

[testenv:releasenotes]
basepython = python3
whitelist_externals = bash
commands = bash -c ci-scripts/releasenotes_tox.sh

[testenv:linters]
basepython = python3
commands =
    # check only modified files:
    python -m pre_commit run --source HEAD^ --origin HEAD
    # in the future we may want to check entire repository:
    # python -m pre_commit run yamllint --all-files
    {[testenv:validate-jinja]commands}

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

[flake8]
# E123, E125 skipped as they are invalid PEP-8.
# E402 module level import not at top of file
# E501 line too long
# F403 'from ansible.module_utils.basic import *' used; unable to detect undefined names
# H303 No wildcard (*) import
# H301  one import per line
# F405 ... may be undefined, or defined from star imports:
show-source = True
ignore = E123,E125,E402,E501,F403,H303,H301,F405
builtins = _

[testenv:validate-jinja]
basepython=python2
commands =
  python ci-scripts/validate_jinja2.py
