Skip to content

Commit d4c86d6

Browse files
authored
chore(ci): move turbo caching to actions/cache via shared setup action (#2546)
1 parent e09a310 commit d4c86d6

8 files changed

Lines changed: 55 additions & 122 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Setup
2+
description: pnpm + node + install, with optional Turbo cache. Run after checkout.
3+
inputs:
4+
node-version:
5+
description: Override node version; empty uses .nvmrc
6+
default: ''
7+
registry-url:
8+
description: npm registry URL (release jobs only)
9+
default: ''
10+
turbo-cache:
11+
description: Restore/save the .turbo cache (build jobs only)
12+
default: 'false'
13+
runs:
14+
using: composite
15+
steps:
16+
- uses: pnpm/action-setup@v6
17+
18+
- uses: actions/setup-node@v6
19+
with:
20+
node-version: ${{ inputs.node-version }}
21+
node-version-file: ${{ inputs.node-version == '' && '.nvmrc' || '' }}
22+
registry-url: ${{ inputs.registry-url }}
23+
cache: pnpm
24+
25+
- name: Install
26+
run: pnpm install --frozen-lockfile
27+
shell: bash
28+
29+
- name: Cache turbo
30+
if: ${{ inputs.turbo-cache == 'true' }}
31+
uses: actions/cache@v5
32+
with:
33+
path: .turbo
34+
key: ${{ runner.os }}-turbo-${{ github.sha }}
35+
restore-keys: |
36+
${{ runner.os }}-turbo-

.github/workflows/bundle-size.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ on:
55
branches:
66
- main
77

8-
env:
9-
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
10-
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
11-
128
concurrency:
139
group: ${{ github.workflow }}-${{ github.ref_name }}
1410
cancel-in-progress: true
@@ -22,16 +18,9 @@ jobs:
2218
- name: Checkout repo
2319
uses: actions/checkout@v6
2420

25-
- name: Setup pnpm
26-
uses: pnpm/action-setup@v6
27-
28-
- uses: actions/setup-node@v6
21+
- uses: ./.github/actions/setup
2922
with:
30-
node-version-file: '.nvmrc'
31-
cache: 'pnpm'
32-
33-
- name: Install
34-
run: pnpm install --frozen-lockfile
23+
turbo-cache: 'true'
3524

3625
- name: Build packages
3726
run: pnpm build --filter=!@react-spring/docs

.github/workflows/checks.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ on:
66
- 'main'
77
pull_request: {}
88

9-
env:
10-
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
11-
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
12-
139
concurrency:
1410
group: ${{ github.workflow }}-${{ github.ref_name }}
1511
cancel-in-progress: true
@@ -27,17 +23,7 @@ jobs:
2723
- name: Checkout repo
2824
uses: actions/checkout@v6
2925

30-
- name: Setup pnpm
31-
uses: pnpm/action-setup@v6
32-
33-
- name: Setup node
34-
uses: actions/setup-node@v6
35-
with:
36-
node-version-file: '.nvmrc'
37-
cache: 'pnpm'
38-
39-
- name: Install
40-
run: pnpm install --frozen-lockfile
26+
- uses: ./.github/actions/setup
4127

4228
- name: Lint
4329
run: pnpm lint

.github/workflows/experimental.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: 'Experimental Releases'
33
on:
44
workflow_dispatch:
55

6-
env:
7-
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
8-
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
9-
106
concurrency:
117
group: ${{ github.workflow }}-${{ github.ref_name }}
128
cancel-in-progress: true
@@ -30,16 +26,9 @@ jobs:
3026
- name: Setup npmrc
3127
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
3228

33-
- name: Setup pnpm
34-
uses: pnpm/action-setup@v6
35-
36-
- uses: actions/setup-node@v6
29+
- uses: ./.github/actions/setup
3730
with:
38-
node-version-file: '.nvmrc'
39-
cache: 'pnpm'
40-
41-
- name: Install
42-
run: pnpm install --frozen-lockfile
31+
turbo-cache: 'true'
4332

4433
- name: Build
4534
run: pnpm build-ci

.github/workflows/nightly.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ on:
44
schedule:
55
- cron: '0 0 * * *'
66

7-
env:
8-
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
9-
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
10-
117
concurrency:
128
group: ${{ github.workflow }}-${{ github.ref_name }}
139
cancel-in-progress: true
@@ -53,19 +49,10 @@ jobs:
5349
exit 0
5450
fi
5551
56-
- name: Setup pnpm
57-
if: steps.version.outputs.NEXT_VERSION
58-
uses: pnpm/action-setup@v6
59-
60-
- uses: actions/setup-node@v6
52+
- uses: ./.github/actions/setup
6153
if: steps.version.outputs.NEXT_VERSION
6254
with:
63-
node-version-file: '.nvmrc'
64-
cache: 'pnpm'
65-
66-
- name: Install
67-
if: steps.version.outputs.NEXT_VERSION
68-
run: pnpm install --frozen-lockfile
55+
turbo-cache: 'true'
6956

7057
- name: Build
7158
if: steps.version.outputs.NEXT_VERSION

.github/workflows/release.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ on:
66
- 'next'
77
workflow_dispatch:
88

9-
env:
10-
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
11-
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
12-
139
concurrency:
1410
group: ${{ github.workflow }}-${{ github.ref_name }}
1511
cancel-in-progress: false
@@ -31,23 +27,15 @@ jobs:
3127
with:
3228
fetch-depth: 0
3329

34-
- name: Setup pnpm
35-
uses: pnpm/action-setup@v6
36-
37-
- name: Setup node
38-
uses: actions/setup-node@v6
30+
- uses: ./.github/actions/setup
3931
with:
40-
node-version-file: '.nvmrc'
41-
cache: 'pnpm'
4232
registry-url: 'https://registry.npmjs.org'
33+
turbo-cache: 'true'
4334

4435
# npm Trusted Publishing requires npm >= 11.5.1; Node 22 LTS still ships npm 10.x
4536
- name: Upgrade npm
4637
run: npm install -g npm@latest
4738

48-
- name: Install
49-
run: pnpm install --frozen-lockfile
50-
5139
- name: Build
5240
run: pnpm build-ci
5341

.github/workflows/tests.yml

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ on:
66
- 'main'
77
pull_request: {}
88

9-
env:
10-
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
11-
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
12-
139
concurrency:
1410
group: ${{ github.workflow }}-${{ github.ref_name }}
1511
cancel-in-progress: true
@@ -35,6 +31,7 @@ jobs:
3531
- 'vitest.config.ts'
3632
- '.github/publish-ci/**/package-lock.json'
3733
- '.github/workflows/*.yml'
34+
- '.github/actions/**'
3835
- 'package.json'
3936
build:
4037
needs: changes
@@ -46,17 +43,9 @@ jobs:
4643
- name: Checkout repo
4744
uses: actions/checkout@v6
4845

49-
- name: Setup pnpm
50-
uses: pnpm/action-setup@v6
51-
52-
- name: Setup node
53-
uses: actions/setup-node@v6
46+
- uses: ./.github/actions/setup
5447
with:
55-
node-version-file: '.nvmrc'
56-
cache: 'pnpm'
57-
58-
- name: Install
59-
run: pnpm install --frozen-lockfile
48+
turbo-cache: 'true'
6049

6150
- name: Build
6251
run: pnpm build-ci --filter=!@react-spring/docs
@@ -96,7 +85,7 @@ jobs:
9685

9786
test-unit:
9887
name: 'Test:unit'
99-
needs: [build]
88+
needs: [changes]
10089
if: ${{ needs.changes.outputs.packages == 'true' }}
10190
runs-on: ubuntu-latest
10291
strategy:
@@ -107,20 +96,9 @@ jobs:
10796
- name: Checkout repo
10897
uses: actions/checkout@v6
10998

110-
- name: Setup pnpm
111-
uses: pnpm/action-setup@v6
112-
113-
- name: Setup node ${{ matrix.node }}
114-
uses: actions/setup-node@v6
99+
- uses: ./.github/actions/setup
115100
with:
116101
node-version: ${{ matrix.node }}
117-
cache: 'pnpm'
118-
119-
- name: Install
120-
run: pnpm install --frozen-lockfile
121-
122-
- name: Build
123-
run: pnpm build-ci
124102

125103
- name: Cache Playwright browsers
126104
uses: actions/cache@v5
@@ -136,7 +114,7 @@ jobs:
136114

137115
test-types:
138116
name: 'Test:types with TS ${{ matrix.ts }}'
139-
needs: [build]
117+
needs: [changes]
140118
if: ${{ needs.changes.outputs.packages == 'true' }}
141119
runs-on: ubuntu-latest
142120
strategy:
@@ -147,17 +125,7 @@ jobs:
147125
- name: Checkout repo
148126
uses: actions/checkout@v6
149127

150-
- name: Setup pnpm
151-
uses: pnpm/action-setup@v6
152-
153-
- name: Setup node
154-
uses: actions/setup-node@v6
155-
with:
156-
node-version-file: '.nvmrc'
157-
cache: 'pnpm'
158-
159-
- name: Install
160-
run: pnpm install --frozen-lockfile
128+
- uses: ./.github/actions/setup
161129

162130
- name: Install TypeScript ${{ matrix.ts }}
163131
run: pnpm add -w typescript@${{ matrix.ts }}
@@ -176,7 +144,7 @@ jobs:
176144

177145

178146
test-e2e:
179-
needs: [build]
147+
needs: [changes]
180148
if: ${{ needs.changes.outputs.packages == 'true' }}
181149
name: 'Test:E2E'
182150
runs-on: ubuntu-latest
@@ -185,17 +153,7 @@ jobs:
185153
- name: Checkout repo
186154
uses: actions/checkout@v6
187155

188-
- name: Setup pnpm
189-
uses: pnpm/action-setup@v6
190-
191-
- name: Setup node
192-
uses: actions/setup-node@v6
193-
with:
194-
node-version: '24.16.0'
195-
cache: 'pnpm'
196-
197-
- name: Install
198-
run: pnpm install --frozen-lockfile
156+
- uses: ./.github/actions/setup
199157

200158
- name: Cache Playwright browsers
201159
uses: actions/cache@v5

turbo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build": {
1313
"outputs": ["dist/**", "public/build/**", "api/**"],
1414
"dependsOn": ["^build"],
15-
"inputs": ["src/**/*.tsx", "src/**/*.ts", "../../tsup.config.base.ts"]
15+
"inputs": ["src/**/*.tsx", "src/**/*.ts", "../../tsdown.config.base.mjs"]
1616
},
1717
"pack": {}
1818
}

0 commit comments

Comments
 (0)