Skip to content

ci(027): cache dependencies of the native bindings jobs per platform - #573

Merged
bartekus merged 1 commit into
mainfrom
ci/native-bindings-cache
Nov 8, 2026
Merged

bartekus merged 1 commit into
mainfrom
ci/native-bindings-cache

Conversation

@bartekus

@bartekus bartekus commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Spec 027 (CI only, no claim of the spec changes). The darwin-arm64, darwin-x64 and win32-x64-msvc legs of native ${{ matrix.platform }} in bindings.yml each restore a dependency cache of their own; nothing built or tested changes, and the four Linux legs are unchanged from main.

  • Cached: ~/.cargo/registry/index, ~/.cargo/registry/cache, ~/.cargo/git and target/release with the workspace crates' artifacts dropped (Cargo rebuilds them after any checkout, as the wasm and node jobs already note).
  • Key: bindings-native-<platform>-<runner>-node-fp-corpus-local-embed-<hashFiles(Cargo.lock, rust-toolchain.toml)>. No restore-keys, so an entry is used only by its own platform, runner, lockfile and toolchain; Cargo's fingerprints still judge every artifact.
  • Restored in every run, saved only from a push to main (merge-queue and pull-request saves are readable by nothing else).
  • scope's post-merge rule also runs the bindings jobs on main when bindings.yml itself changes, so a change to what the caches hold (including this one) seeds them. The wasm and node jobs then hit their existing entries and save nothing.
  • The Linux legs are left uncached: their dependency phase is 74 to 144 s and the node jobs show the workspace chain hides it (below), which does not justify cache budget the repository is already over.

Measurements (before)

Merge-queue runs of #567 (42511840610) and #565 (42452908883), native job seconds:

platform #567 #565 dependency phase (first + local-embed builds)
linux-x64-gnu 482 594 82 s
linux-arm64-gnu 449 446 74 s
linux-x64-musl 849 1186 133 s
linux-arm64-musl 1071 1032 144 s
darwin-arm64 834 696 340 s
darwin-x64 1834 1082 319 s
win32-x64-msvc 1233 950 421 s

Cargo's three builds take 90 to 96 per cent of each job. The dependency phase (until the last dependency crate starts compiling) bounds the saving; the workspace crates compile one after another and still rebuild every run. The node jobs, which already restore dependencies, built rustev-node in 4 min 41 s against 4 min 13 s uncached on linux-x64-gnu, so on Linux the expected saving is small; on macOS and Windows up to about 5 to 7 minutes per job.

Cache budget

Before this change: 12.1 GB active against GitHub's 10 GB repository limit, all on refs/heads/main (largest: verify-cli-repeat 2.4 GB, semver 2.1 GB, verify-integrations-base 1.9 GB). The three new entries add an estimated 0.6 to 1.2 GB (the node job's single-feature entry is 197 MB); GitHub evicts the least recently used.

How the change is exercised

A pull request's own run leaves out every bindings.yml job (spec 027's 2026-11-05 record), so this PR's run does not run the native jobs. The merge-queue entry runs all seven (the three cached legs miss, since no entry exists yet); the push to main then runs them again (the workflow changed), and the three cached legs drop workspace artifacts and save their entries; later queue entries restore them.

Checks

  • actionlint .github/workflows/bindings.yml: clean.
  • make refresh, make gate: pass.

Review note

The AI review's one finding on 1d14740 (low, authority) says it cannot verify the owner's approval of the statecraft-review-exception Environment for this workflow change. That approval is the run's own review-exception job, which ci-gate requires; it is not a defect in the diff.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (no-findings)

Looking at the two changed files:

.github/workflows/bindings.yml

The cache restore step (unconditional, all platforms) and the matching save step are consistent with each other and use a pinned action SHA 55cc8345863c7cc4c66a329aec7e433d2d1c52a9 on both sides.

The Drop workspace artifacts before saving step uses a bash shell function to override cargo for the container legs. The cargo metadata --no-deps | jq ... | sed pipeline runs cargo metadata inside the container while jq and sed run on the host -- this is correct since the pipe is host-side. The test -n "$packages" guard before cargo clean $packages prevents an accidental full-target wipe if the command produces no output.

The unquoted $packages with word-splitting to supply -p pkg pairs to cargo clean is intentional and correct (noted with shellcheck disable=SC2086).

The updated trigger condition -- adding bindings.yml to the set of files that cause a post-merge re-run -- is consistent with the stated rationale (a change to the workflow can change what the caches hold).

The chown commands are extended to cover ~/.cargo/registry and ~/.cargo/git after container runs; this is necessary because Docker runs as root inside the container and would leave root-owned files in those mounted directories.

The Prepare the Cargo home the containers mount step (gated on startsWith(matrix.platform, 'linux')) creates the directories before the first Docker mount, which is required when no cache entry exists yet.

The cache-primary-key output from actions/cache/restore is used as the key in actions/cache/save, which is the documented pattern for split restore/save.

specs/027-node-and-wasm-bindings/spec.md

The revision entry is explicitly marked "(CI only, no claim of this spec changes)" and is appended to the existing revision history section. No lifecycle fields (status, implementation) are changed in the diff, so no ratification is claimed or needed.

No concrete defects found.

{"head": "6f9c8717d1aec947d3296aa7a1545669e996c746", "verdict": "no-findings", "findings": []}

Subject: 59cc7c3...6f9c871, diff digest 9cd29a51fde3f436c375356eca7501bb5d7e41eb8dd6a8a2a7a51661bef543f7, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 8, 2026 19:38 — with GitHub Actions Inactive
@bartekus
bartekus force-pushed the ci/native-bindings-cache branch from 6f9c871 to 1d14740 Compare November 8, 2026 19:46
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the two changed files against governance context and for correctness and security issues.

.github/workflows/bindings.yml

The change adds a dependency cache restore/save cycle for darwin and win32 platform legs of the native matrix job. The logic is sound:

  • The restore uses actions/cache/restore with no fallback key (exact-match only), which is correct given the stated intent.
  • The save guard (steps.cargo-cache.outputs.cache-hit != 'true') correctly skips saving when the exact key already exists.
  • The cargo clean $packages step uses --no-deps metadata to enumerate workspace-only packages, then intentionally word-splits the -p <name> pairs; Cargo package names are alphanumeric plus -/_, so there is no injection risk and the split is correct.
  • The test -n "$packages" guard prevents cargo clean from running without arguments (which would wipe everything) if jq returns nothing.
  • Both actions/cache/restore and actions/cache/save reference the same pinned digest 55cc8345863c7cc4c66a329aec7e433d2d1c52a9, which is consistent.

One governance process point: AGENTS.md states that any change under .github/workflows/ requires the owner's approval of the statecraft-review-exception Environment. This PR changes .github/workflows/bindings.yml. That gate is enforced by CI, not by this review, but the requirement is stated clearly in AGENTS.md and I cannot verify the owner act was performed.

specs/027-node-and-wasm-bindings/spec.md

The revision note correctly labels itself "(CI only, no claim of this spec changes)" and adds a purely documentary entry. No lifecycle fields (status, implementation) are altered in the diff. The note is consistent with the workflow change it describes.

No other defects found.

{"head": "1d147407371f1e41d585a5dc17225e7c6fc540b7", "verdict": "findings", "findings": [{"path": ".github/workflows/bindings.yml", "line": null, "severity": "low", "category": "authority", "summary": "AGENTS.md requires owner approval of the statecraft-review-exception Environment for any change under .github/workflows/; this review cannot verify that act was performed for this workflow change."}]}

Subject: 59cc7c3...1d14740, diff digest e1445c7fd10d006c3b7b8eb87880e1ccce0855d64967d39c4f11066ac21521e7, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 8, 2026 19:48 — with GitHub Actions Inactive
@bartekus
bartekus enabled auto-merge November 8, 2026 19:49
@bartekus
bartekus temporarily deployed to statecraft-review-exception November 8, 2026 19:49 — with GitHub Actions Inactive
@bartekus
bartekus added this pull request to the merge queue Nov 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 8, 2026
@bartekus
bartekus added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 13da46b Nov 8, 2026
54 of 65 checks passed
@bartekus
bartekus deleted the ci/native-bindings-cache branch November 8, 2026 21:34

This branch was previously deployed

1 inactive deployment
statecraft-review-exception — 1d147407 Deployed Nov 8, 2026 by bartekus via review-exception #3856
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