[tox]
isolated_build = True
envlist =
    clean,
    check,
    docs,
    py38,py39,py310,py311,py312
    report

[testenv]
basepython =
    py38: {env:TOXPYTHON:python3.8}
    py39: {env:TOXPYTHON:python3.9}
    py310: {env:TOXPYTHON:python3.10}
    py311: {env:TOXPYTHON:python3.11}
    py312: {env:TOXPYTHON:python3.12}
    {clean,check,docs,report}: {env:TOXPYTHON:python3}
setenv =
    PYTHONPATH={toxinidir}/tests
    PYTHONUNBUFFERED=yes
passenv =
    *
usedevelop = false
deps =
    pytest~=7.4.0
    pytest-cov~=4.1.0
    PyYAML~=6.0.1
commands =
    {posargs:pytest --cov --cov-report=term-missing -vv tests}


[testenv:check]
deps =
    {[testenv]deps}
    black~=22.3.0
    flake8~=4.0.1
    mypy~=0.730
    types-PyYAML
commands =
    black --check src tests
    flake8 src tests
    mypy src/importlinter tests
    lint-imports

[testenv:docs]
deps =
    -r{toxinidir}/docs/requirements.txt
commands =
    sphinx-build {posargs:-E} -b html docs dist/docs
    sphinx-build -b linkcheck docs dist/docs

[testenv:report]
deps = coverage~=6.3.1
skip_install = true
commands =
    coverage report
    coverage html

[testenv:clean]
commands = coverage erase
skip_install = true
deps = coverage

[gh-actions]
# Run check on both Python 3.10 and 3.11, because of our version-dependent dependency on tomli.
python =
    3.8: py38, report
    3.9: py39, report
    3.10: py310, report, check
    3.11: py311, report, check, docs
    3.12: py312, report