[tox]
skipsdist = True

[testenv]
extras = tests
deps =
	cover: pytest-cov
	linters: flake8
	linters: pep8-naming
	linters: mccabe
	linters: flake8-noqa
	linters-diff-ci: flake8-html
changedir = {toxinidir}
usedevelop = True
setenv =
	cover: CI_COVERAGE_OPTS=--cov=gnpy --cov=tests --cov-report=
commands =
	pytest {env:CI_COVERAGE_OPTS:} -vv {posargs}
	cover: coverage html -d cover
	cover: coverage xml -o cover/coverage.xml
	python -m build

[testenv:docs]
extras = docs
allowlist_externals =
	/bin/sh
commands =
	sphinx-build -E -W --keep-going -q -b html docs/ doc/build/html
	/bin/sh -c "rstcheck --ignore-roles cite *.rst"

[testenv:linters]
commands =
	flake8 {posargs}

[testenv:linters-diff-ci]
allowlist_externals = bash
commands =
	flake8 {posargs} --format html --htmldir linters --exit-zero
	bash -c "git diff -U0 origin/$(git rev-parse --abbrev-ref HEAD) | flake8 --diff {posargs}"

[flake8]
max-line-length = 120
max-complexity = 15
ignore = N806 W503
