-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
tox.ini
202 lines (182 loc) · 5.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
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
[tox]
envlist = python
minversion = 3.21.0
requires =
setuptools >= 40.9.0
pip >= 19.0.3
# tox-venv >= 0.4.0
isolated_build = true
[testenv]
package = wheel
wheel_build_env = .pkg
basepython = python3
isolated_build = true
usedevelop = false
extras =
testing
commands =
{envpython} -m \
pytest \
{tty:--color=yes} \
{posargs:--cov-report=term-missing:skip-covered}
[testenv:old-deps]
description =
Run tests with the lowest possible dependency versions as opposed to
using the latest ones
commands_pre =
# NOTE: Not using `deps = ` for this because installing the dist
# NOTE: happens later and overrides it.
# NOTE: With this step we're setting certain packages to the lowest
# NOTE: versions — either limited by the runtime deps or just known
# NOTE: to work.
# NOTE: For example, PyJWT versions below 1.4.2 cause TypeError when
# NOTE: the PEM key is passed as bytes.
# Ref: https://github.com/sanitizers/octomachinery/issues/46:
{envpython} -m pip install \
'cryptography == 2.4.2' \
'gidgethub == 4.2.0' \
'pyjwt == 1.4.2; python_version < "3.10"' \
'pyjwt == 1.7.0; python_version >= "3.10"' \
'pytest-aiohttp == 0.1.0' \
'setuptools == 35.0.2; python_version < "3.10"' \
'setuptools == 41; python_version >= "3.10"' \
'setuptools-scm == 1.15.4'
setenv =
PYTEST_ADDOPTS = -p no:warnings
[testenv:check-docs]
basepython = python3
isolated_build = true
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
usedevelop = false
## don't install octomachinery itself in this env
#skip_install = true
#usedevelop = true
extras =
docs
# testing
#deps =
# pip >= 18
changedir = docs
commands =
{envpython} -m sphinx \
-b linkcheck \
-j auto \
{tty:--color} \
-n \
-d {toxinidir}/build/.doctrees \
. \
{toxinidir}/build/html
[testenv:build-docs]
basepython = python3
isolated_build = true
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
usedevelop = false
## don't install octomachinery itself in this env
#skip_install = true
#usedevelop = true
extras =
docs
# testing
#deps =
# pip >= 18
changedir = docs
commands =
# FIXME: Add -W option below once all other warnings are gone
{envpython} -m sphinx \
-j auto \
-b html \
{tty:--color} \
-n \
-d "{toxinidir}/build/.doctrees" \
. \
"{toxinidir}/build/html"
# Print out the output docs dir and a way to serve html:
-{envpython} -c \
'import pathlib; docs_dir = pathlib.Path(r"{toxinidir}") / "build" / "html"; index_file = docs_dir / "index.html"; '\
'print("\n" + "=" * 120 + f"\n\nDocumentation available under `file://\{index_file\}`\n\nTo serve docs, use `python3 -m http.server --directory \{docs_dir\} 0`\n\n" + "=" * 120)'
[testenv:build-dists]
description =
Build dists and put them into the dist{/} folder
basepython = python3
isolated_build = true
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
usedevelop = false
# don't install octomachinery itself in this env
skip_install = true
deps =
build >= 0.3.1, < 0.4.0
commands =
{envpython} -c \
"import shutil; \
shutil.rmtree('{toxinidir}{/}dist{/}', ignore_errors=True)"
{envpython} -m build \
--outdir '{toxinidir}{/}dist{/}' \
{posargs:--sdist --wheel} \
'{toxinidir}'
[testenv:metadata-validation]
depends =
build-dists
deps =
twine
description =
Verify that dists under the `dist{/}`
dir have valid metadata
# Ref: https://twitter.com/di_codes/status/1044358639081975813
commands =
{envpython} -m \
twine check \
{toxinidir}{/}dist{/}*
# Install an sdist and a wheel into tmp dirs for further comparison
{envpython} -c \
"import shutil; \
shutil.rmtree('{temp_dir}{/}.installed{/}', ignore_errors=True)"
{envpython} -m \
pip install octomachinery \
--no-index \
-f "{toxinidir}{/}dist{/}" \
--no-deps \
--only-binary octomachinery \
--no-compile --no-cache-dir \
-t "{temp_dir}{/}.installed{/}from-whl{/}"
# Pre-download build deps for installing sdist
{envpython} -m \
pip download \
setuptools \
setuptools_scm \
setuptools_scm_git_archive \
wheel \
-d "{temp_dir}{/}.build-deps{/}"
{envpython} -m \
pip install octomachinery \
--no-index \
-f "{toxinidir}{/}dist{/}" \
-f "{temp_dir}{/}.build-deps{/}" \
--no-deps \
--no-binary octomachinery \
--no-compile --no-cache-dir \
-t "{temp_dir}{/}.installed{/}from-sdist{/}"
# Normalize known content difference
sh -c 'sed -i "s#^\(octomachinery-.*.dist-info/top_level.txt,sha256=\).*#\1#" \
{temp_dir}{/}.installed{/}from-*{/}octomachinery-*.dist-info{/}RECORD'
sh -c 'rm -rfv \
{temp_dir}{/}.installed{/}from-*{/}octomachinery-*.dist-info{/}top_level.txt'
# Compare wheel and sdist installs recursively as a smoke-test
diff -ur \
"{temp_dir}{/}.installed{/}from-whl" \
"{temp_dir}{/}.installed{/}from-sdist"
skip_install = true
usedevelop = false
allowlist_externals =
diff
sh
[testenv:pre-commit]
isolated_build = true
deps =
pre-commit
commands =
{envpython} -m pre_commit run --show-diff-on-failure {posargs:--all-files}
# Print out the advise of how to install pre-commit from this env into Git:
-{envpython} -c \
'cmd = "{envpython} -m pre_commit install"; scr_width = len(cmd) + 10; sep = "=" * scr_width; cmd_str = " $ " + cmd; '\
'print("\n" + sep + "\nTo install pre-commit hooks into the Git repo, run:\n\n" + cmd_str + "\n\n" + sep + "\n")'
skip_install = true