-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtox.ini
85 lines (75 loc) · 2.58 KB
/
tox.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
[tox]
envlist =
lint
{py38,py39,py310,py311}-test
combine-test-reports
isolated_build = True
[testenv:lint]
description = Run static checkers.
basepython = py38
extras = lint
passenv = CODEMETER_HOST
commands =
# Check formatting
ruff format . --check
# Lint code and docstrings
ruff check .
# Check type hinting
mypy .
[testenv:{py38,py39,py310,py311}-test]
description = Run doc tests and unit tests.
package = wheel
extras = test
setenv =
PY_IGNORE_IMPORTMISMATCH=1
COVERAGE_FILE = reports{/}.coverage.{envname}
passenv = CODEMETER_HOST
commands =
# Run tests and doctests from .py files
pytest --junitxml=reports/pytest.xml.{envname} {posargs}
[testenv:combine-test-reports]
description = Combine test and coverage data from multiple test runs.
skip_install = true
setenv =
COVERAGE_FILE = reports/.coverage
depends = {py38,py39,py310,py311}-test
deps =
junitparser
coverage[toml]
commands =
junitparser merge --glob reports/pytest.xml.* reports/pytest.xml
coverage combine --keep
coverage html
coverage xml
[testenv:docs]
description = Test and build the docs.
setenv =
DOCSDIR = {toxinidir}/docs
BUILDDIR = {toxinidir}/docs/build
extras = doc
passenv = CODEMETER_HOST
commands =
# Remove build directory
python -c 'import shutil; shutil.rmtree("{env:BUILDDIR}", ignore_errors=True);'
# Delete all files generated by sphinx-apidoc
python -c 'import glob, os; [os.remove(f) for f in glob.glob("docs/computer_stats_daemon*")];'
# Create dummy files to prevent warnings
python -c 'import pathlib; pathlib.Path("{env:DOCSDIR}").joinpath("computer_stats_daemon.rst").write_text("");'
python -c 'import pathlib; pathlib.Path("{env:DOCSDIR}").joinpath("license_compliance.rst").write_text("");'
# Run doctests (only from .rst files in docs folder, doctests in .py files are covered by pytest)
sphinx-build -b doctest -W -d "{env:BUILDDIR}/doctrees" "{env:DOCSDIR}" "{env:BUILDDIR}/doctest" {posargs}
# Autogenerate docs from code
sphinx-apidoc -f --no-toc -o docs/ src/computer_stats_daemon
# Dump OSS license information into the docs directory
python {env:DOCSDIR}/_scripts/generate_license_information.py
# Build the docs
sphinx-build -b html -d "{env:BUILDDIR}/doctrees" "{env:DOCSDIR}" "{env:BUILDDIR}/html" {posargs}
[testenv:build]
description = Build the package.
extras = build
passenv = CODEMETER_HOST
commands =
# Clean up build directories
python -c 'from shutil import rmtree; rmtree("build", True); rmtree("dist", True)'
# Build the package
python -m build .