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.coverage]
67 description = "combine coverage files and generate diff (against DIFF_AGAINST defaulting to origin/main)"
68 skip_install = true
69 dependency_groups = [ "coverage" ]
70 parallel_show_output = true
71 pass_env = [
72 { replace = "ref", of = [
73 "env_run_base",
74 "pass_env",
75 ], extend = true },
76 "DIFF_AGAINST",
77 ]
78 set_env.COVERAGE_FILE = { replace = "env", name = "COVERAGE_FILE", default = "{work_dir}{/}.coverage" }
79 # Exclusions are applied when the report is rendered, so the reporting env needs the plugin too.
80 set_env.PYTHONPATH = "{tox_root}{/}tasks"
81 commands = [
82 [ "coverage", "combine" ],
83 [ "coverage", "report", "--skip-covered", "--show-missing" ],
84 [ "coverage", "xml", "-o", "{env_tmp_dir}{/}coverage.xml" ],
85 [ "coverage", "html", "-d", "{work_dir}{/}htmlcov" ],
86 [
87 "diff-cover",
88 "--compare-branch",
89 { replace = "env", name = "DIFF_AGAINST", default = "origin/main" },
90 "{env_tmp_dir}{/}coverage.xml",
91 ],
92 ]
93 depends = [ "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t", "3.15", "3.15t" ]
94
95 [env.docs]
96 description = "build documentation"
97 dependency_groups = [ "docs" ]
98 commands = [
99 [
100 "sphinx-build",
101 "-d",
102 "{env_tmp_dir}{/}docs_tree",
103 "docs",
104 "{env:READTHEDOCS_OUTPUT:{work_dir}{/}docs_out}/html",
105 "--color",
106 "-b",
107 "html",
108 { replace = "posargs", default = [], extend = true },
109 "-W",
110 ],
111 [
112 "python",
113 "-c",
114 'print(r"documentation available under file://{work_dir}{/}docs_out{/}html{/}index.html")',
115 ],
116 ]
117
118 [env.fix]
119 description = "format the code base to adhere to our styles, and complain about what we cannot do automatically"
120 skip_install = true
121 dependency_groups = [ "fix" ]
122 pass_env = [
123 { replace = "ref", of = [
124 "env_run_base",
125 "pass_env",
126 ], extend = true },
127 "DISABLE_PRE_COMMIT_UV_PATCH",
128 "PROGRAMDATA",
129 ]
130 commands = [ [ "pre-commit", "run", "--all-files", "--show-diff-on-failure", { replace = "posargs", extend = true } ] ]
131
132 [env.pkg_meta]
133 description = "check that the long description is valid"
134 skip_install = true
135 dependency_groups = [ "pkg_meta" ]
136 commands = [
137 [
138 "uv",
139 "build",
140 "--sdist",
141 "--wheel",
142 "--out-dir",
143 "{env_tmp_dir}",
144 ".",
145 ],
146 [
147 "twine",
148 "check",
149 "{env_tmp_dir}{/}*",
150 ],
151 [
152 "check-wheel-contents",
153 "--no-config",
154 "{env_tmp_dir}",
155 ],
156 ]
157
158 [env.type]
159 description = "run type check on code base"
160 dependency_groups = [ "type" ]
161 commands = [ [ "ty", "check", "--output-format", "concise", "--error-on-warning", "." ] ]
162
163 [env.bench]
164 description = "measure the performance matrix and print it as a report (a baseline, not a gate)"
165 package = "wheel"
166 wheel_build_env = ".pkg"
167 commands = [ [ "python", "tasks{/}benchmark.py" ] ]
168
169 [env.dev]
170 description = "dev environment with all deps at {envdir}"
171 package = "editable"
172 dependency_groups = [ "dev" ]
173 commands = [ [ "uv", "pip", "list", "--format=columns" ], [ "python", "-c", 'print(r"{env_python}")' ] ]
174
175 [env.release]
176 description = "build the changelog from the news fragments for the given version, e.g. tox r -e release -- 3.30.0"
177 skip_install = true
178 dependency_groups = [ "release" ]
179 commands = [ [ "towncrier", "build", "--yes", "--version", "{posargs}" ] ]
180
181 [env."3.14"]
182 # Set COVERAGE_FILE again: overriding set_env here drops the value inherited from env_run_base, and without it
183 # coverage writes .coverage in the repo root instead of {work_dir}/.coverage.3.14, so the CI rename cannot find it.
184 set_env.COVERAGE_FILE = { replace = "env", name = "COVERAGE_FILE", default = "{work_dir}{/}.coverage.{env_name}" }
185 set_env.FILELOCK_OLD_CLIENT_PATH = "{env_tmp_dir}{/}filelock-3.20.0"
186 set_env.PYTHONPATH = "{tox_root}{/}tasks"
187 commands_pre = [
188 [
189 "uv",
190 "pip",
191 "install",
192 "--target",
193 "{env_tmp_dir}{/}filelock-3.20.0",
194 "--no-deps",
195 "--reinstall",
196 "filelock==3.20.0",
197 ],
198 ]
199
200 # 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
201 # stays out of env_list because, like PyPy, it is a CI-only check that runs unmeasured and feeds no coverage data: the
202 # 100% gate remains CPython's. Its job is to keep the capability probes the suite gates on honest on a second runtime.
203 [env."graalpy3.11"]
204 description = "run the tests with pytest under {env_name}, unmeasured"