Skip to content

Commit 892fcc0

Browse files
committed
ci: migrate setup to pnpm/setup
Replace pnpm/action-setup + actions/setup-node + manual install step with pnpm/setup v3.0.0 (SHA-pinned), which installs pnpm, provisions Node 22 via pnpm runtime set, and runs pnpm install --frozen-lockfile (require-lockfile: true). Also migrates publish-extension.yaml's standalone setup-node usages. The store cache is a restore/save split around actions/cache, the same policy as the Chromium cache: every branch restores (lockfile-hash key, platform prefix fallback so a dependency bump reuses the rest of the store), only the default branch and releases save. pnpm/setup's own cache: true saves per job per run (pnpm/setup#55, pnpm/setup#56), and v2.1.0's runtime-hashed primary key is never matched by its runtime-less restore probe, so every job saved on every run. Measured on this PR's CI with pnpm/setup caching (setup step, warm): Windows 32-37s vs 56-85s baseline, Linux 8-13s. The split keeps those restore times and drops PR post steps to ~1s. Closes #1119
1 parent f096fe1 commit 892fcc0

6 files changed

Lines changed: 64 additions & 15 deletions

File tree

‎.github/actions/setup/action.yml‎

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
name: Setup
2+
23
description: Install pnpm, Node.js, and project dependencies.
34

5+
inputs:
6+
cache-save:
7+
description: >-
8+
Save the pnpm store cache after the job. Restores always run; only the
9+
default branch saves, so PR runs cannot race one shared key or evict
10+
each other's stores from the cache quota.
11+
default: "false"
12+
413
runs:
514
using: composite
615
steps:
@@ -9,17 +18,38 @@ runs:
918
# Needed for git-based deps (e.g. github:coder/coder) so pnpm can clone without SSH.
1019
run: git config --global url."https://github.com/".insteadOf "git@github.com:"
1120

12-
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
21+
- uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
1322
with:
14-
# Caches the pnpm store, keyed by lockfile hash with a prefix fallback,
15-
# so a dependency bump reuses the rest of the store. setup-node's own
16-
# pnpm cache restores on an exact hash only.
17-
cache: true
23+
runtime: node@22
24+
# The store cache is handled by the actions/cache steps below, which
25+
# unlike this action's `cache: true` can save only on the default
26+
# branch (pnpm/setup#56 tracks a restore-only mode).
27+
cache: false
28+
require-lockfile: true
29+
30+
- name: Get pnpm store path
31+
id: pnpm-store
32+
shell: bash
33+
run: echo "path=$(pnpm store path)" >> "$GITHUB_OUTPUT"
1834

19-
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
35+
# Restores on every branch; saves only where cache-save is set (the
36+
# default branch). Same policy as the Chromium cache in ci.yaml.
37+
- name: Restore pnpm store cache
38+
id: store-cache
39+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
2040
with:
21-
node-version: "22"
41+
path: ${{ steps.pnpm-store.outputs.path }}
42+
key: pnpm-store-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
43+
restore-keys: pnpm-store-${{ runner.os }}-${{ runner.arch }}-
2244

23-
- name: Install dependencies
45+
- name: Prune unreferenced store packages
46+
if: inputs.cache-save == 'true'
2447
shell: bash
25-
run: pnpm install --frozen-lockfile
48+
run: pnpm store prune
49+
50+
- name: Save pnpm store cache
51+
if: inputs.cache-save == 'true' && steps.store-cache.outputs.cache-hit != 'true'
52+
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
53+
with:
54+
path: ${{ steps.pnpm-store.outputs.path }}
55+
key: ${{ steps.store-cache.outputs.cache-primary-key }}

‎.github/workflows/ci.yaml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
persist-credentials: false
2424
- name: Setup pnpm, Node.js, and dependencies
2525
uses: ./.github/actions/setup
26+
with:
27+
# Only the default branch saves the store cache.
28+
cache-save: ${{ github.ref == 'refs/heads/main' }}
2629

2730
- run: pnpm typecheck
2831

@@ -61,6 +64,8 @@ jobs:
6164
persist-credentials: false
6265
- name: Setup pnpm, Node.js, and dependencies
6366
uses: ./.github/actions/setup
67+
with:
68+
cache-save: ${{ github.ref == 'refs/heads/main' }}
6469

6570
- name: Run tests with Electron ${{ matrix.electron-version }}
6671
run: ./scripts/test-electron.sh ${{ matrix.electron-version }}
@@ -87,6 +92,8 @@ jobs:
8792
persist-credentials: false
8893
- name: Setup pnpm, Node.js, and dependencies
8994
uses: ./.github/actions/setup
95+
with:
96+
cache-save: ${{ github.ref == 'refs/heads/main' }}
9097

9198
- run: pnpm build
9299

@@ -106,6 +113,8 @@ jobs:
106113
persist-credentials: false
107114
- name: Setup pnpm, Node.js, and dependencies
108115
uses: ./.github/actions/setup
116+
with:
117+
cache-save: ${{ github.ref == 'refs/heads/main' }}
109118

110119
- name: Get Playwright version
111120
id: playwright-version
@@ -151,6 +160,8 @@ jobs:
151160
persist-credentials: false
152161
- name: Setup pnpm, Node.js, and dependencies
153162
uses: ./.github/actions/setup
163+
with:
164+
cache-save: ${{ github.ref == 'refs/heads/main' }}
154165

155166
- name: Get version from package.json
156167
id: version

‎.github/workflows/pre-release.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020

2121
- name: Setup pnpm, Node.js, and dependencies
2222
uses: ./.github/actions/setup
23+
with:
24+
cache-save: true
2325

2426
- name: Extract version from tag
2527
id: version

‎.github/workflows/publish-extension.yaml‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ jobs:
3434
with:
3535
persist-credentials: false
3636

37-
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
37+
- uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
3838
with:
39-
node-version: "22"
39+
runtime: node@22
4040

4141
- name: Construct package name
4242
id: package
@@ -77,9 +77,10 @@ jobs:
7777
contents: read
7878
if: ${{ needs.setup.outputs.hasVscePat == 'true' }}
7979
steps:
80-
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
80+
- uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
8181
with:
82-
node-version: "22"
82+
runtime: node@22
83+
install: false
8384

8485
- name: Install vsce
8586
env:
@@ -110,9 +111,10 @@ jobs:
110111
contents: read
111112
if: ${{ needs.setup.outputs.hasOvsxPat == 'true' }}
112113
steps:
113-
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
114+
- uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
114115
with:
115-
node-version: "22"
116+
runtime: node@22
117+
install: false
116118

117119
- name: Install ovsx
118120
run: npm install -g ovsx@1.2.0

‎.github/workflows/release.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
3030
- name: Setup pnpm, Node.js, and dependencies
3131
uses: ./.github/actions/setup
32+
with:
33+
# Release runs refresh the store cache.
34+
cache-save: true
3235

3336
- name: Extract version from tag
3437
id: version

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ When updating the minimum Node.js version, update these files:
319319
- **tsconfig.json**: `extends` (the `@tsconfig/nodeXX` package), `lib` (match base ESNext version)
320320
- **esbuild.mjs**: `target`
321321
- **.github/workflows/ci.yaml**: `electron-version` and `vscode-version` matrices
322+
- **.github/workflows/publish-extension.yaml**, **.github/actions/setup/action.yml**: `runtime: node@XX`
322323

323324
## Dependencies
324325

0 commit comments

Comments
 (0)