-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtox.ini
174 lines (114 loc) · 3.46 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
[tox]
envlist =
lint, mypy
test-py314
coverage-py313
coverage_report
packaging
skip_missing_interpreters = {tty:True:False}
[default]
basepython = python3.13
setenv =
PY_MODULE=ims
PYTHONPYCACHEPREFIX={envtmpdir}/pycache
##
# Default environment: unit tests
##
[testenv]
description = run tests
basepython =
py: python
py313: python3.13
py314: python3.14
runner = uv-venv-lock-runner
uv_sync_flags = --group=unit
passenv =
{test,coverage}: IMS_TEST_*
setenv =
{[default]setenv}
coverage: COVERAGE_FILE={toxworkdir}/coverage.{envname}
coverage: COVERAGE_PROCESS_START={toxinidir}/.coveragerc
TRIAL_JOBS={env:TRIAL_JOBS:--jobs=2}
HYPOTHESIS_STORAGE_DIRECTORY={toxworkdir}/hypothesis
commands =
# Run trial without coverage
test: trial --random=0 {env:TRIAL_JOBS} --logfile="{envlogdir}/trial.log" --temp-directory="{envlogdir}/trial.d" {posargs:{env:PY_MODULE}}
# Run trial with coverage
# Notes:
# - Because we run tests in parallel, which uses multiple subprocesses,
# we need to drop in a .pth file that causes coverage to start when
# Python starts. See:
# https://coverage.readthedocs.io/en/coverage-5.5/subprocess.html
# - We use coverage in parallel mode, then combine here to get the results
# to get a unified result for the current test environment.
# - Use `tox -e coverage_report` to generate a report for all environments.
coverage: python -c 'f=open("{envsitepackagesdir}/zz_coverage.pth", "w"); f.write("import coverage; coverage.process_startup()\n")'
coverage: coverage erase
coverage: coverage run --parallel-mode --source="{env:PY_MODULE}" "{envdir}/bin/trial" --random=0 {env:TRIAL_JOBS} --logfile="{envlogdir}/trial.log" --temp-directory="{envlogdir}/trial.d" {posargs:{env:PY_MODULE}}
coverage: coverage combine
coverage: coverage xml -o {toxworkdir}/coverage.xml
# Run coverage reports, ignore exit status
coverage: - coverage report --skip-covered
##
# Lint
##
[testenv:lint]
description = run all linters
basepython = {[default]basepython}
runner = uv-venv-runner
deps = pre-commit==4.0.0
usedevelop = true
skip_install = True
commands =
pre-commit run {posargs:--all-files}
passenv = SKIP
##
# Mypy static type checking
##
[testenv:mypy]
description = run Mypy (static type checker)
basepython = {[default]basepython}
runner = uv-venv-lock-runner
uv_sync_flags = --group=mypy
usedevelop = true
deps =
-r requirements/requirements-mypy.txt
{[default]deps}
commands =
mypy \
--cache-dir="{toxworkdir}/mypy_cache" \
{tty:--pretty:} \
{posargs:src}
##
# Coverage report
##
[testenv:coverage_report]
description = generate coverage report
depends = coverage-py{313,314}
basepython = {[default]basepython}
runner = uv-venv-lock-runner
uv_sync_flags = --group=unit
usedevelop = true
setenv =
{[default]setenv}
COVERAGE_FILE={toxworkdir}/coverage
commands =
coverage combine
- coverage report
- coverage html
##
# Packaging
##
[testenv:packaging]
description = check for potential packaging problems
depends = {test,coverage}-py{313,314}
basepython = {[default]basepython}
runner = uv-venv-runner
skip_install = True
deps =
pip
packaging==24.1
twine==5.1.1
commands =
pip wheel --wheel-dir "{envtmpdir}/dist" --no-deps {toxinidir}
twine check "{envtmpdir}/dist/"*