Skip to content

build(xtask): move scripted mise tasks into an xtask crate - #63

Closed
sweepies wants to merge 1 commit into
mainfrom
chore/xtask
Closed

sweepies wants to merge 1 commit into
mainfrom
chore/xtask

Conversation

@sweepies

@sweepies sweepies commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Draft for Sweepy: what moving the repo's task scripts to cargo xtask looks like. I took it as far as it goes without slowing CI. Two scripts stay in shell, because moving them made their jobs about 40 seconds slower (numbers below).

Where each task went

Line counts are the old script, then the new mise.toml entry (including its tools table) and the xtask module.

Task Before After
test:unit bash, 12 mise.toml entry, 8 (usage choices plus a Tera if for --part)
test:tools bash, 18 mise.toml entry, 3 + 13 tools
docs:cli bash, 15 mise.toml run list, 14
benchmarks:summary bash, 11 mise.toml entry, 4
cache:usage bash, 6 mise.toml entry, 4
ci (was ci/_default) bash, 21 mise.toml 5 + xtask/src/ci.rs 56
test:stress bash, 32 mise.toml 5 + 13 tools + stress.rs 37
corpus:report bash + jq, 26 mise.toml 5 + corpus.rs 138 (about 30 of them a test)
release:package bash + jq, 38 mise.toml 4 + release.rs 92
conformance:inspect bun, 28 mise.toml 4 + conformance.rs 147 (shared with logs)
conformance:logs bun, 19 mise.toml 4 + conformance.rs
registry:update bun, 5 mise.toml 3 + registry.rs 24
server:replay bun, 25 mise.toml 4 + replay.rs 73
ci:changes bash, 38 unchanged shell (drops one dead mise-tasks/docs/* pattern)
cache:prune bash, 62 unchanged shell
cc, ar bash, 13 and 3 unchanged shell

xtask/src/main.rs (152 lines) holds the command table, a small argument parser (--name value, --name=value, positional bounds, --help), and run/output helpers that fail with the command line and exit status. The tasks that use xtask are raw_args = true entries that run cargo xtask <task>, through the .cargo/config.toml alias. No task was renamed.

Dependencies are serde_json (without serde's derive, so no proc-macro build) plus hmac 0.13 and sha2 0.11, the versions the server already uses. Cargo.lock gains only the xtask package. server:replay signs with the same HMAC-SHA256 construction as crates/server/src/webhook.rs. It doesn't depend on patchula-server itself, because that would compile the engine and tokio just to sign a body. Its HTTP is a hand-written HTTP/1.1 POST over TcpStream, which is all a loopback target needs.

Why ci:changes and cache:prune stay shell

Both jobs run the script straight from a sparse checkout, without mise or Rust. To run xtask, a job has to install Rust, Zig and mbx through mise (install_args, with MISE_TASK_RUN_AUTO_INSTALL=false), restore the Cargo downloads and mbx bundle, and build xtask. I measured that in this PR's first CI run (the full-xtask version is on chore/xtask-all):

Job Shell (before) xtask, cold xtask, warm mbx
Changed paths 5 to 8 s (#61 runs, main) 47 s not rerun; same steps as prune
Cache: prune superseded entries 9 s on main, 6 s same-run control 48 s 49 s
Cache cleanup (on PR close) 8 s not measured; same steps as prune

The warm run didn't help. 16 of 21 compilations hit, but the four build scripts bypass mbx (unportable-native-link), and installing the toolchain costs about 12 s either way. Changed paths gates every Rust job, so this would add about 40 s to every pull request. If you'd rather have them in Rust anyway, chore/xtask-all has both ported, along with a unit-tested path classifier that matched the shell script on the last 45 PRs.

CI timing for this head

Job #61's PR runs (before) This PR (two runs)
Changed paths 5 to 8 s 7 s, 5 s
Corpus: lookup 79 to 87 s (lookup step 41 to 42 s) 98 s, 121 s (lookup step 52 to 53 s)
Lint: rustfmt, clippy 83 to 119 s (clippy step 52 to 89 s) 169 s, 97 s (clippy step 78 s; the 169 s run spent 70 s in mise-action)
Tests: unit (others) 176 to 265 s (test step 153 to 225 s) 276 s, 269 s, 270 s on a rerun (test step 223 to 240 s)
Run wall clock 219 to 249 s 289 s, 281 s

At first the corpus job compiled xtask too, and took 149 s. Now the build job, which already builds every workspace binary, uploads target/debug/xtask next to patchula, and the corpus task runs ${XTASK_BIN:-cargo xtask}, the way corpus:check uses PATCHULA_BIN. So the corpus job compiles nothing. Its lookup step is still about 10 s slower than #61's runs, but within main's 56 s, and it's network-bound.

Tests: unit (others) is slower in all three samples, and I haven't pinned down why. Its mbx stats match the baseline (274 hits and 56 misses, against 275 and 55), so xtask's own objects aren't the cost. The compile phase took 2m18s to 2m35s, against 1m36s to 1m49s. The difference I can see is that these runs restore main's post-#61 bundle (87a9bd0), while the baseline runs restored the pre-#61 one (eb84a32). I'd confirm against a no-op PR on current main before treating it as this change's cost.

Bun

The conformance harness was the only user of the base bun, so it now installs Renovate with mise exec -- aube --dir <tmp> install --ignore-scripts. aube's trust policy rejects @yarnpkg/[email protected]: it has no provenance, while 3.2.0 did, and it was published 2025-09-18. The harness exempts exactly that version in a generated aube-workspace.yaml. That's a supply-chain call for you. With the exemption, Renovate 44.155.6 installs and --version runs. bun leaves [tools]. It stays in mise.lock as a task-scoped engine of test:tools and test:stress, because the real lockfile tests regenerate bun.lock. The pin test now checks bun too, and reads the pins from mise.toml instead of the old script headers.

Checked locally

  • ci:changes (xtask version) matched the shell script's outputs on the last 45 PRs.
  • registry:update produced output byte-identical to the bun script's.
  • conformance:logs and conformance:inspect gave the same JSON as the bun scripts on the fixtures. Object key order can differ, because serde_json sorts keys.
  • server:replay was checked against a signature-verifying listener, covering a good secret, a bad secret, a secret file, a non-loopback target, and both secrets set.
  • docs:cli left cli.md unchanged.
  • release:package x86_64-unknown-linux-musl produced the same archive layout as before.
  • test:unit --part bad is rejected by mise's choices.

corpus:report ran only in CI.

Docs

AGENTS.md now describes the split between mise.toml entries, xtask commands, and the four shell file tasks. internals/ci-cache.md documents the same split and why Changed paths and prune stay shell, plus XTASK_BIN.

@deepsource-io

deepsource-io Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 87a9bd0...32bc6ae on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Rust Oct 27, 2026 9:55p.m. Review ↗
JavaScript Oct 27, 2026 9:55p.m. Review ↗
Shell Oct 27, 2026 9:55p.m. Review ↗
Secrets Oct 27, 2026 9:55p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment thread xtask/src/ci.rs Resolved
Comment thread xtask/src/ci.rs Resolved
Comment thread xtask/src/ci.rs Resolved
@context7

context7 Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Docs7 for sweepies/count-patchula

Result Status Action
Deployment ➖ Not used —
Content review ✅ Passed. No problems found. —

Commit 32bc6ae

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula 32bc6ae Commit Preview URL

Branch Preview URL
Oct 27 2026, 09:55 PM

Tasks that run a command or two in order are now plain mise.toml entries:
test:unit, test:tools, docs:cli, benchmarks:summary and cache:usage. Tasks
with real logic are commands in a new xtask crate that their mise tasks run
as cargo xtask <task>: ci, conformance:inspect, conformance:logs,
corpus:report, registry:update, release:package, server:replay and
test:stress.

ci:changes and cache:prune stay shell file tasks. Their jobs run without mise
or Rust, and building xtask there added about 40 seconds to each, including
Changed paths, which gates every pull request. cc and ar stay shell because
they run on every C compile.

The corpus job runs the build job's xtask binary through XTASK_BIN, the way
it already runs patchula through PATCHULA_BIN, so it compiles nothing.

The conformance harness installs Renovate with aube instead of bun, so bun
leaves the base tools; it stays a task-scoped engine for the real lockfile
tool tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant