Skip to content

Commit a4c8715

Browse files
committed
ci: cache the pnpm store and Turborepo output
The workflow had no caching at all, so every job downloaded the whole dependency graph from scratch and every job rebuilt every package from scratch, even when nothing relevant had changed. Extract the repeated setup into a composite action that installs pnpm before Node (so actions/setup-node can locate the pnpm store to cache), installs with --frozen-lockfile, and restores .turbo/cache. Turborepo only reuses output when a task's inputs hash the same, so the turbo cache cannot go stale. On the last green run this restores the pnpm store in the four heavy jobs (cold installs took 7s-22s each) and gives repeat runs, including every push to a PR branch, warm build and test results.
1 parent 324b102 commit a4c8715

2 files changed

Lines changed: 31 additions & 20 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Setup
2+
description: Install Node.js, pnpm and workspace dependencies, with the pnpm store and Turborepo caches restored.
3+
4+
inputs:
5+
node-version:
6+
description: Node.js version to install
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
# install pnpm first so actions/setup-node can locate the store to cache
13+
- uses: pnpm/action-setup@v5
14+
- uses: actions/setup-node@v6
15+
with:
16+
node-version: ${{ inputs.node-version }}
17+
cache: pnpm
18+
- run: pnpm install --frozen-lockfile
19+
shell: bash
20+
# Turborepo reuses task output when a task's inputs hash the same; caching
21+
# .turbo/cache lets later runs (and later commits) skip rebuilds.
22+
- uses: actions/cache@v4
23+
with:
24+
path: .turbo/cache
25+
key: turbo-${{ runner.os }}-${{ inputs.node-version }}-${{ github.sha }}
26+
restore-keys: turbo-${{ runner.os }}-${{ inputs.node-version }}-

.github/workflows/ci.yml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v6
19-
- uses: actions/setup-node@v6
19+
- uses: ./.github/actions/setup
2020
with:
2121
node-version: latest
22-
- uses: pnpm/action-setup@v5
23-
with:
24-
run_install: true
2522
- run: pnpm run lint
2623
test-node-versions:
2724
runs-on: ubuntu-latest
@@ -30,12 +27,9 @@ jobs:
3027
node-version: [22, 24]
3128
steps:
3229
- uses: actions/checkout@v6
33-
- uses: actions/setup-node@v6
30+
- uses: ./.github/actions/setup
3431
with:
3532
node-version: ${{ matrix.node-version }}
36-
- uses: pnpm/action-setup@v5
37-
with:
38-
run_install: true
3933
- run: pnpm test
4034
test-e2e:
4135
runs-on: ubuntu-latest
@@ -54,12 +48,9 @@ jobs:
5448
timeout-minutes: 15
5549
steps:
5650
- uses: actions/checkout@v6
57-
- uses: actions/setup-node@v6
51+
- uses: ./.github/actions/setup
5852
with:
5953
node-version: 22
60-
- uses: pnpm/action-setup@v5
61-
with:
62-
run_install: true
6354
- run: pnpm run test-e2e
6455
env:
6556
# Firefox refuses to start as root unless $HOME is owned by root, and
@@ -70,21 +61,15 @@ jobs:
7061
runs-on: macos-latest
7162
steps:
7263
- uses: actions/checkout@v6
73-
- uses: actions/setup-node@v6
64+
- uses: ./.github/actions/setup
7465
with:
7566
node-version: latest
76-
- uses: pnpm/action-setup@v5
77-
with:
78-
run_install: true
7967
- run: pnpm test
8068
test-windows:
8169
runs-on: windows-latest
8270
steps:
8371
- uses: actions/checkout@v6
84-
- uses: actions/setup-node@v6
72+
- uses: ./.github/actions/setup
8573
with:
8674
node-version: latest
87-
- uses: pnpm/action-setup@v5
88-
with:
89-
run_install: true
9075
- run: pnpm test

0 commit comments

Comments
 (0)