-
Notifications
You must be signed in to change notification settings - Fork 7
/
tox.ini
243 lines (157 loc) · 4.64 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
[tox]
envlist =
lint, mypy
test-py313
coverage-py312
coverage_report
docs
packaging
skip_missing_interpreters = {tty:True:False}
[default]
basepython = python3.12
deps =
{test,coverage}: -r requirements/requirements-tests.txt
coverage: {[testenv:coverage_report]deps}
setenv =
PY_MODULE=ims
PYTHONPYCACHEPREFIX={envtmpdir}/pycache
##
# Default environment: unit tests
##
[testenv]
description = run tests
basepython =
py: python
py312: python3.12
py313: python3.13
deps = {[default]deps}
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}
usedevelop = true
skip_install = True
deps =
-r requirements/requirements-lint.txt
commands =
pre-commit run {posargs:--all-files}
##
# Mypy static type checking
##
[testenv:mypy]
description = run Mypy (static type checker)
basepython = {[default]basepython}
usedevelop = true
deps =
-r requirements/requirements-mypy.txt
{[default]deps}
commands =
mypy \
--cache-dir="{toxworkdir}/mypy_cache" \
{tty:--pretty:} \
{posargs:setup.py src}
##
# Coverage report
##
[testenv:coverage_report]
description = generate coverage report
depends = coverage-py{312,313}
basepython = {[default]basepython}
usedevelop = true
skip_install = True
deps =
-r requirements/requirements-coverage.txt
setenv =
{[default]setenv}
COVERAGE_FILE={toxworkdir}/coverage
commands =
coverage combine
- coverage report
- coverage html
##
# Documentation
##
[testenv:docs]
description = build documentation
basepython = {[default]basepython}
deps =
-r requirements/requirements-docs.txt
commands =
sphinx-build \
-b html -d "{envtmpdir}/doctrees" \
"{toxinidir}/docs" \
"{toxinidir}/htmldocs"
[testenv:docs-auto]
description = build documentation and rebuild automatically
basepython = {[default]basepython}
deps =
{[testenv:docs]deps}
commands =
sphinx-autobuild \
-b html -d "{envtmpdir}/doctrees" \
--host=localhost \
"{toxinidir}/docs" \
"{toxinidir}/htmldocs"
##
# Packaging
##
[testenv:packaging]
description = check for potential packaging problems
depends = {test,coverage}-py{312,313}
basepython = {[default]basepython}
skip_install = True
deps =
-r requirements/requirements-packaging.txt
commands =
pip wheel --wheel-dir "{envtmpdir}/dist" --no-deps {toxinidir}
twine check "{envtmpdir}/dist/"*
##
# Print dependencies
##
[testenv:dependencies]
description = print dependencies
basepython = {[default]basepython}
recreate = true
deps =
pipdeptree
commands =
python -c 'print()'
pip freeze --exclude=ranger-ims-server --exclude=pipdeptree
python -c 'print()'
pipdeptree
##
# Run the service
##
[testenv:exec]
basepython = {[default]basepython}
commands =
"{envbindir}/ims" --config="{toxinidir}/conf/imsd.conf" --log-file=- {posargs:server}