|
1 | 1 | name: Setup |
| 2 | + |
2 | 3 | description: Install pnpm, Node.js, and project dependencies. |
3 | 4 |
|
| 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 | + |
4 | 13 | runs: |
5 | 14 | using: composite |
6 | 15 | steps: |
|
9 | 18 | # Needed for git-based deps (e.g. github:coder/coder) so pnpm can clone without SSH. |
10 | 19 | run: git config --global url."https://github.com/".insteadOf "git@github.com:" |
11 | 20 |
|
12 | | - - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 |
| 21 | + - uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0 |
13 | 22 | 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" |
18 | 34 |
|
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 |
20 | 40 | 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 }}- |
22 | 44 |
|
23 | | - - name: Install dependencies |
| 45 | + - name: Prune unreferenced store packages |
| 46 | + if: inputs.cache-save == 'true' |
24 | 47 | 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 }} |
0 commit comments