Skip to content

perf(ci): run only the jobs and contract cells a change affects - #192

Merged
aRustyDev merged 1 commit into
mainfrom
perf/ci-affected-only
Nov 16, 2026
Merged

aRustyDev merged 1 commit into
mainfrom
perf/ci-affected-only

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

PR 4 of the CI/CD review (.agents/plans/cicd-review/PLAN.md): ci now runs only the jobs and contract cells a change affects.

Before

  • Too much ran. Any change matching the rust regex started all 32 jobs and 23 cells. That included:
    • a deploy-only script;
    • probes/, which no job runs;
    • .github/deploy/;
    • a workflow ci does not run;
    • an oracle results file.
  • Too little ran. A change to web/ alone skipped the worker-cf e2e cell, which drives that build (G-30).

After

.github/scripts/plan-ci.py replaces classify-changes.sh and the plan job. The changes job gives it three things:

  • the changed paths;
  • Cargo's graph of the workspace, from cargo metadata --no-deps, with every kind of dependency;
  • the matrix, which plan-cells.sh still parses from contract-all.sh.

It returns jobs and cells.

Change Jobs Cells
web/ web, contract worker-cf e2e
thrust-adapters-cloudflare ci-scripts deps lint hermetic contract 13 worker-*
thrust-adapters-selfhosted/Cargo.toml the same, plus deny, pg-adapter and mutants 10 native-*
thrust-contracts (everything depends on it) all but deny and web 23
tools/oracle-v1/ deps hermetic contract 3 oracle
scripts/smoke-deploy.sh ci-scripts none
docs/ none none

Fails open. Everything runs in these cases:

  • a path whose readers the planner does not know (an unknown crate directory, an unlisted script, the toolchain, the lockfile, ci.yml, the planner or gate, the cells' harness);
  • a target it does not know;
  • no base commit, a failed diff, or a failed cargo metadata;
  • a release candidate, a merge-queue entry, a manual run, or the new nightly run on main (03:23 UTC).

The nightly run is how a new RustSec advisory or a new stable shows up without waiting for a pull request. deploy.yml ignores it, because plan-deploy.sh deploys only after a pull request or a push.

Files that tests read from outside their crate get their own rules, because Cargo's graph can't see them:

  • tools/oracle-v1/ is read by the tests of four crates.
  • .github/deploy/ is read by the TLS tests of adapters-postgres.

The gate (assert-gate.sh) now checks the planner's job set:

  • Every expected job must be success, and every other job must be skipped.
  • The gate and the planner must name the same nine jobs.
  • EXPECTED_JOBS and PLANNED must be JSON arrays of strings. A mutant showed that {} would otherwise read as "no jobs".
  • The cell-marker rules are unchanged.

Tests

  • test_plan_ci.py (new, 4,885 checks):
    • 300 seeded random crate graphs, with each crate changed alone and in pairs, against an independent reverse-reachability written in the test.
    • The plan of a list equals the union of its parts' plans.
    • Each rule is the first match of its own sample (no shadowing), and matches a tracked file.
    • The fail-open cases.
    • This repo's real graph: every target of contract-all.sh is known, and the named crates exist.
    • No script that the planner keeps out of the cells is called by the scripts that run a cell.
  • test-ci-scripts.sh (101 checks): the gate over each of the nine jobs, expected or not, with each of the four results, plus the cell, input and name cases.
  • 34 hand mutants of the planner and the gate, each caught.
  • Locally: every ci-scripts test and deps guard under dash (37/37), and actionlint.

Not verified until CI runs it

This PR changes ci.yml and the gate, so its own run is a full one: it shows the new wiring with all nine jobs expected. The narrowed plans first run on later pull requests. The plan's verification step covers that: draft PRs touching docs, one Worker crate, scripts/smoke-deploy.sh and web/.

Built-ins considered

  • cargo-rail, affected and cargo-delta compute the affected crates. None of them knows the jobs, the cells or the gate's expected set, and each would add a binary to the required check's path.
  • dorny/paths-filter maps paths to flags, but its filters would be YAML that no test runs.

The graph itself comes from cargo metadata.

Not in this PR

The smaller fixes from the review each get their own PR:

  • lint-workflow.sh over every workflow;
  • --locked on hermetic and pg-adapter;
  • a docs job;
  • rust-toolchain.toml.

Refs: #49

🤖 Generated with Claude Code

ci.yml ran all or nothing. Any file under scripts/, probes/,
.github/deploy/ or tools/oracle-v1/, or any workflow (deploy.yml,
flake-hunt.yml included), started all 32 jobs and the 23 cells. A
change to web/ alone skipped the browser journeys' cell, which drives
that build (G-30).

- .github/scripts/plan-ci.py replaces classify-changes.sh and the
  `plan` job. The `changes` job gives it the changed paths, Cargo's
  graph of the workspace (cargo metadata --no-deps; normal, dev and
  build dependencies) and the matrix (plan-cells.sh). It names the
  jobs and the cells to run:
  - A crate change affects the crate and every crate that depends on
    it. A target's cells run when the binary they start is affected
    (native-* start thrust-server, worker-* start thrust-worker).
  - pg-adapter runs when thrust-adapters-selfhosted is affected.
    mutants runs when thrust-server is affected.
  - A pass runs on its own inputs: tools/oracle-v1/ runs the oracle
    cells; e2e/ and web/ run worker-cf e2e.
  - Files that tests read from outside their crate have their own
    rules: tools/oracle-v1/ and .github/deploy/.
  - A path whose readers the planner does not know runs everything.
    So does an unknown target.
- ci.yml:
  - Every job runs on `contains(jobs, '<job>')`.
  - The matrix comes from `changes`.
  - A merge-queue entry runs everything, as does a release candidate,
    a manual run and a new nightly run on main (03:23 UTC). The
    nightly run catches a new advisory or stable toolchain.
    deploy.yml ignores it.
- assert-gate.sh checks the planner's job set:
  - An expected job must be `success`; every other must be `skipped`.
  - The gate and the planner must name the same nine jobs.
  - The inputs must be JSON arrays of strings.
  - The cell rules are unchanged.
- .config/branding/ (the book's palette) no longer runs everything.
- Docs: cicd.md, running.md, status.md (G-30's gap 2),
  book-theme.md, e2e-schedule.yml's header, and the plan's as-built
  notes.

Tests:
- test_plan_ci.py, 4885 checks:
  - 300 generated crate graphs, against an independent
    reverse-reachability;
  - the union of plans;
  - each rule is first matched by its own sample, and matches a
    tracked file;
  - the fail-open cases;
  - this repository's graph and targets;
  - no script kept out of the cells is called by what runs a cell.
- test-ci-scripts.sh, 101 checks: the gate over every job, expected or
  not, with each of the four results.
- 34 hand mutants of the planner and the gate, each caught.

Refs: #49
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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