[tox]
minversion = 4.28.0
envlist = py3,pypy,pep8

[testenv]
usedevelop = True
constraints =
  {env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
deps =
  -r{toxinidir}/requirements.txt
  -r{toxinidir}/test-requirements.txt
commands =
  find . -type f -name "*.pyc" -delete
  stestr run {posargs}
allowlist_externals =
  find
passenv =
  ETCD_VERSION

[testenv:pep8]
skip_install = true
deps =
  pre-commit
  {[testenv:mypy]deps}
commands =
  pre-commit run --all-files --show-diff-on-failure
  {[testenv:mypy]commands}

[testenv:mypy]
description =
  Run type checks.
deps =
  {[testenv]deps}
  mypy
commands =
  mypy --cache-dir="{envdir}/mypy_cache" -p etcd3gw {posargs}

[testenv:venv]
commands = {posargs}

[testenv:cover]
deps = {[testenv]deps}
setenv =
  PYTHON=coverage run --source etcd3gw --parallel-mode
allowlist_externals =
  {toxinidir}/setup-etcd-env.sh
commands =
  coverage erase
  {toxinidir}/setup-etcd-env.sh pifpaf -e TOOZ_TEST run etcd -- stestr run {posargs}
  coverage combine
  coverage html -d cover
  coverage xml -o cover/coverage.xml
  coverage report --show-missing

[testenv:examples]
allowlist_externals =
  {toxinidir}/setup-etcd-env.sh
commands =
  {toxinidir}/setup-etcd-env.sh pifpaf -e TOOZ_TEST run etcd -- python {toxinidir}/etcd3gw/examples/etcd.py

[testenv:docs]
deps =
  -r{toxinidir}/doc/requirements.txt
commands =
  sphinx-build -W -b html doc/source doc/build/html

[testenv:py{3,310,311,312,313}-etcd]
allowlist_externals =
  {toxinidir}/setup-etcd-env.sh
commands =
  {toxinidir}/setup-etcd-env.sh pifpaf -e TOOZ_TEST run etcd -- stestr run {posargs}

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

[testenv:debug]
commands = oslo_debug_helper {posargs}

[flake8]
# We only enable the hacking (H) checks
select = H
show-source = True
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build

[hacking]
import_exceptions =
  collections.abc
  typing
