Files
ahriman/tox.ini

120 lines
3.7 KiB
INI

[tox]
envlist = check, tests
isolated_build = true
labels =
release = version, docs, publish
dependencies = -e .[journald,pacman,reports,s3,shell,stats,unixsocket,validator,web,web_api-docs,web_auth,web_oauth2,web_metrics]
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_default_fixture_loop_scope = function
asyncio_mode = auto
spec_test_format = {result} {docstring_summary}
[testenv:archive]
description = Create source files tarball
deps =
build
commands =
python -m build --sdist
[testenv:check]
description = Run common checks like linter, mypy, etc
dependency_groups =
check
deps =
{[tox]dependencies}
pip_pre = true
setenv =
CFLAGS="-Wno-unterminated-string-initialization"
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=.pylint.toml "src/{[tox]project_name}"
bandit -c .bandit.yml -r "src/{[tox]project_name}"
bandit -c .bandit-test.yml -r "tests/{[tox]project_name}"
mypy {[mypy]flags} -p "{[tox]project_name}" --install-types --non-interactive
[testenv:docs]
description = Generate source files for documentation
allowlist_externals =
bash
find
mv
changedir = src
dependency_groups =
docs
depends =
version
deps =
{[tox]dependencies}
uv
pip_pre = true
setenv =
SPHINX_APIDOC_OPTIONS=members,no-undoc-members,show-inheritance
commands =
bash -c 'shtab --shell bash --prefix ahriman --prog ahriman ahriman.application.ahriman._parser > ../package/share/bash-completion/completions/_ahriman'
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 --no-output --show-dot --dot-output architecture.dot --no-config --cluster
mv architecture.dot ../docs/_static/architecture.dot
# remove autogenerated modules rst files
find ../docs -type f -name "{[tox]project_name}*.rst" -delete
sphinx-apidoc -o ../docs .
# compile list of dependencies for rtd.io
uv pip compile --group ../pyproject.toml:docs --extra s3 --extra validator --extra web --output-file ../docs/requirements.txt --quiet ../pyproject.toml
[testenv:html]
description = Generate html documentation
dependency_groups =
docs
deps =
{[tox]dependencies}
pip_pre = true
recreate = true
commands =
sphinx-build -b html -a -j auto -W docs {envtmpdir}{/}html
[testenv:publish]
description = Create and publish release to GitHub
allowlist_externals =
git
depends =
docs
passenv =
SSH_AUTH_SOCK
commands =
git add package/archlinux/PKGBUILD src/ahriman/__init__.py docs/_static/architecture.dot package/share/man/man1/ahriman.1 package/share/bash-completion/completions/_ahriman package/share/zsh/site-functions/_ahriman
git commit -m "Release {posargs}"
git tag "{posargs}"
git push
git push --tags
[testenv:tests]
description = Run tests
dependency_groups =
tests
deps =
{[tox]dependencies}
pip_pre = true
setenv =
CFLAGS="-Wno-unterminated-string-initialization"
commands =
pytest {posargs}
[testenv:version]
description = Bump package version
allowlist_externals =
sed
deps =
packaging
commands =
# check if version is set and validate it
{envpython} -c 'from packaging.version import Version; Version("{posargs}")'
sed -i 's/^__version__ = .*/__version__ = "{posargs}"/' src/ahriman/__init__.py
sed -i "s/pkgver=.*/pkgver={posargs}/" package/archlinux/PKGBUILD