[tox]
envlist = check, tests
dependencies = -e .[journald,pacman,s3,web]
project_name = ahriman

[mypy]
flags = --implicit-reexport --strict --allow-untyped-decorators --allow-subclassing-any

[pytest]
addopts = --cov=ahriman --cov-report=term-missing:skip-covered --no-cov-on-fail --cov-fail-under=100 --spec
asyncio_mode = auto
spec_test_format = {result} {docstring_summary}

[testenv]
deps =
	{[tox]dependencies}

[testenv:check]
deps =
	{[tox]dependencies}
	-e .[check]
allowlist_externals =
	/bin/bash
setenv =
	MYPYPATH=src
commands =
	autopep8 --exit-code --max-line-length 120 -aa -i -j 0 -r "src/{[tox]project_name}" "tests/{[tox]project_name}"
	pylint --rcfile=.pylintrc "src/{[tox]project_name}"
	bandit -c .bandit.yml -r "src/{[tox]project_name}"
	bandit -c .bandit-test.yml -r "tests/{[tox]project_name}"
	/bin/bash -c 'mypy {[mypy]flags} -p "{[tox]project_name}" --install-types --non-interactive || mypy {[mypy]flags} -p "{[tox]project_name}"'

[testenv:docs]
deps =
	{[tox]dependencies}
	-e .[docs]
changedir = src
allowlist_externals =
	/bin/bash
setenv =
	SPHINX_APIDOC_OPTIONS=members,no-undoc-members,show-inheritance
commands =
	/bin/bash -c 'shtab --shell bash --prefix ahriman --prog ahriman ahriman.application.ahriman._parser > ../package/share/bash-completion/completions/_ahriman'
	/bin/bash -c 'shtab --shell zsh --prefix ahriman --prog ahriman ahriman.application.ahriman._parser > ../package/share/zsh/site-functions/_ahriman'
	argparse-manpage --module ahriman.application.ahriman --function _parser --author "ahriman team" --project-name ahriman --author-email "" --url https://github.com/arcan1s/ahriman --output ../package/share/man/man1/ahriman.1
	pydeps ahriman -o ../docs/ahriman-architecture.svg --no-config --no-show --cluster
	sphinx-apidoc -o ../docs .

[testenv:docs-html]
deps =
	{[tox]dependencies}
	-e .[docs]
commands =
	sphinx-build -b html -a -j auto -W docs docs/html

[testenv:tests]
deps =
	{[tox]dependencies}
	-e .[tests]
commands =
	pytest {posargs}
