Skip to content

Commit 5a7277b

Browse files
authored
Improve CI performance (#231)
* cache node_modules * use windows-11-arm * add restore-keys * `@actions/glob` does not support `{...}` * add missing cache file * typescript-eslint does not recommend cache * update cache keys
1 parent c937d4a commit 5a7277b

3 files changed

Lines changed: 43 additions & 24 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 'Setup Node and node_modules cache'
2+
description: 'Setup Node.js and node_modules'
3+
inputs:
4+
node-version:
5+
description: 'Node.js version'
6+
required: true
7+
outputs:
8+
cache-hit:
9+
description: 'Whether node_modules cache was hit'
10+
value: ${{ steps.node-modules-cache.outputs.cache-hit }}
11+
runs:
12+
using: 'composite'
13+
steps:
14+
- uses: actions/setup-node@v4
15+
id: setup-node
16+
with:
17+
node-version: ${{ inputs.node-version }}
18+
- uses: actions/cache@v4
19+
id: node-modules-cache
20+
with:
21+
path: node_modules
22+
key: node-modules-${{ runner.arch }}-${{ runner.os }}-node-${{ steps.setup-node.outputs.node-version }}-npm-${{ hashFiles('**/package-lock.json') }}
23+
restore-keys: node-modules-${{ runner.arch }}-${{ runner.os }}-node-${{ steps.setup-node.outputs.node-version }}-npm-
24+
- run: npm install
25+
if: steps.node-modules-cache.outputs.cache-hit != 'true'
26+
shell: sh

.github/workflows/ci.yml

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,77 +14,70 @@ jobs:
1414
runs-on: ubuntu-24.04-arm
1515
steps:
1616
- uses: actions/checkout@v4
17-
- uses: actions/setup-node@v4
17+
- uses: ./.github/actions/setup-node-and-node-modules
1818
with:
1919
node-version: 22
20-
cache: 'npm'
2120
- uses: actions/cache@v4
2221
with:
2322
path: |
2423
node_modules/.cache/prettier/.prettier-cache
24+
packages/*/dist
25+
packages/*/tsconfig.build.tsbuildinfo
2526
tsconfig.tsbuildinfo
26-
packages/*/{dist,tsconfig.build.tsbuildinfo}
27-
.eslintcache
28-
key: toolcache-lint-${{ runner.os }}-${{ github.sha }}
29-
restore-keys: toolcache-lint-${{ runner.os }}
30-
- run: npm install
27+
key: lint-tools-${{ runner.arch }}-${{ runner.os }}-${{ github.sha }}
28+
restore-keys: lint-tools-${{ runner.arch }}-${{ runner.os }}
3129
- run: npm run lint
3230
build:
3331
runs-on: ubuntu-24.04-arm
3432
steps:
3533
- uses: actions/checkout@v4
36-
- uses: actions/setup-node@v4
34+
- uses: ./.github/actions/setup-node-and-node-modules
3735
with:
3836
node-version: 22
39-
cache: 'npm'
40-
- run: npm install
4137
- run: npm run build
4238
test:
4339
strategy:
4440
fail-fast: false
4541
matrix:
4642
node: [20, 22]
47-
os: [ubuntu-24.04-arm, windows-2025]
43+
os: [ubuntu-24.04-arm, windows-11-arm]
4844
runs-on: ${{ matrix.os }}
4945
steps:
5046
- uses: actions/checkout@v4
51-
- uses: actions/setup-node@v4
47+
- uses: ./.github/actions/setup-node-and-node-modules
5248
with:
5349
node-version: ${{ matrix.node }}
54-
cache: 'npm'
5550
- uses: actions/cache@v4
5651
with:
5752
path: node_modules/.vite/vitest
58-
key: toolcache-test-${{ runner.os }}-node${{ matrix.node }}-${{ github.sha }}
59-
restore-keys: toolcache-test-${{ runner.os }}-node${{ matrix.node }}
60-
- run: npm install
53+
key: test-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }}-${{ github.sha }}
54+
restore-keys: test-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }}
6155
- run: npm run test
6256
e2e:
6357
strategy:
6458
fail-fast: false
6559
matrix:
6660
node: [20, 22]
67-
os: [ubuntu-24.04-arm, windows-2025]
61+
os: [ubuntu-24.04-arm, windows-11-arm]
6862
runs-on: ${{ matrix.os }}
6963
steps:
7064
- uses: actions/checkout@v4
71-
- uses: actions/setup-node@v4
65+
- uses: ./.github/actions/setup-node-and-node-modules
7266
with:
7367
node-version: ${{ matrix.node }}
74-
cache: 'npm'
7568
- uses: actions/cache@v4
7669
with:
7770
path: |
7871
node_modules/.vite/vitest
7972
packages/*/dist
8073
packages/*/tsconfig.build.tsbuildinfo
81-
key: toolcache-e2e-${{ runner.os }}-node${{ matrix.node }}-${{ github.sha }}
82-
restore-keys: toolcache-e2e-${{ runner.os }}-node${{ matrix.node }}
74+
tsconfig.tsbuildinfo
75+
key: e2e-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }}-${{ github.sha }}
76+
restore-keys: e2e-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }}
8377
- uses: actions/cache@v4
8478
with:
8579
path: .vscode-test
86-
key: ${{ runner.os }}-vscode-${{ env.VSCODE_VERSION }}
87-
- run: npm install
80+
key: vscode-test-${{ runner.arch }}-${{ runner.os }}-vscode-${{ env.VSCODE_VERSION }}
8881

8982
- run: xvfb-run -a npm run e2e
9083
if: runner.os == 'Linux'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"build": "tsc -b tsconfig.build.json",
1919
"lint": "run-s -c lint:*",
2020
"lint:tsc": "tsc -b",
21-
"lint:eslint": "eslint --cache --cache-strategy content .",
21+
"lint:eslint": "eslint .",
2222
"lint:prettier": "prettier --cache --check .",
2323
"test": "vitest --run --project unit",
2424
"e2e": "run-s -c e2e:build e2e:vitest e2e:vscode",

0 commit comments

Comments
 (0)