Debian Codegraph @

tox.toml

raw
1 requires = [ "tox>=4.52" ]
2 env_list = [
3 "3.15",
4 "3.14",
5 "3.13",
6 "3.12",
7 "3.11",
8 "3.10",
9 "3.14t",
10 "3.15t",
11 "coverage",
12 "docs",
13 "fix",
14 "pkg_meta",
15 "type"
16 ]
17 skip_missing_interpreters = true
18
19 [env_run_base]
20 description = "run the tests with pytest under {env_name}"
21 package = "wheel"
22 wheel_build_env = ".pkg"
23 dependency_groups = [ "test" ]
24 pass_env = [ "PYTEST_*", "SSL_CERT_FILE" ]
25 set_env.COVERAGE_FILE = { replace = "env", name = "COVERAGE_FILE", default = "{work_dir}{/}.coverage.{env_name}" }
26 # tasks holds the coverage_pragmas plugin, which coverage imports by name in this process and in the subprocesses it
27 # patches, so it has to resolve from the environment rather than from pytest's sys.path.
28 set_env.PYTHONPATH = "{tox_root}{/}tasks"
29 # No --cov-context: coverage refuses its sys.monitoring core when contexts are configured, because that core does not
30 # implement them, but pytest-cov switches contexts behind that guard. The unsupported pair silently drops lines the
31 # suite ran, and it cost BaseAsyncFileLock.__del__'s no-loop path a flaky 99.98% on the 3.14 jobs.
32 commands = [
33 [
34 "pytest",
35 "--durations",
36 "10",
37 "--junitxml",
38 "{env_tmp_dir}{/}junit.xml",
39 { replace = "posargs", default = [
40 "--no-cov-on-fail",
41 "--cov",
42 "{env_site_packages_dir}{/}filelock",
43 "--cov",
44 "{tox_root}{/}tests",
45 "--cov-config",
46 "{tox_root}{/}pyproject.toml",
47 "--cov-report",
48 "term-missing:skip-covered",
49 "--cov-report",
50 "html:{env_tmp_dir}{/}htmlcov",
51 "--cov-report",
52 "xml:{env_tmp_dir}{/}coverage.xml",
53 ], extend = true },
54 "tests",
55 ],
56 { replace = "posargs", default = [
57 [
58 "diff-cover",
59 "--compare-branch",
60 { replace = "env", name = "DIFF_AGAINST", default = "origin/main" },
61 "{env_tmp_dir}{/}coverage.xml",
62 ],
63 ], extend = true },
64 ]
65
66 [env."3.14"]
67 # Set COVERAGE_FILE again: overriding set_env here drops the value inherited from env_run_base, and without it
68 # coverage writes .coverage in the repo root instead of {work_dir}/.coverage.3.14, so the CI rename cannot find it.
69 set_env.COVERAGE_FILE = { replace = "env", name = "COVERAGE_FILE", default = "{work_dir}{/}.coverage.{env_name}" }
70 set_env.FILELOCK_OLD_CLIENT_PATH = "{env_tmp_dir}{/}filelock-3.20.0"
71 set_env.PYTHONPATH = "{tox_root}{/}tasks"
72 commands_pre = [
73 [
74 "uv",
75 "pip",
76 "install",
77 "--target",
78 "{env_tmp_dir}{/}filelock-3.20.0",
79 "--no-deps",
80 "--reinstall",
81 "filelock==3.20.0",
82 ],
83 ]
84
85 [env.coverage]
86 description = "combine coverage files and generate diff (against DIFF_AGAINST defaulting to origin/main)"
87 skip_install = true
88 dependency_groups = [ "coverage" ]
89 parallel_show_output = true
90 pass_env = [
91 { replace = "ref", of = [
92 "env_run_base",
93 "pass_env",
94 ], extend = true },
95 "DIFF_AGAINST",
96 ]
97 set_env.COVERAGE_FILE = { replace = "env", name = "COVERAGE_FILE", default = "{work_dir}{/}.coverage" }
98 # Exclusions are applied when the report is rendered, so the reporting env needs the plugin too.
99 set_env.PYTHONPATH = "{tox_root}{/}tasks"
100 commands = [
101 [ "coverage", "combine" ],
102 [ "coverage", "report", "--skip-covered", "--show-missing" ],
103 [ "coverage", "xml", "-o", "{env_tmp_dir}{/}coverage.xml" ],
104 [ "coverage", "html", "-d", "{work_dir}{/}htmlcov" ],
105 [
106 "diff-cover",
107 "--compare-branch",
108 { replace = "env", name = "DIFF_AGAINST", default = "origin/main" },
109 "{env_tmp_dir}{/}coverage.xml",
110 ],
111 ]
112 depends = [ "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t", "3.15", "3.15t" ]
113
114 [env.docs]
115 description = "build documentation"
116 dependency_groups = [ "docs" ]
117 commands = [
118 [
119 "sphinx-build",
120 "-d",
121 "{env_tmp_dir}{/}docs_tree",
122 "docs",
123 "{env:READTHEDOCS_OUTPUT:{work_dir}{/}docs_out}/html",
124 "--color",
125 "-b",
126 "html",
127 { replace = "posargs", default = [], extend = true },
128 "-W",
129 ],
130 [
131 "python",
132 "-c",
133 'print(r"documentation available under file://{work_dir}{/}docs_out{/}html{/}index.html")',
134 ],
135 ]
136
137 [env.fix]
138 description = "format the code base to adhere to our styles, and complain about what we cannot do automatically"
139 skip_install = true
140 dependency_groups = [ "fix" ]
141 pass_env = [
142 { replace = "ref", of = [
143 "env_run_base",
144 "pass_env",
145 ], extend = true },
146 "DISABLE_PRE_COMMIT_UV_PATCH",
147 "PROGRAMDATA",
148 ]
149 commands = [ [ "pre-commit", "run", "--all-files", "--show-diff-on-failure", { replace = "posargs", extend = true } ] ]
150
151 [env.pkg_meta]
152 description = "check that the long description is valid"
153 skip_install = true
154 dependency_groups = [ "pkg_meta" ]
155 commands = [
156 [
157 "uv",
158 "build",
159 "--sdist",
160 "--wheel",
161 "--out-dir",
162 "{env_tmp_dir}",
163 ".",
164 ],
165 [
166 "twine",
167 "check",
168 "{env_tmp_dir}{/}*",
169 ],
170 [
171 "check-wheel-contents",
172 "--no-config",
173 "{env_tmp_dir}",
174 ],
175 ]
176
177 [env.type]
178 description = "run type check on code base"
179 dependency_groups = [ "type" ]
180 commands = [ [ "ty", "check", "--output-format", "concise", "--error-on-warning", "." ] ]
181
182 [env.bench]
183 description = "measure the performance matrix and print it as a report (a baseline, not a gate)"
184 package = "wheel"
185 wheel_build_env = ".pkg"
186 commands = [ [ "python", "tasks{/}benchmark.py" ] ]
187
188 [env.dev]
189 description = "dev environment with all deps at {envdir}"
190 package = "editable"
191 dependency_groups = [ "dev" ]
192 commands = [ [ "uv", "pip", "list", "--format=columns" ], [ "python", "-c", 'print(r"{env_python}")' ] ]
193
194 # tox invents an env on the fly only for a py or pypy factor, so GraalPy has to be declared to be selectable at all. It
195 # stays out of env_list because, like PyPy, it is a CI-only check that runs unmeasured and feeds no coverage data: the
196 # 100% gate remains CPython's. Its job is to keep the capability probes the suite gates on honest on a second runtime.
197 [env."graalpy3.11"]
198 description = "run the tests with pytest under {env_name}, unmeasured"
199
200 [env.release]
201 description = "build the changelog from the news fragments for the given version, e.g. tox r -e release -- 3.30.0"
202 skip_install = true
203 dependency_groups = [ "release" ]
204 commands = [ [ "towncrier", "build", "--yes", "--version", "{posargs}" ] ]