Skip to content

Commit 967d357

Browse files
alucardzomjluque0101cursoragent
authored
ci(INFRA-3593): Phase 1 — Namespace cache for Linux CI trial (MetaMask#29716)
## **Description** INFRA-3593 Phase 1 — adds Namespace Cache Volumes integration to the Linux CI jobs on the `namespace-runner-trial` branch. When `runner_provider: namespace` is dispatched, the 8 Linux CI jobs that install dependencies now: 1. Mount a Namespace Cache Volume via `nscloud-cache-action` covering `~/.cache/yarn`, `.metamask`, `node_modules`, `.yarn/cache`, and `.yarn/install-state.gz` 2. Skip `actions/setup-node` Yarn caching (set to empty string) to avoid duplicate network-backed cache traffic 3. Skip `actions/cache` for `node_modules` in `component-view-tests` and `merge-unit-and-component-view-tests` (Namespace cache already covers it) When `runner_provider: current` (the default on every existing trigger), all ternaries collapse to their prior values and behavior is byte-identical to the base branch. **No job is renamed. No default is changed.** This is an additive, opt-in change activated only via manual `workflow_dispatch` with `runner_provider: namespace`. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: INFRA-3593 (parent epic INFRA-3511) Refs: INFRA-3592 (Phase 0, PR MetaMask#29557) ## **Manual testing steps** ```gherkin Feature: Namespace Cache Volumes on Linux CI Scenario: dispatch with namespace provider — cache volumes active Given the branch phase1-namespace-linux-cache When user runs `gh workflow run ci.yml --ref phase1-namespace-linux-cache -f runner_provider=namespace` Then all 8 Linux CI jobs with dependencies use nscloud-cache-action And actions/setup-node Yarn caching is disabled (no duplicate cache traffic) And all jobs pass across every matrix shard (unit-tests x10, component-view-tests x2, scripts x6) Scenario: dispatch with current provider — byte-identical to base Given the branch phase1-namespace-linux-cache When user runs `gh workflow run ci.yml --ref phase1-namespace-linux-cache -f runner_provider=current` Then nscloud-cache-action steps are skipped (if condition is false) And actions/setup-node uses cache: yarn as before And actions/cache for node_modules runs as before And all jobs pass on GitHub-hosted runners Scenario: implicit current via PR/push trigger Given a push or pull_request event (no workflow_dispatch) Then inputs.runner_provider is undefined/empty And all ternaries collapse to existing behavior ``` ## **Screenshots/Recordings** ### **Before** N/A ### **After** N/A — CI infrastructure PR, no UI surface. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) N/A — workflow YAML only, no app code. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. Made with [Cursor](https://cursor.com) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches many GitHub Actions workflows to optionally switch runner labels and caching behavior, which could break CI execution or cause cache-related flakiness when enabled. Default behavior remains unchanged unless `runner_provider=namespace` is explicitly selected. > > **Overview** > Introduces a `runner_provider` input (with `workflow_dispatch` choices where relevant) to route jobs between existing runners and new `namespace-profile-*` runner labels across `ci.yml`, reusable build workflows, and E2E smoke/regression workflows. > > When `runner_provider=namespace`, Linux CI jobs that install dependencies mount Namespace cache volumes via `namespacelabs/nscloud-cache-action`, disable `actions/setup-node` Yarn caching, and skip `actions/cache`-based `node_modules` restores in coverage-merge/component-view jobs; Node memory limits are also reduced on Namespace runners. > > Updates `actionlint` configuration to allow the new Namespace runner profile labels. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 3a52111. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Jose Luque <jose.luque@consensys.net> Co-authored-by: José Manuel <6741785+jluque0101@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 99e4557 commit 967d357

1 file changed

Lines changed: 85 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 85 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,19 @@ jobs:
9494
- get_requirements
9595
steps:
9696
- uses: actions/checkout@v6
97+
- name: Configure Namespace cache
98+
if: ${{ inputs.runner_provider == 'namespace' }}
99+
uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0 # v1
100+
with:
101+
path: |
102+
~/.cache/yarn
103+
.metamask
104+
node_modules
105+
.yarn/cache
97106
- uses: actions/setup-node@v6
98107
with:
99108
node-version-file: '.nvmrc'
100-
cache: yarn
109+
cache: ${{ inputs.runner_provider != 'namespace' && 'yarn' || '' }}
101110
- name: Install Yarn dependencies with retry
102111
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
103112
with:
@@ -130,10 +139,19 @@ jobs:
130139
- get_requirements
131140
steps:
132141
- uses: actions/checkout@v6
142+
- name: Configure Namespace cache
143+
if: ${{ inputs.runner_provider == 'namespace' }}
144+
uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0 # v1
145+
with:
146+
path: |
147+
~/.cache/yarn
148+
.metamask
149+
node_modules
150+
.yarn/cache
133151
- uses: actions/setup-node@v6
134152
with:
135153
node-version-file: '.nvmrc'
136-
cache: yarn
154+
cache: ${{ inputs.runner_provider != 'namespace' && 'yarn' || '' }}
137155
- name: Install Yarn dependencies with retry
138156
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
139157
with:
@@ -170,10 +188,19 @@ jobs:
170188
- uses: actions/checkout@v6
171189
with:
172190
fetch-depth: 2
191+
- name: Configure Namespace cache
192+
if: ${{ inputs.runner_provider == 'namespace' }}
193+
uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0 # v1
194+
with:
195+
path: |
196+
~/.cache/yarn
197+
.metamask
198+
node_modules
199+
.yarn/cache
173200
- uses: actions/setup-node@v6
174201
with:
175202
node-version-file: '.nvmrc'
176-
cache: yarn
203+
cache: ${{ inputs.runner_provider != 'namespace' && 'yarn' || '' }}
177204
- name: Install Yarn dependencies with retry
178205
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
179206
with:
@@ -205,10 +232,19 @@ jobs:
205232
statuses: write
206233
steps:
207234
- uses: actions/checkout@v6
235+
- name: Configure Namespace cache
236+
if: ${{ inputs.runner_provider == 'namespace' }}
237+
uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0 # v1
238+
with:
239+
path: |
240+
~/.cache/yarn
241+
.metamask
242+
node_modules
243+
.yarn/cache
208244
- uses: actions/setup-node@v6
209245
with:
210246
node-version-file: '.nvmrc'
211-
cache: yarn
247+
cache: ${{ inputs.runner_provider != 'namespace' && 'yarn' || '' }}
212248
- name: Install Yarn dependencies with retry
213249
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
214250
with:
@@ -469,10 +505,19 @@ jobs:
469505
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
470506
steps:
471507
- uses: actions/checkout@v6
508+
- name: Configure Namespace cache
509+
if: ${{ inputs.runner_provider == 'namespace' }}
510+
uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0 # v1
511+
with:
512+
path: |
513+
~/.cache/yarn
514+
.metamask
515+
node_modules
516+
.yarn/cache
472517
- uses: actions/setup-node@v6
473518
with:
474519
node-version-file: '.nvmrc'
475-
cache: yarn
520+
cache: ${{ inputs.runner_provider != 'namespace' && 'yarn' || '' }}
476521
- name: Install Yarn dependencies with retry
477522
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
478523
with:
@@ -488,7 +533,7 @@ jobs:
488533
# in sync with the length of matrix.shard
489534
- run: yarn test:unit --shard=${{ matrix.shard }}/10 --forceExit --silent --coverageReporters=json --json --outputFile=tests/results/unit-test-results-${{ matrix.shard }}.json
490535
env:
491-
NODE_OPTIONS: --max_old_space_size=20480
536+
NODE_OPTIONS: ${{ inputs.runner_provider == 'namespace' && '--max_old_space_size=12288' || '--max_old_space_size=20480' }}
492537
- name: Rename coverage report and extract test count for this shard
493538
shell: bash
494539
run: |
@@ -520,7 +565,17 @@ jobs:
520565
if: ${{ !cancelled() && github.event_name != 'merge_group' }}
521566
steps:
522567
- uses: actions/checkout@v6
568+
- name: Configure Namespace cache
569+
if: ${{ inputs.runner_provider == 'namespace' }}
570+
uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0 # v1
571+
with:
572+
path: |
573+
~/.cache/yarn
574+
.metamask
575+
node_modules
576+
.yarn/cache
523577
- name: Restore node_modules cache
578+
if: ${{ inputs.runner_provider != 'namespace' }}
524579
id: cache-node-modules
525580
uses: actions/cache@v4
526581
with:
@@ -531,9 +586,9 @@ jobs:
531586
- uses: actions/setup-node@v6
532587
with:
533588
node-version-file: '.nvmrc'
534-
cache: yarn
589+
cache: ${{ inputs.runner_provider != 'namespace' && 'yarn' || '' }}
535590
- name: Install Yarn dependencies with retry
536-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
591+
if: ${{ inputs.runner_provider == 'namespace' || steps.cache-node-modules.outputs.cache-hit != 'true' }}
537592
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
538593
with:
539594
timeout_minutes: 10
@@ -641,7 +696,17 @@ jobs:
641696
shard: [1, 2]
642697
steps:
643698
- uses: actions/checkout@v6
699+
- name: Configure Namespace cache
700+
if: ${{ inputs.runner_provider == 'namespace' }}
701+
uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0 # v1
702+
with:
703+
path: |
704+
~/.cache/yarn
705+
.metamask
706+
node_modules
707+
.yarn/cache
644708
- name: Restore node_modules cache
709+
if: ${{ inputs.runner_provider != 'namespace' }}
645710
id: cache-node-modules
646711
uses: actions/cache@v4
647712
with:
@@ -652,9 +717,9 @@ jobs:
652717
- uses: actions/setup-node@v6
653718
with:
654719
node-version-file: '.nvmrc'
655-
cache: yarn
720+
cache: ${{ inputs.runner_provider != 'namespace' && 'yarn' || '' }}
656721
- name: Install Yarn dependencies with retry
657-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
722+
if: ${{ inputs.runner_provider == 'namespace' || steps.cache-node-modules.outputs.cache-hit != 'true' }}
658723
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
659724
with:
660725
timeout_minutes: 10
@@ -671,7 +736,7 @@ jobs:
671736
--json \
672737
--outputFile=tests/results/cv-test-results-${{ matrix.shard }}.json
673738
env:
674-
NODE_OPTIONS: --max-old-space-size=20480
739+
NODE_OPTIONS: ${{ inputs.runner_provider == 'namespace' && '--max-old-space-size=12288' || '--max-old-space-size=20480' }}
675740
- name: Rename coverage report and extract test count for this shard
676741
shell: bash
677742
run: |
@@ -860,6 +925,15 @@ jobs:
860925
- uses: actions/checkout@v6
861926
with:
862927
fetch-depth: 0 # SonarCloud needs a full checkout to perform necessary analysis
928+
- name: Configure Namespace cache
929+
if: ${{ inputs.runner_provider == 'namespace' }}
930+
uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0 # v1
931+
with:
932+
path: |
933+
~/.cache/yarn
934+
.metamask
935+
node_modules
936+
.yarn/cache
863937
- uses: actions/setup-node@v6
864938
with:
865939
node-version-file: '.nvmrc'

0 commit comments

Comments
 (0)