Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
296 lines (286 loc) · 16.9 KB
/
Copy pathpyproject.toml
File metadata and controls
296 lines (286 loc) · 16.9 KB
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# This manifest is the pixi workspace and the tool configuration, and nothing else.
# It is not a Python package: it declares no `[project]`, no dependencies and no
# build backend, because since #267 there is no Python to build. What used to be
# here -- hatchling, an editable self-install of `devlaunch`, and a `[project]`
# table whose version was read out of `rust/Cargo.toml` -- served a Python `dl`
# that no longer exists.
#
# What ships is a linux-64 wheel of the two compiled binaries (`dl`, `dla`),
# built by maturin from `packaging/wheel/pyproject.toml`, and a conda package of
# the same binaries from `conda.recipe/recipe.yaml`. Both read their version from
# `rust/Cargo.toml`, which is the one place it lives; a release is one edit.
# Neither is built from here, and the `rust` feature below is not what builds them
# either: it is for building the crates under `rust/` from inside a container.
#
# The Python in this environment is the acceptance harness (`test/`, which judges
# the binaries from outside through the `DEVLAUNCH_DL_CMD` seam), the repo's own
# doc guards, and the tooling under `scripts/`. None of it is imported by anything
# that ships, and none of it is installed -- the suite runs from the checkout.
[tool.pixi.workspace]
# `name` here rather than in a `[project]` table: pixi takes it from either, and a
# `[project]` would be a claim that this directory builds a Python distribution.
name = "devlaunch"
channels = ["conda-forge", "https://prefix.dev/blooop"]
# linux-aarch64 is here for the *development* environment, and claims nothing
# about the release: what ships is still a linux-64 wheel and a linux-64 conda
# package, as the header above says.
#
# It is required rather than nice to have, because a pixi workspace refuses
# outright on a platform it does not declare. Measured on a throwaway workspace
# declaring one platform this machine cannot run: `pixi install` exits
# `unsupported-platform`, "The workspace does not support '<platform>' on this
# machine", and installs nothing. That is two arm64 paths that cannot work
# without the line below: the arm64 leg of
# `.github/workflows/devcontainer-prebuild.yml`, which fails at `setup-pixi`
# before it can build an image, and this repository's own devcontainer on an
# Apple Silicon host, whose `postCreateCommand` is a bare `pixi install` and so
# fails at container create -- which would make an arm64 prebuild an image that
# pulls fast and then cannot come up.
#
# What it costs is +825 lines of pixi.lock and no linux-64 pin: the two solves
# are independent, and every dependency resolves to a real aarch64 build --
# devpod 0.26.1 is in the blooop channel for linux-aarch64, which is the one
# that matters here, since the prebuild tag is only usable if the devpod that
# publishes it is the devpod that later looks for it.
platforms = ["linux-64", "linux-aarch64"]
[tool.pixi.dependencies]
# `>=3.11` for stdlib `tomllib`, and 3.11 rather than 3.10 because the floor is
# now the harness's and not a released package's: a Python `dl` supporting >=3.10
# is what put the old one there, and `tomli` is what it cost.
python = ">=3.11"
shellcheck = ">=0.10.0,<0.11"
# Match the devpod `dl` is actually installed alongside (pixi global ships
# 0.26.x). The pin used to be <0.9, which quietly meant the suite exercised a
# devpod five years of releases behind the one users run -- and it hid this
# module's bug outright: 0.8 requests a pty for `devpod ssh --command` whenever
# stdout is a terminal, and 0.26 never does. See rust/devlaunch-core/src/clients/ssh.rs.
devpod = ">=0.26.1,<0.27"
gh = ">=2.83.0,<3.0"
# Conda-side tools the suite needs, alongside the `test` feature's PyPI half in
# [project.optional-dependencies]. git-lfs is not a devlaunch runtime dependency
# -- `dl` treats it as optional and skips LFS work when it is absent -- but the
# tests that pin the cache-as-LFS-store behaviour need the real thing, and would
# otherwise *skip*, which is the failure mode that looks like a pass.
[tool.pixi.feature.test.dependencies]
git-lfs = ">=3.4,<4"
# The toolchain that builds what ships, in the environment the devcontainer
# installs -- so `pixi run cargo test` works the moment a container comes up and
# an agent working in one can compile the thing it is editing. Before this, the
# container had no cargo at all: a Rust change could be written in here and not
# built, and the only verification available was pushing it and reading CI.
#
# `rust/rust-toolchain.toml` stays the pin of record; this and `ci.yml`'s two
# `dtolnay/rust-toolchain` steps are kept in lockstep with it by hand, the same
# arrangement those two steps already had. A conda `rust` does not read
# `rust-toolchain.toml` -- that file is rustup's -- so the version has to be said
# again here rather than derived from it.
#
# A feature on `default` alone, not a plain dependency: `py310`-`py313` exist to
# run the frozen Python reference against four interpreters and have no use for
# cargo, and a plain dependency would put the toolchain in each of their solves
# and CI caches. It is not free where it does go -- the environment goes from
# 521MB to 2044MB, since conda's `rust` links with a gcc toolchain, a sysroot and
# binutils -- and README's "Disk cost of the dev container" carries the numbers
# and the reason that trade is the right one.
[tool.pixi.feature.rust.dependencies]
# `1.97.1.*`, not `1.97.*`: `rust/rust-toolchain.toml` names 1.97.1 and `ci.yml`
# installs 1.97.1, and AGENTS.md already tells a reader this environment is "pinned
# to the 1.97.1 that rust-toolchain.toml names". At `1.97.*` that stops being true
# the day 1.97.2 is published -- silently, and only inside the container, which is
# the worst place for a toolchain difference to appear. Kept in lockstep by
# `test_agents_doc.py`.
rust = "1.97.1.*"
# The coverage instrumentation for the crates above (#294). `cargo llvm-cov` drives
# rustc's `-C instrument-coverage` and then reduces the `.profraw` files it leaves
# with `llvm-profdata`/`llvm-cov`, which is why `llvm-tools` is here beside it: a
# rustup toolchain gets those from the `llvm-tools-preview` component, and this
# environment has no rustup. Their LLVM has to be the one rustc emitted for --
# `rustc -vV` reports 22.1.6 against `llvm-tools` 22.1.8, the same major, which is
# where the profile format is stable. If a `rust` bump ever crosses an LLVM major,
# this pin moves with it and `cargo llvm-cov` says so loudly ("unsupported
# instrumentation profile version") rather than miscounting.
cargo-llvm-cov = ">=0.9.0,<0.10"
llvm-tools = ">=22.1,<23"
# The suite's own PyPI half. A pixi feature rather than
# `[project.optional-dependencies]`, which needed a `[project]` table to hang off;
# nothing here is a dependency *of* anything, it is the toolbox the checkout is
# worked in.
[tool.pixi.feature.test.pypi-dependencies]
pytest-cov = ">=4.1,<=7.1.0"
pytest = ">=7.4,<=9.0.3"
ruff = ">=0.5.0,<=0.15.15"
coverage = ">=7.5.4,<=7.14.1"
prek = ">=0.2.28,<0.5.0"
ty = ">=0.0.12,<=0.0.19"
# One environment. There used to be five -- py310 through py313 beside `default`
# -- because a released `dl` was a Python package that had to work on each of
# them. It is a binary now (#267), so the interpreter is the harness's and not the
# product's, and a matrix over it tests nothing anybody ships. That also settles
# what the `rust` feature above costs: with one environment there is no longer a
# set of solves it has to be kept out of, and `default` is the only place it could
# go.
[tool.pixi.environments]
default = { features = ["test", "rust"], solve-group = "default" }
[tool.pixi.tasks]
# `pixi run dl` and `pixi run dla`: this working tree, compiled and run (#268).
#
# Tasks now, where they used to be console scripts the editable Python install put
# in the environment. Nothing resolves `dl` in here by accident any more, which is
# the point -- the shipped implementation is Rust, and these are the only two names
# in the container that name it.
#
# `cargo run` rather than a build task and a path, so there is still no build step
# to remember: it compiles what changed and runs the result. The debug profile,
# because this is the edit-run loop and a release build pays two-figure seconds for
# a startup difference nothing in here measures (`pixi run bench` and `./dev.sh`
# are where the release profile matters). `-q` so cargo's progress lines stay out
# of stdout, which callers of `--ls --json` parse.
#
# `--features .../dev-build` marks the version line `-dev`, exactly as `./dev.sh`
# does on the host: a build of somebody's tree says so wherever it runs.
dl = "cargo run -q --locked --manifest-path rust/Cargo.toml -p dl --bin dl --features dl/dev-build --"
dla = "cargo run -q --locked --manifest-path rust/Cargo.toml -p dla --bin dla --features dla/dev-build --"
dev-add-docker = "python scripts/devpod_provider.py docker"
dev = { cmd = "devpod up . --ide none && ssh pythontemplate.devpod", depends-on = ["dev-add-docker"] }
dev-vs = { cmd = "devpod up . --ide vscode", depends-on = ["dev-add-docker"] }
dev-restart = { cmd = "devpod up . --recreate --ide none && ssh pythontemplate.devpod", depends-on = ["dev-add-docker"] }
dev-restart-vs = { cmd = "devpod up . --recreate --ide vscode", depends-on = ["dev-add-docker"] }
# Build this repo's devcontainer and publish it to the prebuild repository named
# in .devcontainer/devcontainer.json (customizations.devpod.prebuildRepository),
# so that the next `dl blooop/devlaunch` pulls an image instead of building one.
#
# No `--repository`: devpod reads the destination out of devcontainer.json, which
# keeps the registry written down in exactly one place. The tag devpod publishes
# on its own is the prebuild hash -- which is per architecture, since the
# architecture is hashed with the config and the context -- and `--tag` adds a
# moving alias next to it, the one `build.cacheFrom` points at for builders that
# do not understand prebuilds (VS Code, plain `devcontainer up`).
#
# The alias is an argument, defaulting to `latest`, because two architectures now
# publish into one repository and devpod arch-qualifies nothing: an alias passed
# by both legs is a tag whose owner is whichever leg finished last. So `latest`
# is amd64's and `latest-arm64` is arm64's; see the comment on the build step in
# the workflow for why that asymmetry is the right one. Publishing by hand needs
# no argument and behaves exactly as it did.
#
# `.github/workflows/devcontainer-prebuild.yml` runs this on pushes to `main`
# that touch `.devcontainer/**`; it is a task so the same command can be run by
# hand -- after `docker login ghcr.io` -- to publish from a branch. Idempotent
# either way: an existing prebuild is found and returned, not rebuilt.
devcontainer-prebuild = { cmd = "devpod build . --tag {{ alias }}", args = [{ arg = "alias", default = "latest" }], depends-on = ["dev-add-docker"] }
# Re-record the README's demo GIFs from the tapes in docs/demo/.
#
# A task so that `pixi task list` mentions the demos exist at all; the logic is
# in the script because it needs a loop and a `command -v`, and pixi's task
# shell has neither.
#
# Easiest on a host: it films the released `dl`, which drives devpod and docker.
# `vhs`, `ttyd` and `ffmpeg` are not in this environment -- the script checks
# for them and says what is missing, container or host.
demo = "bash scripts/record_demo.sh"
prek = "prek run -a"
prek-update = "prek autoupdate"
format = "ruff format ."
check-clean-workspace = "git diff --exit-code"
ruff-lint = "ruff check . --fix"
ty = "ty check --respect-ignore-files ."
lint = { depends-on = ["ruff-lint", "ty"] }
style = { depends-on = ["format", "lint"] }
commit-format = "git commit -a -m'autoformat code' || true"
# The binaries the acceptance harness judges. A task rather than a step in CI,
# so `pixi run test` and `pixi run test-e2e` do the right thing from a fresh
# checkout too: the `DEVLAUNCH_DL_CMD` seam defaults to `rust/target/release/dl`
# and fails the test that asked when it is not there, which is the honest answer
# but a poor greeting.
#
# The release profile because that is what ships, and because a suite that judged
# a debug build would be judging something nobody runs. Point the seam at a debug
# build by hand when the compile time matters more than the fidelity:
# DEVLAUNCH_DL_CMD='cargo run -q --manifest-path rust/Cargo.toml -p dl --bin dl --' pixi run pytest
build-release = "cargo build --release --locked --manifest-path rust/Cargo.toml -p dl -p dla"
test = { cmd = "pytest", depends-on = ["build-release"] }
# Median wall time of a command over N runs; see "Measuring launch time" in docs/performance.md.
bench = "python scripts/bench_launch.py"
# The step between a bench record and the published trend: see "The trend on
# main" in docs/performance.md. The bench workflow runs it; it is a task so that the same
# command can be run by hand against records a developer benched themselves.
bench-points = "python scripts/bench_points.py"
# Needs a real Docker daemon and a real devpod. Inside this repo's devcontainer
# that daemon is the container's own, via the docker-in-docker feature; on an
# ephemeral CI runner or a machine you do not mind writing to, it is the host's.
#
# The default run excludes e2e (see addopts); this is the way back in. A
# trailing `-m e2e` beats the one in addopts, and `-ra` puts every skip's reason
# in the summary, which is the whole difference between a run that opted out of
# something and a run that could not do it.
#
# Deliberately no `depends-on = ["dev-add-docker"]`. The suite repoints
# DEVPOD_HOME at a fresh directory in pytest_configure, before collection, so a
# provider registered in the ambient ~/.devpod is one this run never reads:
# test/e2e/conftest.py installs it into the run's own home instead. An edge here
# would buy the suite nothing and write to the developer's real devpod home as a
# side effect of running tests.
test-e2e = { cmd = "pytest -m e2e -ra test/e2e/", depends-on = ["build-release"] }
coverage = { cmd = "coverage run -m pytest && coverage xml -o coverage.xml", depends-on = ["build-release"] }
coverage-report = "coverage report -m"
# The same measurement CI's `rust-coverage` job takes, in the container (#294).
#
# Deliberately runnable here rather than only on a runner: this environment carries
# the toolchain that builds what ships precisely so a change can be verified in the
# container instead of by pushing it and reading CI, and "which lines does my new
# test actually reach" is a question with a one-command answer or no answer at all.
#
# `--workspace` where CI names the suites one at a time. CI splits them to give
# each a timeout that names the wedged one; by hand, the whole thing in one command
# is the point -- including `interrupt` and `lock_wait`, which CI leaves out. They
# kill real process trees, so they contribute no counters either way; here they
# cost a minute and are one less difference between the two runs.
#
# `--summary-only` prints the per-file table and no annotated source. Drop it for
# the full listing, or `--html` for a tree to open:
# pixi run cargo llvm-cov --workspace --html -- --test-threads=1
coverage-rust = { cmd = "cargo llvm-cov --workspace --locked --summary-only -- --test-threads=1", cwd = "rust" }
# The lcov file CI uploads, for anything that reads one locally.
coverage-rust-lcov = { cmd = "cargo llvm-cov --workspace --locked --lcov --output-path lcov.info -- --test-threads=1", cwd = "rust" }
update-lock = "pixi update && git commit -a -m'update pixi.lock' || true"
push = "git push"
update-lock-push = { depends-on = ["update-lock", "push"] }
fix = { depends-on = ["update-lock", "format", "ruff-lint", "prek"] }
fix-commit-push = { depends-on = ["fix", "commit-format", "update-lock-push"] }
ci-no-cover = { depends-on = ["style", "test"] }
ci = { depends-on = [
"format",
"ruff-lint",
"ty",
"coverage",
"coverage-report",
] }
ci-push = { depends-on = ["format", "ruff-lint", "update-lock", "ci", "push"] }
clear-pixi = "rm -rf .pixi pixi.lock"
setup-git-merge-driver = "git config merge.ourslock.driver true"
update-from-template-repo = "./scripts/update_from_template.sh"
[tool.pytest.ini_options]
markers = [
"unit: Pure logic tests with no external commands. Fast, runs everywhere.",
"integration: Runs a real command of this repo's own tooling -- `./dev.sh`, a\n documented bench reset -- against scratch state. No devpod and no container.",
"e2e: Real DevPod creating real containers. Needs a Docker daemon.",
"creates_workspace: This e2e test builds a real workspace. The session floor in test/e2e/conftest.py holds a run that attempted one of these and built nothing to be a failure, so the promise is declared by the test rather than inferred afterwards.",
]
testpaths = ["test"]
# Default: run unit and integration tests, skip e2e (which needs a daemon, and
# creates and deletes real containers -- in a devpod home the suite makes for
# the run, never the developer's)
addopts = "-m 'not e2e'"
[tool.coverage.run]
omit = ["*/test/*", "__init__.py"]
[tool.coverage.report]
exclude_also = [
"def __repr__",
"if False:",
"if 0:",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"pass",
"(_):",
]