1
1
# build and test on linux, windows, mac with node 12, 14, 16
2
2
name : CI
3
3
4
- env :
5
- pnpm_store_path : ${{github.workspace}}/.pnpm-store
6
-
7
4
on :
8
5
push :
9
6
branches :
13
10
- main
14
11
15
12
jobs :
16
- pnpmstore :
13
+ # "checks" job runs on linux + node14 only and checks that install, build, lint and audit work
14
+ # it also primes the pnpm store cache for linux, important for downstream tests
15
+ checks :
17
16
timeout-minutes : 5
18
17
runs-on : ${{ matrix.os }}
19
-
20
18
strategy :
21
- fail-fast : false
22
19
matrix :
23
- os : [ ubuntu-latest, windows-latest, macos-latest ]
24
- node : [ 14 ]
25
-
20
+ # pseudo-matrix for convenience, NEVER use more than a single combination
21
+ node : [14]
22
+ os : [ubuntu-latest]
23
+ outputs :
24
+ build_successful : ${{ steps.build.outcome == 'success' }}
26
25
steps :
26
+ - uses : actions/checkout@v2
27
27
- uses : actions/setup-node@v2
28
28
with :
29
29
node-version : ${{ matrix.node }}
30
-
31
- - name : checkout
32
- uses : actions/checkout@v2
33
-
34
- - name : install pnpm
35
- run : npm i -g pnpm@6
36
- - name : set pnpm store-dir
37
- run : pnpm config set store-dir ${{ env.pnpm_store_path }}
38
- - name : pnpm-store
39
- uses : actions/cache@v2
40
- id : pnpm-store
41
- with :
42
- path : ${{ env.pnpm_store_path }}
43
- key : ${{ matrix.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
44
-
45
- - name : pnpm-store-fallback
46
- if : steps.pnpm-store.outputs.cache-hit != 'true'
47
- uses : actions/cache@v2
48
- id : pnpm-store-fallback
49
- with :
50
- path : ${{ env.pnpm_store_path }}
51
- key : ${{ matrix.os }}-pnpm-store-fallback-${{ hashFiles('**/pnpm-lock.yaml') }}
52
- restore-keys : |
53
- ${{ matrix.os }}-pnpm-store-fallback-
54
- ${{ matrix.os }}-pnpm-store-
55
-
56
- - name : install
57
- if : steps.pnpm-store.outputs.cache-hit != 'true'
58
- run : pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
59
- - name : prune store
60
- if : steps.pnpm-store.outputs.cache-hit != 'true'
61
- run : pnpm store prune
62
- - name : check store
63
- if : steps.pnpm-store.outputs.cache-hit != 'true'
64
- run : pnpm store status
65
-
66
- lint :
67
- needs : pnpmstore
68
- timeout-minutes : 5
69
- runs-on : ${{ matrix.os }}
70
- strategy :
71
- matrix :
72
- os : [ ubuntu-latest ]
73
- node : [ 14 ]
74
- steps :
30
+ - run : npm i -g pnpm@6
75
31
- uses : actions/setup-node@v2
76
32
with :
77
33
node-version : ${{ matrix.node }}
78
-
79
- - name : checkout
80
- uses : actions/checkout@v2
81
-
82
- - name : pnpm-store
83
- uses : actions/cache@v2
84
- id : pnpm-store
85
- with :
86
- path : ${{ env.pnpm_store_path }}
87
- key : ${{ matrix.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
88
- - name : install pnpm
89
- run : npm i -g pnpm@6
90
- - name : set pnpm store-dir
91
- run : pnpm config set store-dir ${{ env.pnpm_store_path }}
34
+ cache : ' pnpm'
35
+ cache-dependency-path : ' **/pnpm-lock.yaml'
92
36
- name : install
93
- run : pnpm install --frozen-lockfile --offline --ignore-scripts
94
- - name : install esbuild
95
- run : node node_modules/esbuild/install.js
37
+ run : |
38
+ pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
39
+ node node_modules/esbuild/install.js
96
40
- name : build
97
- run : pnpm run build:ci
41
+ id : build
42
+ run : pnpm run build
98
43
- name : lint
99
- run : pnpm lint
100
-
101
- audit :
102
- needs : pnpmstore
103
- timeout-minutes : 5
104
- runs-on : ${{ matrix.os }}
105
- strategy :
106
- matrix :
107
- os : [ ubuntu-latest ]
108
- node : [ 14 ]
109
- steps :
110
- - uses : actions/setup-node@v2
111
- with :
112
- node-version : ${{ matrix.node }}
113
-
114
- - name : checkout
115
- uses : actions/checkout@v2
116
-
117
- - name : pnpm-store
118
- uses : actions/cache@v2
119
- id : pnpm-store
120
- with :
121
- path : ${{ env.pnpm_store_path }}
122
- key : ${{ matrix.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
123
- - name : install pnpm
124
- run : npm i -g pnpm@6
125
- - name : set pnpm store-dir
126
- run : pnpm config set store-dir ${{ env.pnpm_store_path }}
127
- - name : install
128
- run : pnpm install --frozen-lockfile --offline --ignore-scripts
44
+ if : (${{ success() }} || ${{ failure() }})
45
+ run : pnpm run lint
129
46
- name : audit
47
+ if : (${{ success() }} || ${{ failure() }})
130
48
run : pnpm audit
131
49
50
+ # this is the test matrix, it runs with node14 on linux,windows,macos + node12,16 on linux
51
+ # it is skipped if the build step of the checks job wasn't successful (still runs if lint or audit fail)
132
52
test :
133
- needs : pnpmstore
53
+ needs : checks
54
+ if : (${{ success() }} || ${{ failure() }}) && (${{ needs.checks.output.build_successful }})
134
55
timeout-minutes : 10
135
56
runs-on : ${{ matrix.os }}
136
57
strategy :
137
58
fail-fast : false
138
59
matrix :
139
- os : [ ubuntu-latest, windows-latest, macos-latest ]
140
- node : [ 12, 14, 16 ]
60
+ node : [14]
61
+ os : [ubuntu-latest, macos-latest, windows-latest]
62
+ include :
63
+ - node : 12
64
+ os : ubuntu-latest
65
+ - node : 16
66
+ os : ubuntu-latest
141
67
steps :
68
+ - uses : actions/checkout@v2
142
69
- uses : actions/setup-node@v2
143
70
with :
144
71
node-version : ${{ matrix.node }}
145
-
146
- - name : checkout
147
- uses : actions/checkout@v2
148
-
149
- - name : pnpm-store
150
- uses : actions/cache@v2
151
- id : pnpm-store
72
+ - run : npm i -g pnpm@6
73
+ - uses : actions/setup-node@v2
152
74
with :
153
- path : ${{ env.pnpm_store_path }}
154
- key : ${{ matrix.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
155
-
156
- - name : install pnpm
157
- run : npm i -g pnpm@6
158
- - name : set pnpm store-dir
159
- run : pnpm config set store-dir ${{ env.pnpm_store_path }}
75
+ node-version : ${{ matrix.node }}
76
+ cache : ' pnpm'
77
+ cache-dependency-path : ' **/pnpm-lock.yaml'
160
78
- name : install
161
- run : pnpm install --frozen-lockfile --offline --ignore-scripts
162
- - name : install esbuild
163
- run : node node_modules/esbuild/install.js
79
+ run : |
80
+ pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
81
+ node node_modules/esbuild/install.js
164
82
- name : build
165
83
run : pnpm run build:ci
166
84
- name : run tests
167
85
run : pnpm test:ci
168
-
169
86
- name : archive tests temp directory
170
87
if : failure()
171
88
shell : bash
@@ -190,36 +107,3 @@ jobs:
190
107
temp/serve/junit.xml
191
108
temp/build/jest-results.json
192
109
temp/build/junit.xml
193
-
194
- build :
195
- needs : pnpmstore
196
- timeout-minutes : 5
197
- runs-on : ${{ matrix.os }}
198
- strategy :
199
- matrix :
200
- os : [ ubuntu-latest ]
201
- node : [ 14 ]
202
- steps :
203
- - uses : actions/setup-node@v2
204
- with :
205
- node-version : ${{ matrix.node }}
206
-
207
- - name : checkout
208
- uses : actions/checkout@v2
209
-
210
- - name : pnpm-store
211
- uses : actions/cache@v2
212
- id : pnpm-store
213
- with :
214
- path : ${{ env.pnpm_store_path }}
215
- key : ${{ matrix.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
216
- - name : install pnpm
217
- run : npm i -g pnpm@6
218
- - name : set pnpm store-dir
219
- run : pnpm config set store-dir ${{ env.pnpm_store_path }}
220
- - name : install
221
- run : pnpm install --frozen-lockfile --offline --ignore-scripts
222
- - name : install esbuild
223
- run : node node_modules/esbuild/install.js
224
- - name : build
225
- run : pnpm run build
0 commit comments