#
# Tox global configuration
#
[tox]
envlist = py36-nocover,py37-nocover,py38-nocover,py39-nocover,py310-nocover,py311-nocover
skip_missing_interpreters = true

#
# Defaults for all environments
#
# Anything specified here is iherited by the sections
#
[testenv]
commands =
    # Running with coverage reporting enabled
    py{36,37,38,39,310,311}-!nocover: pytest --basetemp {envtmpdir} --cov=buildstream --cov-config .coveragerc {posargs}
    py{36,37,38,39,310,311}-!nocover: mkdir -p .coverage-reports
    py{36,37,38,39,310,311}-!nocover: mv {envtmpdir}/.coverage {toxinidir}/.coverage-reports/.coverage.{env:COVERAGE_PREFIX:}{envname}

    # Running with coverage reporting disabled
    py{36,37,38,39,310,311}-nocover: pytest --basetemp {envtmpdir} {posargs}
deps =
    py{36,37,38,39,310,311}: -rrequirements/requirements.txt
    py{36,37,38,39,310,311}: -rrequirements/dev-requirements.txt
    py{36,37,38,39,310,311}: -rrequirements/plugin-requirements.txt

    # Only require coverage and pytest-cov when using it
    !nocover: -rrequirements/cov-requirements.txt
passenv =
    BST_FORCE_BACKEND
    GI_TYPELIB_PATH
    INTEGRATION_CACHE

#
# These keys are not inherited by any other sections
#
setenv =
    py{36,37,38,39,310,311}: COVERAGE_FILE = {envtmpdir}/.coverage
whitelist_externals =
    py{36,37,38,39,310,311}:
        mv
        mkdir

#
# Coverage reporting
#
[testenv:coverage]
commands =
    - coverage combine --rcfile={toxinidir}/.coveragerc {toxinidir}/.coverage-reports/
    coverage report --rcfile={toxinidir}/.coveragerc -m
deps =
    -rrequirements/requirements.txt
    -rrequirements/dev-requirements.txt
    -rrequirements/cov-requirements.txt
setenv =
    COVERAGE_FILE = {toxinidir}/.coverage-reports/.coverage

#
# Running linters
#
[testenv:lint]
commands_pre =
    # Build C extensions to allow Pylint to analyse them
    {envpython} setup.py build_ext --inplace

commands =
    pylint {posargs: buildstream tests doc/source/conf.py setup.py}
deps =
    -rrequirements/requirements.txt
    -rrequirements/dev-requirements.txt

#
# Building documentation
#
[testenv:docs]
commands =
    make -C doc
# sphinx_rtd_theme < 0.4.2 breaks search functionality for Sphinx >= 1.8
deps =
    sphinx >= 1.8.5
    sphinx-click
    sphinx_rtd_theme >= 0.4.2
    -rrequirements/requirements.txt
    -rrequirements/plugin-requirements.txt
passenv =
    BST_FORCE_SESSION_REBUILD
    BST_SOURCE_CACHE
    HOME
    LANG
    LC_ALL
whitelist_externals =
    make
