ci: find reusable builds from prior runs#41435
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/extension-platform (4 files, +106 -19)
👨🔧 @HowardBraham (4 files, +106 -19)
👨🔧 @itsyoboieltr (4 files, +106 -19)
|
47b95fc to
43755cb
Compare
Builds ready [43755cb]
⚡ Performance Benchmarks (Total: 🟢 17 pass · 🟡 1 warn · 🔴 0 fail)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
43755cb to
f13aab4
Compare
Builds ready [f13aab4]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 3 warn · 🔴 0 fail)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
f13aab4 to
f716337
Compare
f716337 to
494cade
Compare
Builds ready [ad565d7] [reused from 3566079]
⚡ Performance Benchmarks (Total: 🟢 3 pass · 🟡 6 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [e1104e7]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
e1104e7 to
0f1af80
Compare
Builds ready [0f1af80]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs
|
0f1af80 to
f8a2004
Compare
Builds ready [f8a2004] [reused from 0f1af80]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f8a2004. Configure here.
Builds ready [17f879d]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 11 warn · 🔴 1 fail)
Bundle size diffs
|
-extract required build artifact names -paginate artifacts -test and adjust [skip-e2e]
Builds ready [97ad790]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs
|
|
Builds ready [3765e47]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs
|




Description
Automatically reuse build artifacts when build-affecting source files haven't changed, eliminating redundant rebuilds across CI runs.
Problem: Every CI run rebuilds all 22 build variants (~15 min of compute) even when only tests, docs, or CI config changed. The previous
[builds-from-run: X]mechanism required manually finding a prior run ID and embedding it in a commit message — very few people used it.Solution: Compute a deterministic content hash of all build-affecting files, store it as a GitHub commit status, and automatically find a prior run with a matching hash and all build artifacts still available. When found, downstream jobs reuse those artifacts instead of rebuilding.
How it works
Hash computation —
git ls-tree -renumerates all files at the PR's HEAD commit, then a denylist filters out paths that don't affect builds (tests, docs, CI config, linting config, etc.). Thebuild-command:values frommain.ymlare appended so command changes bust the hash. The result is piped togit hash-object --stdin.Hash storage — The hash is posted as a
build-source-hashcommit status on every run, making it queryable by future runs viagetCombinedStatusForRef.Lookup — Searches same branch first (10 most recent
completedorin_progressruns), then falls back to the base branch (main/stable). A candidate must have a matching hash AND all required build artifacts still available (verified viagithub.paginate).Gating — When builds are reused,
builds-from-runpoints to the prior run. All build jobs, benchmarks, bundle-size, storybook, ts-migration-dashboard, and source-map-explorer are skipped. E2E and other tests run against the reused artifacts.PR comment — Build links annotated with
[reused from <sha>]when artifacts come from a different commit. "All artifacts" link points to the run that produced the builds.Escape hatches
[force-builds]in commit message orforce-buildslabelpull_requestonly[skip-builds]in commit message orskip-buildslabelpull_requestonlyci-status-gateBoth overrides are intentionally ignored in
merge_groupevents — the merge queue always uses hash-verified reuse (or fresh builds if no match).Safety properties
continue-on-error: true, error catches).main,stable, and direct pushes torelease/*always build fresh for full signal.[skip-builds]setsskip-builds: truewhichci-status-gatechecks; the PR cannot merge until the override is removed (prevents unverified builds from landing).Changelog
CHANGELOG entry: null
Related issues
Closes: https://github.com/MetaMask/MetaMask-planning/issues/5922
Manual testing steps
Tested on fork
consensys-test/metamask-extension-howardacross 9 test phases:build-source-hashcommit status ✅[skip-builds]blocks merge — Gate fails with "skip-builds is active" ✅[skip-builds]— Remove tag, re-run, gate passes; 150+ E2E tests pass on reused artifacts ✅build-overridesSKIPPED inmerge_groupevent; hash computed and matched/unmatched correctly ✅force-buildslabel — Triggers 22 fresh builds despite hash match ✅Note
Medium Risk
Medium risk because it changes core CI control flow (build execution, artifact selection, merge gating) and adds new commit-status based decisions and permissions; mistakes could lead to stale artifacts or unexpected skipped jobs.
Overview
Introduces automatic build artifact reuse by computing a deterministic
build-source-hash, posting it as a commit status, and searching recentmain.ymlruns (same branch then base branch) for a run with a matching hash and all required artifacts; when found,builds-from-run/builds-from-shaare propagated so downstream jobs download and test against reused builds.Adds PR-level overrides (
[force-builds]/force-buildslabel to force fresh builds;[skip-builds]/skip-buildslabel to reuse without hash verification) and updatesci-status-gateto block merges whenskip-buildsis active while improving error reporting.Updates prerelease commenting and documentation to reflect the new mechanism:
publish-prereleasenow resolvesHOST_URLfrom the build-producing run, annotates comments with[reused from <sha>], and the legacy.github/scripts/identify-builds-from-run.shmanual directive is removed.Reviewed by Cursor Bugbot for commit 3765e47. Bugbot is set up for automated code reviews on this repo. Configure here.