Skip to content

ci: pre-warm Namespace cache for unit/component-view test shards#30098

Merged
tommasini merged 14 commits into
mainfrom
ci/reuse-js-deps-ci
May 15, 2026
Merged

ci: pre-warm Namespace cache for unit/component-view test shards#30098
tommasini merged 14 commits into
mainfrom
ci/reuse-js-deps-ci

Conversation

@tommasini
Copy link
Copy Markdown
Contributor

@tommasini tommasini commented May 13, 2026

Summary

Introduces a `prepare-ci-js-deps` job and a `setup-ci-js-deps` composite action to eliminate redundant `yarn install` + `yarn setup:github-ci --node` across 13 CI shards (10 unit-test + 2 component-view + 1 merge job).

What changed

New job `prepare-ci-js-deps` (`ci.yml`)
Runs before `unit-tests`, `component-view-tests`, and `merge-unit-and-component-view-tests` and installs dependencies once on behalf of all consumers.

  • Namespace runners: mounts the persistent cache volume and runs install only when the volume is cold (yarn.lock changed in the pool). Consumers restore from the same volume — install is skipped entirely on a warm cache.
  • Non-Namespace runners (current default for all PRs): runs install, then packs `node_modules` + generated files into a gzipped tarball (`ci-js-deps.tar.gz`) and uploads it as a workflow-run artifact. Consumers download and extract the tarball instead of running their own install.

TEMP: The tarball artifact path is a temporary fallback while Namespace is on trial. Once Namespace becomes the default runner, the pack/upload steps in the producer and the download/extract steps in each consumer can be deleted. The `setup-ci-js-deps` composite action requires no changes.

New composite action `.github/actions/setup-ci-js-deps`
Shared setup sequence used by the producer and all three consumer jobs:

  1. Mount Namespace cache (Namespace only)
  2. `actions/setup-node`
  3. File-based freshness check (`node_modules` dir + `termsOfUseContent.ts`)
  4. `yarn install --immutable` + `yarn setup:github-ci --node` — only if step 3 finds files missing

On non-Namespace consumers, step 3 finds the tarball already extracted, so step 4 is skipped.

Consumer jobs (`unit-tests`, `component-view-tests`, `merge-unit-and-component-view-tests`)
Each job's setup block is replaced with:

  • TEMP: download + extract `ci-js-deps.tar.gz` (non-Namespace only; tar preserves permissions so no separate restore step is needed)
  • Call to `setup-ci-js-deps` (which skips install when files are already present)

`check-all-jobs-pass`
`prepare-ci-js-deps` added to the gate.

Not changed

  • `setup-node-modules.yml` — untouched
  • E2E jobs — untouched (Phase 2 scope)

Estimated impact

Lane Shards Before After (non-Namespace) After (Namespace)
`unit-tests` 10 ~2 min install each ~30s download+extract ~10s cache hit
`component-view-tests` 2 ~2 min install each ~30s download+extract ~10s cache hit
`merge-unit-and-component-view-tests` 1 ~2 min install ~30s download+extract ~10s cache hit
Saved per run ~22 runner-min ~26 runner-min

Removal guide (when Namespace passes trial)

Search for `# TEMP` in `ci.yml` — there are exactly 4 clearly marked blocks:

  1. `Pack CI JS deps` + `Upload CI JS deps artifact` in `prepare-ci-js-deps`
  2. `Download CI JS deps artifact` + `Extract CI JS deps` in each of the 3 consumer jobs

Delete those blocks. No changes needed to `setup-ci-js-deps/action.yml`.

Manual testing steps

```gherkin
Given a pull request runs CI on a non-Namespace runner (ubuntu-latest)
When prepare-ci-js-deps completes
Then a ci-js-deps.tar.gz artifact is uploaded
And each unit-tests and component-view-tests shard downloads and extracts it
And all shards skip yarn install and pass

Given a pull request runs CI on a Namespace runner
When prepare-ci-js-deps completes on a warm cache volume
Then all consumer shards mount the cache volume and skip yarn install
And all shards pass

Given the Namespace cache volume is cold (yarn.lock changed)
When prepare-ci-js-deps runs
Then it installs dependencies and warms the volume
And all consumer shards hit the warm volume and skip install
```

References

  • ADR: `docs/ci-dependency-setup-reuse-adr.md`
  • Related action: `.github/actions/restore-node-modules-permissions`

Note

Medium Risk
Changes CI job dependencies and dependency-caching behavior for unit/component-view shards; misconfiguration could cause flaky installs or missing artifacts, but impact is limited to CI execution.

Overview
Reduces redundant JS dependency setup across CI test shards. Adds a new composite action setup-ci-js-deps that configures Namespace cache, sets up Node, and conditionally runs yarn install --immutable + yarn setup:github-ci --node based on workspace freshness.

Introduces a prepare-ci-js-deps job that runs once before unit-tests, component-view-tests, and merge-unit-and-component-view-tests to warm Namespace shared cache; for non-Namespace runners it packs and uploads a short-lived ci-js-deps artifact that consumer shards download/extract to skip their own installs.

Updates test/merge jobs to depend on prepare-ci-js-deps, replaces their inline dependency setup with the new action + temporary artifact restore steps, tightens if conditions to require successful get_requirements, and adds prepare-ci-js-deps to the check-all-jobs-pass gate.

Reviewed by Cursor Bugbot for commit d9e8501. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

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.

@metamaskbotv2 metamaskbotv2 Bot added the team-mobile-platform Mobile Platform team label May 13, 2026
@tommasini tommasini marked this pull request as ready for review May 13, 2026 12:41
@tommasini tommasini requested a review from a team as a code owner May 13, 2026 12:41
Comment thread .github/actions/consume-ci-js-deps/action.yml Outdated
Comment thread .github/workflows/setup-node-modules.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Remove four opt-in inputs added to setup-node-modules.yml
(setup-command, use-exact-artifact-name, include-yarn-install-state,
include-inpage-bridge-artifacts) and revert the workflow to its
original interface.

The prepare-ci-js-deps producer now calls setup-node-modules.yml with
only artifact-name, artifact-retention-days, and runner_provider,
matching how push-eas-update.yml already consumes the same reusable
workflow.

Consumer jobs (unit-tests, component-view-tests,
merge-unit-and-component-view-tests) now reference the artifact via
needs.prepare-ci-js-deps.outputs.artifact-name instead of the
hardcoded name, matching the established pattern in
push-eas-update.yml.\
@tommasini tommasini added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label May 13, 2026
@metamaskbotv2 metamaskbotv2 Bot added the INVALID-PR-TEMPLATE PR's body doesn't match template label May 13, 2026
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/actions/setup-ci-js-deps/action.yml
Comment thread .github/workflows/ci.yml
@tommasini tommasini changed the title ci: reuse JS dependency setup across unit/component-view test shards (Phase 1) ci: pre-warm Namespace cache for unit/component-view test shards May 13, 2026
Comment thread .github/actions/setup-ci-js-deps/action.yml
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 7c8ed8d. Configure here.

Comment thread .github/workflows/ci.yml Outdated
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

E2E Test Selection:
The two changed files are purely CI infrastructure changes with no impact on application code or E2E test logic:

  1. .github/actions/setup-ci-js-deps/action.yml - A NEW composite GitHub Action that centralizes JS dependency setup (Namespace cache config, Node.js setup, yarn install with retry, project setup). This is a pure CI refactoring.

  2. .github/workflows/ci.yml - Refactors the CI pipeline to:

    • Add a new prepare-ci-js-deps job that installs dependencies once and either warms the Namespace shared cache volume or uploads a tarball artifact for non-Namespace runners
    • Update unit-tests, component-view-tests, and merge-unit-and-component-view-tests jobs to use the new composite action and download the artifact instead of each installing independently
    • Improve if conditions with !cancelled() and result == 'success' patterns
    • Add prepare-ci-js-deps to the final status check

These changes are a CI optimization/refactoring to reduce redundant dependency installations across parallel jobs. No application source code, E2E test files, test page objects, test fixtures, or app functionality was modified. Running E2E tests would not validate these CI infrastructure changes and would be wasteful. No performance tests are needed either since no app code was changed.

Performance Test Selection:
No application code was changed. These are pure CI infrastructure changes affecting how JS dependencies are installed and cached across CI jobs. No performance impact on the app itself.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tommasini tommasini added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit b30bd2a May 15, 2026
157 checks passed
@tommasini tommasini deleted the ci/reuse-js-deps-ci branch May 15, 2026 21:57
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-M team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants