Skip to content

Commit 857f1ec

Browse files
JPeer264claude
andauthored
ci: Keep Namespace cache volumes complete and cache the pnpm binary (#25569)
This gives the E2E jobs their own Namespace cache tag and removes the tag from jobs that do not use a cache. A new `mount-pnpm-store` action mounts the pnpm store and the npm cache before `install-pnpm`, so pnpm itself also comes from the cache volume. ## Why Namespace keeps the volume of the last job that exits cleanly. E2E jobs and jobs without cache use often finished last, so Build got no `node_modules` in about 8 of 10 runs. `pnpm self-update` also downloaded pnpm in every job, which took up to 130s. ## Cache decisions `cache: pnpm` runs pnpm, so it cannot come before `install-pnpm`. Until Namespace changes this, `mount-pnpm-store` sets `PNPM_CONFIG_STORE_DIR` itself. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 3f00b10 commit 857f1ec

3 files changed

Lines changed: 53 additions & 30 deletions

File tree

‎.github/actions/install-dependencies/action.yml‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ description: 'Installs pnpm dependencies into node_modules folders on the Namesp
44
runs:
55
using: 'composite'
66
steps:
7-
- name: Install pnpm
8-
uses: ./.github/actions/install-pnpm
9-
107
- name: List dependency paths
118
id: paths
129
run: |
@@ -19,11 +16,13 @@ runs:
1916
shell: bash
2017

2118
- name: Mount dependency cache
22-
uses: namespacelabs/nscloud-cache-action@1124a6f3ce44e5cf84cc22111530961f4d2a15f9 # v1.7.0
19+
uses: ./.github/actions/mount-pnpm-store
2320
with:
24-
cache: pnpm
2521
path: ${{ steps.paths.outputs.paths }}
2622

23+
- name: Install pnpm
24+
uses: ./.github/actions/install-pnpm
25+
2726
# The cache volume can hold node_modules of another commit or branch. This is a no-op when they match
2827
# pnpm-lock.yaml.
2928
- name: Install dependencies
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Mount pnpm store'
2+
description:
3+
'Mounts the pnpm store, the pnpm and npm caches and the given paths from the Namespace cache volume. Use it before
4+
`install-pnpm`, so `install-pnpm` takes pnpm from the cache volume.'
5+
6+
inputs:
7+
path:
8+
description: 'Paths to mount from the cache volume in addition to the pnpm store and caches, one per line.'
9+
required: false
10+
default: ''
11+
12+
runs:
13+
using: 'composite'
14+
steps:
15+
# Replaces the `pnpm` mode of nscloud-cache-action until it works without pnpm on PATH. The mode runs `pnpm store
16+
# path`, so it only works after `install-pnpm`, when `pnpm self-update` has already downloaded pnpm.
17+
# The cache directory holds `lockfile-verified.jsonl`. With it, `pnpm install` skips the supply-chain check of a
18+
# lockfile that was already verified, which otherwise fetches the metadata of every package from the registry.
19+
- name: Set pnpm store and cache directories
20+
run: |
21+
echo "PNPM_CONFIG_STORE_DIR=$HOME/.cache/pnpm-store" >> "$GITHUB_ENV"
22+
echo "PNPM_CONFIG_CACHE_DIR=$HOME/.cache/pnpm" >> "$GITHUB_ENV"
23+
shell: bash
24+
25+
# The `npm` mode keeps the npm cache of the `npm ci` in `pnpm/action-setup`, which installs the bootstrap pnpm
26+
- name: Mount cache paths
27+
uses: namespacelabs/nscloud-cache-action@1124a6f3ce44e5cf84cc22111530961f4d2a15f9 # v1.7.0
28+
with:
29+
cache: npm
30+
path: |
31+
~/.cache/pnpm-store
32+
~/.cache/pnpm
33+
${{ inputs.path }}

‎.github/workflows/build.yml‎

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ env:
5252
# This option both controls the `v8-compile-cache-lib` and `v8-compile-cache` packages.
5353
DISABLE_V8_COMPILE_CACHE: '1'
5454

55-
# All jobs share one Namespace cache volume through `overrides.cache-tag`. Pull request jobs get their own volume
56-
# (`-pr`), so they cannot change the node_modules that develop and release builds install from.
55+
# Jobs that install the monorepo dependencies share one Namespace cache volume through `overrides.cache-tag`, E2E jobs
56+
# share another one (`-e2e`). Jobs that do not use a cache volume have no cache tag. Pull request jobs get their own
57+
# volumes (`-pr`), so they cannot change the node_modules that develop and release builds install from.
5758
jobs:
5859
job_get_metadata:
5960
uses: ./.github/workflows/ci-metadata.yml
@@ -268,9 +269,7 @@ jobs:
268269
job_check_branches:
269270
name: Check PR branches
270271
needs: job_get_metadata
271-
runs-on:
272-
namespace-profile-sentry-javascript-small;overrides.cache-tag=sentry-javascript${{ github.event_name ==
273-
'pull_request' && '-pr' || '' }}
272+
runs-on: namespace-profile-sentry-javascript-small
274273
if: github.event_name == 'pull_request'
275274
permissions:
276275
pull-requests: write
@@ -354,9 +353,7 @@ jobs:
354353
name: Check lockfile
355354
needs: [job_get_metadata]
356355
timeout-minutes: 10
357-
runs-on:
358-
namespace-profile-sentry-javascript;overrides.cache-tag=sentry-javascript${{ github.event_name == 'pull_request'
359-
&& '-pr' || '' }}
356+
runs-on: namespace-profile-sentry-javascript
360357
if: |
361358
needs.job_get_metadata.outputs.changed_deps == 'true' ||
362359
needs.job_get_metadata.outputs.is_base_branch == 'true' ||
@@ -1054,8 +1051,8 @@ jobs:
10541051
always() && needs.job_build_tarballs.result == 'success' && needs.job_build.outputs.e2e-matrix !='{"include":[]}'
10551052
needs: [job_get_metadata, job_build, job_build_layer, job_build_tarballs]
10561053
runs-on:
1057-
namespace-profile-sentry-javascript;overrides.cache-tag=sentry-javascript${{ github.event_name == 'pull_request'
1058-
&& '-pr' || '' }}
1054+
namespace-profile-sentry-javascript;overrides.cache-tag=sentry-javascript-e2e${{ github.event_name ==
1055+
'pull_request' && '-pr' || '' }}
10591056
timeout-minutes: 15
10601057
env:
10611058
# We just use a dummy DSN here, only send to the tunnel anyhow
@@ -1100,13 +1097,11 @@ jobs:
11001097
uses: denoland/setup-deno@v2.0.5
11011098
with:
11021099
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
1103-
- name: Install pnpm
1104-
uses: ./.github/actions/install-pnpm
11051100
# Keeps the pnpm store on the cache volume for the `pnpm install` of the test application
11061101
- name: Mount pnpm store
1107-
uses: namespacelabs/nscloud-cache-action@1124a6f3ce44e5cf84cc22111530961f4d2a15f9 # v1.7.0
1108-
with:
1109-
cache: pnpm
1102+
uses: ./.github/actions/mount-pnpm-store
1103+
- name: Install pnpm
1104+
uses: ./.github/actions/install-pnpm
11101105

11111106
- name: Restore tarball artifacts
11121107
uses: actions/download-artifact@v8
@@ -1202,8 +1197,8 @@ jobs:
12021197
github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]'
12031198
needs: [job_get_metadata, job_build, job_build_tarballs]
12041199
runs-on:
1205-
namespace-profile-sentry-javascript;overrides.cache-tag=sentry-javascript${{ github.event_name == 'pull_request'
1206-
&& '-pr' || '' }}
1200+
namespace-profile-sentry-javascript;overrides.cache-tag=sentry-javascript-e2e${{ github.event_name ==
1201+
'pull_request' && '-pr' || '' }}
12071202
timeout-minutes: 15
12081203
env:
12091204
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
@@ -1251,13 +1246,11 @@ jobs:
12511246
uses: denoland/setup-deno@v2.0.5
12521247
with:
12531248
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
1254-
- name: Install pnpm
1255-
uses: ./.github/actions/install-pnpm
12561249
# Keeps the pnpm store on the cache volume for the `pnpm install` of the test application
12571250
- name: Mount pnpm store
1258-
uses: namespacelabs/nscloud-cache-action@1124a6f3ce44e5cf84cc22111530961f4d2a15f9 # v1.7.0
1259-
with:
1260-
cache: pnpm
1251+
uses: ./.github/actions/mount-pnpm-store
1252+
- name: Install pnpm
1253+
uses: ./.github/actions/install-pnpm
12611254

12621255
- name: Restore tarball artifacts
12631256
uses: actions/download-artifact@v8
@@ -1343,9 +1336,7 @@ jobs:
13431336
]
13441337
# Always run this, even if a dependent job failed
13451338
if: always()
1346-
runs-on:
1347-
namespace-profile-sentry-javascript-small;overrides.cache-tag=sentry-javascript${{ github.event_name ==
1348-
'pull_request' && '-pr' || '' }}
1339+
runs-on: namespace-profile-sentry-javascript-small
13491340
permissions: {}
13501341
steps:
13511342
- name: Check for failures

0 commit comments

Comments
 (0)