Skip to content

Commit 34b297c

Browse files
authored
Update CI workflow (#135)
- Run tests on Node 22 instead of 21 (in addition to 18 and 20). - Cache the .yarn folder because that is the main one needed for Yarn version 4. - Wait for linting to finish before running unit tests. The CI is so short that this makes sense. If the CI is too slow, it is because Jest is running with too many workers, which will be fixed in another PR. - Ensure the Coveralls coverage is supplied the correct key, to avoid false duplicates in the report. - Cancel in-progress workflows when new commits are pushed to a branch. - Use the --immutable flag to detect any lockfile inconsistencies in the CI.
1 parent 36fe2cf commit 34b297c

1 file changed

Lines changed: 45 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,86 @@
11
name: CI
22
on: [push, pull_request]
3-
jobs:
43

4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.ref }}
6+
cancel-in-progress: true
7+
8+
env:
9+
DEFAULT_NODE_VERSION: 22.x
10+
11+
jobs:
512
lint:
13+
name: Lint
614
runs-on: ubuntu-latest
715
steps:
8-
- uses: actions/checkout@v2
9-
- uses: actions/cache@v2
16+
- name: Use Node.js ${{ env.DEFAULT_NODE_VERSION }}
17+
uses: actions/setup-node@v4
1018
with:
11-
path: '**/node_modules'
12-
key: ${{ runner.os }}-lint-modules-${{ hashFiles('**/yarn.lock') }}
13-
- uses: actions/setup-node@v2
19+
node-version: ${{ env.DEFAULT_NODE_VERSION }}
20+
- name: Enable corepack
21+
run: corepack enable
22+
- name: Ensure line endings are consistent
23+
run: git config --global core.autocrlf input
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
- name: Load dependency cache
27+
uses: actions/cache@v4
1428
with:
15-
node-version: 20.x
16-
- run: corepack enable
17-
- run: yarn install
18-
- run: yarn run lint
19-
29+
path: '**/node_modules'
30+
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
31+
- name: Install dependencies
32+
run: yarn install --immutable
33+
- name: Run ESLint
34+
run: yarn run lint
2035
test:
36+
name: Test
37+
needs: lint
2138
runs-on: ${{ matrix.os }}
2239
strategy:
2340
matrix:
24-
os: [ubuntu-latest, windows-latest, macos-latest]
41+
os:
42+
- ubuntu-latest
43+
- windows-latest
44+
- macos-latest
2545
node-version:
2646
- 18.x
2747
- 20.x
28-
- 21.x
48+
- 22.x
2949
steps:
3050
- name: Use Node.js ${{ matrix.node-version }}
31-
uses: actions/setup-node@v2
51+
uses: actions/setup-node@v4
3252
with:
3353
node-version: ${{ matrix.node-version }}
34-
- name: Enable CorePack
54+
- name: Enable corepack
3555
run: corepack enable
3656
- name: Ensure line endings are consistent
3757
run: git config --global core.autocrlf input
38-
- name: Check out repository
39-
uses: actions/checkout@v2
40-
- uses: actions/cache@v2
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
- name: Load dependency cache
61+
uses: actions/cache@v4
4162
with:
4263
path: '**/node_modules'
43-
key: ${{ runner.os }}-test-modules-${{ hashFiles('**/yarn.lock') }}
64+
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
4465
- name: Install dependencies
45-
run: yarn install
66+
run: yarn install --immutable
4667
- name: Build project
4768
run: yarn run build
4869
- name: Run tests
4970
run: yarn run test
5071
- name: Submit coverage results
51-
uses: coverallsapp/github-action@master
72+
uses: coverallsapp/github-action@v2
5273
with:
5374
github-token: ${{ secrets.github_token }}
54-
flag-name: run-${{ matrix.node-version }}
75+
flag-name: ${{ matrix.node-version }}-${{ matrix.os }}
5576
parallel: true
56-
5777
coveralls:
78+
name: Coverage
5879
needs: test
5980
runs-on: ubuntu-latest
6081
steps:
6182
- name: Consolidate test coverage from different jobs
62-
uses: coverallsapp/github-action@master
83+
uses: coverallsapp/github-action@v2
6384
with:
6485
github-token: ${{ secrets.github_token }}
6586
parallel-finished: true

0 commit comments

Comments
 (0)