Skip to content

Latest commit

 

History

History
406 lines (345 loc) · 24.9 KB

ci-tiers.md

File metadata and controls

406 lines (345 loc) · 24.9 KB

CI tiers: what runs on a PR, on a merge, and before a release

Perry's CI is one workflow — .github/workflows/test.yml — with three tiers. The tier a run belongs to, and the exact set of jobs it executes, is decided by one script, scripts/ci_plan.py, in the workflow's first job (plan). Planned jobs use needs: plan and fromJSON(needs.plan.outputs.plan).jobs.<name>. The tokio-ban preflight runs independently on every PR and core CI run. It checks repository Cargo manifests, lockfiles and Rust source without a Rust toolchain. The gate requires its result to be success; a missing, skipped, failed or cancelled preflight cannot pass pr-gate or a release gate.

python3 scripts/ci_plan.py --table       # the job x tier matrix below
python3 scripts/ci_plan.py --self-test   # the policy's own invariants
tier trigger what it is for fan-in job
pr every pull_request push the required gate. Small, fast, must be green on main. pr-gate — the only required status context
sweep every push to main (coalesced) + a two-hourly cron backstop post-merge truth for main: unscoped unit/package tests plus medium-weight jobs; Perry's large integration inventory stays in the nightly/release full tier main-gate
full nightly schedule, v* tags, workflow_dispatch, PRs labelled run-extended-tests everything, incl. auto-optimize parity over test-files and node-suite, compile-smoke, doc-tests, package smokes full-suite-gate — what release-packages.yml waits for

The job × tier matrix

Generated by python3 scripts/ci_plan.py --table; the lint job checks that this copy is current.

The PR gap tier uses twelve fast-mode shards after a six-way shard exhausted the 110-minute job bound; the sweep and full tiers run the same lane in three. The full tier's parity job runs every case of tests/fixtures/programs/ and tests/parity/node-suite/ in auto-optimize mode through scripts/parity.py, in sixteen shards. Compile-smoke partitions the complete top-level tests/fixtures/programs/*.ts inventory into four stable round-robin shards, with at most two smoke shards running concurrently. Each file is assigned once before the existing platform exclusions are applied. Every shard retains the default compiler invocation and failure markers; full-suite-gate requires the matrix job's aggregate result. These splits address twelve-way gap jobs reaching their 110-minute bound and the unsharded smoke job reaching the hosted six-hour limit. Actual CI durations must still establish the new margin.

job pr sweep full
lint always yes yes
check yes yes yes
warnings yes yes yes
cargo-test yes yes yes
cargo-test-perry yes
gap-suite 12x fast 3x fast 3x fast
wasi-execution yes yes yes
gc-call-effects yes yes yes
gc-stress 1x pr 4x all 4x all
e2e-scoped yes
parity-scoped yes
security-audit deps only yes yes
windows-build yes yes
windows-arm64-build yes yes
compiler-output-regression yes yes
repsel-census yes yes
harmonyos-smoke yes yes
binary-size yes
parity yes
test262 yes
compile-smoke yes
native-abi-evidence-packet yes
drizzle-mysql-smoke yes
ink-link-smoke yes
effect-basic-smoke yes
doc-tests yes

windows-build also runs python scripts/run_windows_runtime_regressions.py after building the compiler and both static archives. It compares the Windows path/file-URL, realpath, shell quoting, child argv0, platform metadata, and named-pipe shutdown fixtures with the exact Node oracle in .node-version. The pipe fixtures cover duplex replies and queued writes as well as EOF. A native unread-peer probe also checks that destroying a socket releases the drain's duplicated handle while the JavaScript process remains alive. These fixtures skip their Windows bodies on other hosts; use the full tier (run-extended-tests) when reviewing changes to this behavior.

scripts/ci_pr_files.py binds scope to the expected PR head and stable head/base/file-count metadata. It validates paginated file lists for ordinary PRs. Above GitHub's 3,000-file listing cap it compares immutable merge-base and head Git trees, retaining both endpoints of renames. Partial recursive tree arrays are discarded and replaced by complete child-tree traversal; malformed, truncated fallback or raced responses fail before emitting scope. This keeps large layout migrations scoped without accepting a shortened list.

Within the pr tier the changed-file list narrows the plan further:

  • docs-only (only docs/, *.md, benchmarks/, npm/, packaging/, .claude/, … — see NON_CORE_GLOBS in ci_plan.py) → lint and the mandatory tokio-ban preflight run.
  • core (anything that can change the compiler, the runtime, or a test outcome) → the whole PR tier.
  • deps (a lockfile, manifest, deny.toml, package.json, .claude/, skills/, …) → additionally the inlined security-audit suite.

Within cargo-test, runtime changes also select perry-stdlib unit tests: those tests exercise runtime GC, arenas, closures, promises and the event loop. The perry-ext-* crates remain excluded from dependency fan-out unless directly changed. scripts/ci_test_scope.py owns this policy, with regression tests in lint.

Rust test lanes and timeboxes

Perry's Cargo suites use the same fast / mid / slow idea as socket-wheelhouse, but their wall times are measured in minutes because Rust compilation and the runtime-linked test binaries dominate these suites. The wheelhouse's 10s / 30s / 60s limits apply to its small Vitest lanes and should not be copied onto Cargo.

Lane What runs Expected time Enforced timebox
Fast PR-scoped crate unit tests (--lib --bins), plus the always-on FFI ABI unit check <10 min for the scoped Cargo loop 30 min Cargo job cap; the PR gate targets ≤30 min wall clock once queued.
Mid Full workspace package tests on main sweeps, including Perry bin/unit tests; Perry integration tests are left to the slow lane <60 min target; the prior full Cargo job measured 50–60 min warm and 90–103 min cold before removing Perry's serial integration inventory 120 min Cargo job cap.
Slow Complete Perry integration inventory on nightly, release tags, and opt-in full runs; changed suites run through e2e-scoped on PRs Eight round-robin shards 120 min per shard. The separate scoped e2e job applies 25 min subprocess bounds where configured.

The hard caps are failure cutoffs, not performance goals. Although fast and mid share the cargo-test job, its timeout comes from the planner tier: 30 minutes for PR scope and 120 minutes for full workspace scope. A manual workflow_dispatch --tier pr has full workspace scope without the sharded slow lane, so it retains a 180-minute cap. The main sweep now runs Perry's bin/unit target in the cargo-test job while the complete Perry integration inventory stays in the nightly/release shards; this avoids repeating the expensive serial integration loop on every merge without dropping it from the full-suite gate. A run that approaches its cap should trigger a measured build/test optimization, not a larger timeout. Keep RUST_TEST_THREADS=1 for perry-runtime: its tests share process-global GC, arena, timer, and notification state. Keep CARGO_BUILD_JOBS=1 for the runtime-linked test binaries until runner memory measurements support increasing it. Mr Boxington-backed release jobs use mbx's default cache policy; local make build-dev and make build-prod leave MBX_INCREMENTAL unset so mbx can keep private incremental state for edited crates while sharing unchanged compilations.

e2e-scoped runs integration suites selected by the diff, but its SUITE_EXCLUSIONS check is deliberately not scoped: whenever that list is nonempty, every core PR reruns each excluded exact test and fails if it no longer fails. This catches fixes made in HIR, transform, or another dependency without adding Rust setup to docs-only PRs.

parity-scoped runs the program cases a PR owns, in auto mode against tests/parity/snapshots/linux-auto/: each changed case, the subject of each changed snapshot, and the node-suite modules that scripts/test_owners.py maps the changed source to. A source path no row owns is cross-cutting and adds nothing; the gap lane already runs for it. With nothing selected the job ends after computing the selection.

An empty or failed file listing is treated as core and a failed plan job fails the gate outright — a broken planner must never turn into "everything skipped, therefore green".

Why it looks like this (measured 2026-08-16)

The organisation runs on GitHub's Free plan: 20 concurrent hosted jobs, 5 of them macOS, for the whole org. Before this shape, every PR push fanned out to 14 workflows / 48 jobs / ~650 runner-minutes, and main saw ~66 PR pushes and ~58 merges a day. That is 1.5–2× total capacity, so:

  • job queue waits were 3–7 h (conformance-smoke shards: median 4 h);
  • 0 of 66 PR runs of the Tests workflow reached a conclusion in the sample window — 8 failed, 56 were cancelled by the next push;
  • the required contexts included two jobs (parity, compile-smoke) that never ran on a PR and one (conformance-smoke-complete) that had been red on main for days, so every one of the last 12 merges was an admin bypass with lint and cargo-test still queued.

The always-red required-gate incident was tracked in #8092. #8087 restored lint, #8095 made the textual and native LLVM paths record the same stable ELF source identity so cargo-test could pass on Linux, and #8187 replaced the fragmented required-context list with the single pr-gate fan-in described above.

Two specific costs dominated:

  • conformance-smoke was 8 shards × ~60 min = 480 job-minutes per push, and 96 % of each shard's test time was ~10 tests at ~200 s each — the auto-optimize path rebuilding a feature-stripped runtime per distinct feature set, redundantly in every shard. The harness's PERRY_SKIP_BUILD=1 mode runs the same tests against one prebuilt release compiler at ~1.5 s each; that is the fast gap mode every tier uses. Auto-optimize runs in the full tier's parity job, because it is the only arm that sees auto-optimize-only link bugs.
  • Every job saved a fresh sccache tarball (then ~0.5–1.3 GB) on every PR push (~200 GB/day into a 10 GB repo cache budget), evicting every useful entry within the hour — and PR-scoped caches are not even readable by other PRs. No job saves an sccache tarball now, and only main-line runs save caches; see Build caches. cache-warm.yml is gone: the sweep is the cache-producing build on main.

A later release run exposed a separate serial bottleneck: its 246 perry integration-test binaries had not reached their midpoint when cargo-test hit its 180-minute cap. In the full tier, cargo-test now retains the perry bin/unit target and every other package while cargo-test-perry assigns every perry integration target exactly once across eight deterministic, count-balanced shards. The shards restore the shared compiler cache but do not upload eight near-duplicate copies. Their aggregate matrix result is a direct dependency of full-suite-gate.

The satellite gates (gc-ratchet, gc-root-dominance, gc-native-roots, gc-moving-witnesses, gc-parse-churn-gate, gc-ptr-shape-off-witness, tls-budget, auto-opt-app-patterns, eh-transport, llvm-inprocess, ext-link, container-tests) keep their six-hourly / nightly main-line sweeps and their release-tag arms (see CI gate scheduling and scripts/gate_freshness.json), but their PR arm is opt-in: apply the run-extended-tests label to a PR and they run on it, along with the full tier of test.yml. An unlabelled PR still gets a run of each — with every job skipped, which costs no runner slot.

Build caches

The repository's Actions cache holds 10 GB on the organisation's Free plan, and a PR can restore only what main saved: PR-scoped entries are invisible to other PRs. Every Rust job goes through .github/actions/perry-rust-cache, which wraps Swatinem/rust-cache with one policy:

  • One family per build. key names the family (the job id by default). rust-cache keeps the first save of a key, so a family has exactly one saving job (save: "true"), chosen from the jobs a PR runs. Sweep and nightly jobs that run the same build restore that family without saving it; the release-profile build-perry jobs restore gap-suite-build. A restorer needs the saver's runs-on and the same CARGO*/RUST*/CC* environment, which rust-cache hashes into the key; the action exports CARGO_INCREMENTAL=0 first so that variable never splits a family. A saver must run on main: e2e-scoped runs only on PRs, so it keeps no cache. test_actions_plan.py fails on a second saver, on a restorer that cannot hit, on matrix legs that share a runner and a family but build differently, and on a direct Swatinem/rust-cache use in the core workflows.
  • Saves survive a red main. cache-on-failure is on: a job that fails its tests has still compiled valid dependencies, and a red main would otherwise never save anything. A job that fails before it builds saves a near-empty entry that rust-cache never replaces, so the key also carries the ISO week (PERRY_CACHE_EPOCH): such an entry lasts at most a week, and every family starts cold once a week.
  • The key follows the pinned toolchain only. rust-cache hashes every installed rustc, and the runner image's preinstalled stable changes with each image rollout, so the action removes it before hashing.
  • Restored dependencies stay fresh. .cargo/config.toml builds std from rust-src, which Cargo fingerprints by mtime, and every job installs the toolchain anew. The action pins those mtimes to a fixed date, and the vendored rust-cache keeps the build-std units it would otherwise drop for being absent from cargo metadata (the "Perry patch" in its cleanup.ts). Without both, std and every crate above it rebuild after a full cache hit.
  • No sccache tarballs. Those tarballs grew to ~4.7 GB each by the time three jobs saved one on every main run, which evicted the whole budget. The GitHub cache backend of sccache (one entry per compilation unit) was measured at ~0 % Rust hits under throttling. rust-cache stores dependencies only; workspace crates rebuild in every job.

Only jobs that run on pull requests save, and only from test.yml; sweep, nightly and cron jobs restore a PR family when their build matches one, and start cold otherwise. GitHub evicts by last access, and a family saved by a later cron run is newer than the PR families, so it evicts them first: one morning, gc-native-roots' four platform entries (~3.8 GB) and two macOS families pushed wasi-components and four other PR families out. test_actions_plan.py checks the saver against scripts/ci_plan.py's tiers. The release workflows (release-packages.yml, release-wasi.yml) keep their own release-* keys. gh api repos/PerryTS/perry/actions/cache/usage and gh api repos/PerryTS/perry/actions/caches show the total and each family's size; if the PR families stop fitting in 10 GB together, PR jobs go cold again.

Budgets

tier typical jobs typical runner-minutes target wall clock
pr (core) ~13 (6 gap shards) ~200 ≤ 30 min once queued
pr (docs-only) 2 ~5 ≤ 5 min
sweep ~19 ~300 not a target — it coalesces
full ~30 ~1500 not a target

push to main uses ONE constant concurrency group with cancel-in-progress: false: GitHub keeps at most one running + one pending run per group and replaces the pending run with the newest, so a burst of merges is tested at its tip instead of queueing 58 sweeps. The push arm alone is not sufficient: measured 2026-08-16..18, no push sweep ever reached a runner — merges replaced the pending run faster than the pending→running transition happened, even with an idle queue. The two-hourly cron (47 */2 * * *; the planner maps any non-nightly cron to the sweep tier) is the reliable arm; the push trigger stays for quiet periods. Sweep-only jobs are chained behind check so a sweep's fan-out does not take every runner slot the moment a merge lands. Attribution of a sweep failure is by window (previous sweep SHA .. this sweep SHA), exactly as for the six-hourly gates.

Opting a PR into more

  • run-cc-parity label — runs the Claude Code bundle parity gate on changes to crates, build inputs, or the gate. This independent, initially non-required check compiles pinned Claude Code 2.1.112 and compares offline native help/version output with checked-in Node goldens on one macOS runner.
  • run-extended-tests label — promotes the PR's test.yml run to the full tier AND enables the PR arm of every satellite gate. Use it for GC / codegen changes that should be measured before merge, and for anything touching a full-tier-only suite. Applying the label re-fires the runs (labeled trigger).
  • skip-changelog label — skips the changeset step in lint (a crates/ change must otherwise add a changelog.d/<PR>-<slug>.md fragment).
  • workflow_dispatch on any branch: tier (pr / sweep / full) and update_gap_snapshot.

Re-baselining the gap snapshot

The pull-request gap lane runs scripts/parity.py run --suite all --filter test_gap_ --mode fast, including migrated cases that retain their test_gap_ basename. It is judged by the per-subject snapshots under tests/parity/snapshots/linux-fast/, each checked in both directions: any divergence — a case that started failing OR started passing — is red. When main has legitimately moved (a triaged regression, an oracle change), regenerate it from CI, not from a laptop (the required baseline is Linux, fast mode):

gh workflow run test.yml --ref <branch> -f tier=pr -f update_gap_snapshot=true
# wait for the run, then:
gh run download <run-id> -n gap-snapshot-update -D /tmp/snap
cp -R /tmp/snap/. tests/parity/snapshots/linux-fast/
# fill in `issue` / `reason` for every new entry, then commit

New entries land as category: untriaged; give each an issue and a reason before merging. A crash is never accepted into a snapshot (parity.py refuses).

The full tier's parity job is judged by tests/parity/snapshots/linux-auto/. Re-baseline it from a full run's shard reports:

gh run download <run-id> -p 'parity-shard-*' -D /tmp/parity
python3 scripts/parity.py accept /tmp/parity/*/latest.json

Branch protection

Required status checks on main: pr-gate only. Adding, removing or renaming a job in test.yml never needs a branch-protection edit again; the fan-in job carries the verdict. gate-freshness.yml (scripts/gate_freshness.json) watches that each main-line sweep produces a completed result within its budget; the gate's own run carries whether that result passed or failed.

Release

release-packages.yml's await-tests dispatches test.yml with tier=full on the pinned release branch and polls the SHA for a run whose full-suite-gate job succeeded — a green sweep or PR-tier run on the same SHA does not count. See Releasing.

parity runs as 16 shards (parity.py run --suite all --mode auto --shard N/16). Each shard compares its own cases with the snapshots in both directions, so its exit code is its verdict, and a shard that ran no case fails.

test262 runs every Test262 case (scripts/test262_subset.py --full-corpus) as 16 shards at the SHA in tests/compat/test262/pinned-sha.txt. test262-aggregate merges them with scripts/test262_ratchet.py, prints the pass rate over the whole corpus in the run summary, and fails on a new failure, on a known failure that now passes (remove it from tests/compat/test262/baseline.json), or on a pass count below the baseline. Re-baseline with scripts/test262_ratchet.py --update <reports>.

Workflow suite selection

The CI Actions workflow defaults to suite=core, preserving the tiered pr-gate, main-gate, and full-suite-gate. Select suite=coverage, suite=security-audit, or another auxiliary ID to run that nested workflow independently; suite=all adds all auxiliary workflows to core CI. The tier selector continues to control core CI.

The Actions sidebar has six repository workflows. GitHub also registers four independent entries for Dependabot Updates, Dependency Graph, Copilot, and Pages, making ten entries once retired workflow history is cleaned up.

Workflow Categories and suite selection
CI Required core CI and auxiliary security/coverage checks; defaults to suite=core
Extended Tests (compiler-runtime.yml) Compiler/runtime, compatibility, integration, and performance; choose a category such as suite=compatibility, one suite such as suite=simctl-tests, or suite=all
GC Six collector suites; choose an individual suite or suite=all
Repository (maintenance.yml) Documentation and repository maintenance; defaults to offline suite=validate; select suite=docs-check for docs checks or suite=docs for deployment. Every 30 minutes auto-label adds platform:, area: and type: labels to new issues and PRs (scripts/auto_label.py)
Publish to npm / GitHub Release Compiler packages, platform archives, and GitHub releases
Publish to npm / @perryts/hono-server Independent adapter package publication

Every original suite remains represented except node-suite-guard, whose corpus the full tier's parity job runs. Schedules select their original suites even when several categories share a parent. Category and all dispatches use the original suite input defaults; individual suite dispatches accept their custom inputs. Live maintenance tasks must be selected explicitly and dispatched from main. Documentation deployment can still be dispatched on a release tag. The release workflows retain their filenames for npm trusted publisher authorization.

Job display names use lowercase. Nested suite jobs use the stable suite ID as their prefix, for example docs-check / build-and-validation and docs-check / suite result. Workflow category names retain their sidebar casing. Keep suite prefixes stable: freshness checks, failure monitoring, and release orchestration select jobs by these names. scripts/check_actions_topology.py enforces lowercase labels and suite prefixes.

For example, gh workflow run compiler-runtime.yml -f suite=performance runs the performance category; gh workflow run compiler-runtime.yml -f suite=benchmark runs only the benchmark suite. Release orchestration dispatches the simulator suite on the exact candidate SHA and checks its actual job result, independently of other Extended Tests jobs.

After a consolidation lands, Repository automatically deletes completed runs whose repository workflow file no longer exists. It allows queued/running jobs to finish before deleting their history and leaves GitHub's dynamic registrations alone. This removes retired entries from the sidebar as their last runs are cleaned up.

Required WASI command and component execution

The wasi_execution plan entry joins the core PR, sweep and full tiers and starts five Linux jobs in parallel, so the gate waits for the longest of them rather than their sum:

  • wasi-native runs the target-wasi codegen and link-argument unit tests.
  • wasi-component-units runs the component-model unit tests (scripts/component_unit_tests.sh).
  • wasi-execution builds Perry with target-wasi and a matching wasm32-wasip2 runtime, checks the IR ABI, then runs all six smoke cases, twenty acceptance cases and ten pinned-Node comparisons.
  • wasi-execution-p1 builds the same compiler and a wasm32-wasip1 runtime, checks its imports, then runs the preview 1 smoke, acceptance and gap suites and the preview 1 host suite.
  • wasi-components builds matching native component tools and instrumented runtimes and runs both component harnesses: native hosting, Perry-authored guests, resource lifetimes, forced moving GC and direct Rust/Perry composition.

Per-case logs, component phase verdicts, source revision and artifacts are retained (wasi-required-<sha>, wasi-required-p1-<sha> and wasi-components-<sha>). The required pr-gate rejects a skipped or missing planned WASI job as well as failures and cancellation, for each of the five. Docs-only PRs skip this build. The wider Windows/macOS matrix remains in the extended suite. Native component execution is currently qualified on Linux.