[tox]
minversion = 4.0
envlist = py38, py39, py310, py311, py312, lint
skipsdist = True

[testenv]
install_command = pip install -c{toxinidir}/constraints.txt -U {opts} {packages}
setenv =
  VIRTUAL_ENV={envdir}
  LANGUAGE=en_US
  LC_ALL=en_US.utf-8
  SETUPTOOLS_ENABLE_FEATURES=legacy-editable
passenv=
  GITHUB_REF_NAME
  GITHUB_BASE_REF
whitelist_externals = sh
deps =
  -r requirements-dev.txt
  build
commands =
    python -I -m build --wheel -C=--build-option=-- -C=--build-option=-- -C=--build-option=-j4
    pip install --find-links={toxinidir}/dist qiskit_aer
    stestr run {posargs}

[testenv:coverage]
basepython = python3
setenv =
  {[testenv]setenv}
  PYTHON=coverage3 run --source qiskit_aer --parallel-mode
commands =
  stestr run {posargs}
  coverage3 combine
  coverage3 report

[testenv:lint]
envdir = .tox/lint
basepython = python3
allowlist_externals = sh
commands =
  sh tools/clang-format.sh --Werror -n
  black --check {posargs} qiskit_aer test tools setup.py
  pylint -j 2 -rn qiskit_aer

[testenv:clang-format]
allowlist_externals = sh
envdir = .tox/lint
commands = sh tools/clang-format.sh -i

[testenv:black]
envdir = .tox/lint
commands = black qiskit_aer test tools setup.py

[testenv:docs]
deps =
  -r requirements-dev.txt
  build
commands =
  python -I -m build --wheel -C=--build-option=-j4
  pip install --find-links={toxinidir}/dist qiskit_aer
  sphinx-build -W -b html docs/ docs/_build/html -j auto {posargs}

[testenv:docs-clean]
skip_install = true
deps =
allowlist_externals = rm
commands = rm -rf {toxinidir}/docs/stubs/ {toxinidir}/docs/_build
