11# build and test on linux, windows, mac with node 12, 14, 16
22name : CI
33
4- env :
5- pnpm_store_path : ${{github.workspace}}/.pnpm-store
6-
74on :
85 push :
96 branches :
1310 - main
1411
1512jobs :
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 :
1716 timeout-minutes : 5
1817 runs-on : ${{ matrix.os }}
19-
2018 strategy :
21- fail-fast : false
2219 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' }}
2625 steps :
26+ - uses : actions/checkout@v2
2727 - uses : actions/setup-node@v2
2828 with :
2929 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
7531 - uses : actions/setup-node@v2
7632 with :
7733 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'
9236 - 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
9640 - name : build
97- run : pnpm run build:ci
41+ id : build
42+ run : pnpm run build
9843 - 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
12946 - name : audit
47+ if : (${{ success() }} || ${{ failure() }})
13048 run : pnpm audit
13149
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)
13252 test :
133- needs : pnpmstore
53+ needs : checks
54+ if : (${{ success() }} || ${{ failure() }}) && (${{ needs.checks.output.build_successful }})
13455 timeout-minutes : 10
13556 runs-on : ${{ matrix.os }}
13657 strategy :
13758 fail-fast : false
13859 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
14167 steps :
68+ - uses : actions/checkout@v2
14269 - uses : actions/setup-node@v2
14370 with :
14471 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
15274 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'
16078 - 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
16482 - name : build
16583 run : pnpm run build:ci
16684 - name : run tests
16785 run : pnpm test:ci
168-
16986 - name : archive tests temp directory
17087 if : failure()
17188 shell : bash
@@ -190,36 +107,3 @@ jobs:
190107 temp/serve/junit.xml
191108 temp/build/jest-results.json
192109 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