-
-
Notifications
You must be signed in to change notification settings - Fork 27
384 lines (344 loc) · 10.8 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
name: ci
on: push
permissions:
contents: write
issues: write
pull-requests: write
jobs:
# example splitting all tests across GitHub machines
prepare:
runs-on: ubuntu-22.04
# explicitly set the output of this job
# so that other jobs can use it
outputs:
matrix: ${{ steps.prepare.outputs.matrix }}
steps:
# generate the list using a bash script
- name: Create matrix ⊹
id: prepare
# for reusable workflow, must use the full action reference
uses: bahmutov/gh-build-matrix@v1.0.1
with:
n: 3 # number of containers to output
- name: Print result 🖨
run: echo '${{ steps.prepare.outputs.matrix }}'
test-unit:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Install dependencies 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Run unit tests 🧪
run: npm run unit
# two jobs that split 2 explicit specs
test-spec:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
containers: [1, 2]
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Run split Cypress E2E tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
build: npm run test-names
# using operating system process environment variables
env:
SPEC: 'cypress/e2e/spec-b.cy.js,cypress/e2e/spec-e.cy.js'
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
DEBUG: 'cypress-split'
test-spec-wildcard:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
containers: [1, 2]
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Run split Cypress E2E tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
build: npm run demo-preview-spec
# using operating system process environment variables
env:
# confirm we can use wildcards in the SPEC list
SPEC: 'cypress/e2e/spec-*.cy.js, cypress/e2e/spec-*.cy.js'
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
DEBUG: 'cypress-split'
test-random-order:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
containers: [1, 2]
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Run random order Cypress E2E tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
# using operating system process environment variables
env:
SPLIT_RANDOM_SEED: 42
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
DEBUG: 'cypress-split'
test-subfolder:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Run Cypress E2E tests in the subfolder 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
build: npm run subfolder
env:
SPLIT: 2
SPLIT_INDEX: 0
test-merge-timings:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Install dependencies 🧪
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Merge example timings ⛙
id: merge
run: npm run demo-merge -- --set-gha-output merged
env:
DEBUG: cypress-split
- name: Show merged output
run: |
echo off
echo '${{ steps.merge.outputs.merged }}'
preview:
needs: prepare
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Preview the split 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
command: npm run demo-preview
- name: Preview the split with timings 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
install: false
command: npm run demo-preview -- --split-file ./timings.json
test-split:
needs: prepare
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Print GitHub variables 🖨
run: npx @bahmutov/print-env GITHUB
- name: Print GitHub strategy context 🖨
run: echo '${{ toJSON(strategy) }}'
- name: Run split Cypress tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
build: npm run test-names
# using operating system process environment variables
env:
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
test-no-summary:
needs: prepare
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Run some Cypress tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
# run half of all specs
env:
SPLIT: 2
# run the second part of the list of specs
SPLIT_INDEX: 1
# do not write summary to github
SPLIT_SUMMARY: false
test-empty:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Run an empty Cypress split 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
build: npm run deps
command: npm run empty
test-user-spec-list:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Split explicit user list of specs 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
command: npm run user-specs
test-timings:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Split specs based on timings json file 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
command: npm run timings
test-timings-split-output-file:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Split specs based on timings json file 🧪, write output to different file 🗃️
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
command: npm run timings-split-output-file
- name: Show split output file
run: cat new-timings.json
test-timings-no-file:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Split specs based on non-existent timings json file 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
command: npm run timings-no-file
test-find-timings-file:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Needs to find the timings file 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
project: examples/timings-file/tests/cypress-tests
env:
SPLIT: 1
SPLIT_INDEX: 0
# the timings file is not next to the config file
# but in the project folder
SPLIT_FILE: timings.json
test-pending-tests:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Needs to find the timings file 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
project: examples/pending-timings/tests/cypress-tests
env:
SPLIT: 1
SPLIT_INDEX: 0
# the timings file is not next to the config file
# but in the project folder
SPLIT_FILE: timings.json
test-workflow-e2e:
# https://github.com/bahmutov/cypress-workflows
uses: bahmutov/cypress-workflows/.github/workflows/split.yml@v2
with:
nE2E: 3
test-workflow-component:
# https://github.com/bahmutov/cypress-workflows
uses: bahmutov/cypress-workflows/.github/workflows/split.yml@v2
with:
nComponent: 2
# using SPLIT_INDEX1 to start index at 1
test-index1:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Run split Cypress E2E tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
# using operating system process environment variables
env:
SPEC: 'cypress/e2e/spec-b.cy.js,cypress/e2e/spec-e.cy.js'
SPLIT: 2
# should run the first spec "spec-b" in the list
SPLIT_INDEX1: 1
DEBUG: 'cypress-split'
test-skipped-specs:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Run split Cypress E2E tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
# using operating system process environment variables
env:
# should exclude these specs
SKIP_SPEC: 'cypress/e2e/spec-b.cy.js,cypress/e2e/spec-e.cy.js'
SPLIT: 2
SPLIT_INDEX: 0
DEBUG: 'cypress-split'
release:
if: github.ref == 'refs/heads/main'
needs:
[
test-random-order,
test-skipped-specs,
test-unit,
test-empty,
test-split,
test-spec,
test-workflow-e2e,
test-workflow-component,
test-no-summary,
test-user-spec-list,
test-subfolder,
test-index1,
test-timings,
test-timings-no-file,
test-pending-tests,
test-merge-timings,
test-find-timings-file,
test-spec-wildcard,
preview,
]
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Semantic Release 🚀
# https://github.com/cycjimmy/semantic-release-action
uses: cycjimmy/semantic-release-action@v4
with:
branch: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}