@@ -18,50 +18,74 @@ concurrency:
18
18
cancel-in-progress : ${{ github.ref != 'refs/heads/master' }}
19
19
20
20
env :
21
- NODE_VERSION : 18
22
21
CACHE_KEY : " ${{ github.ref }}-${{ github.run_id }}-${{ github.run_attempt }}"
23
22
24
23
jobs :
24
+ configure :
25
+ name : Configure Build Matrix
26
+ runs-on : ubuntu-latest
27
+
28
+ outputs :
29
+ matrix : ${{ steps.set-matrix.outputs.matrix }}
30
+
31
+ steps :
32
+ - uses : actions/checkout@v4
33
+ with :
34
+ ref : ${{ github.event.pull_request.head.sha || github.ref }}
35
+
36
+ - id : set-matrix
37
+ run : echo "matrix=$(jq -c . < ./.github/workflows/matrix.json)" >> $GITHUB_OUTPUT
38
+
25
39
build :
40
+ needs : configure
41
+
26
42
name : Build Package
27
43
runs-on : ubuntu-latest
28
44
45
+ strategy :
46
+ matrix : ${{ fromJson(needs.configure.outputs.matrix) }}
47
+
29
48
steps :
30
49
- name : Checkout code
31
50
uses : actions/checkout@v4
32
51
33
52
- uses : ./.github/actions/build
34
53
with :
35
- node : ${{ env.NODE_VERSION }}
54
+ node : ${{ matrix.node }}
36
55
37
56
- name : Save build artifacts
38
57
uses : actions/cache/save@v3
39
58
with :
40
59
path : .
41
- key : ${{ env.CACHE_KEY }}
60
+ key : ${{ matrix.node }}-${{ env.CACHE_KEY }}
42
61
43
62
unit :
44
- needs : build # Require build to complete before running tests
63
+ needs : [configure, build] # Require build to complete before running tests
45
64
46
65
name : Run Unit Tests
47
66
runs-on : ubuntu-latest
48
67
68
+ strategy :
69
+ matrix : ${{ fromJson(needs.configure.outputs.matrix) }}
70
+
49
71
steps :
50
72
- uses : actions/checkout@v4
51
73
52
74
- uses : actions/setup-node@v3
53
75
with :
54
- node-version : ${{ env.NODE_VERSION }}
76
+ node-version : ${{ matrix.node }}
55
77
cache : npm
56
78
57
79
- uses : actions/cache/restore@v3
58
80
with :
59
81
path : .
60
- key : ${{ env.CACHE_KEY }}
82
+ key : ${{ matrix.node }}-${{ env.CACHE_KEY }}
61
83
62
84
- run : npm run test:ci
63
85
64
- -
uses :
codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # [email protected]
86
+ # only upload coverage on one node version
87
+ - if : matrix.node == 18
88
+ uses :
codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # [email protected]
65
89
66
90
lint :
67
91
needs : build # Require build to complete before running tests
@@ -74,12 +98,12 @@ jobs:
74
98
75
99
- uses : actions/setup-node@v3
76
100
with :
77
- node-version : ${{ env.NODE_VERSION }}
101
+ node-version : ${{ matrix.node }}
78
102
cache : npm
79
103
80
104
- uses : actions/cache/restore@v3
81
105
with :
82
106
path : .
83
- key : ${{ env.CACHE_KEY }}
107
+ key : ${{ matrix.node }}-${{ env.CACHE_KEY }}
84
108
85
109
- run : npm run lint
0 commit comments