forked from cypress-io/cypress-example-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.yml
397 lines (383 loc) · 10.4 KB
/
circle.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
385
386
387
388
389
390
391
392
393
394
395
396
397
version: 2.1
# testing jobs are all the same, so just use a template
defaults: &defaults
parallelism: 1
working_directory: ~/app
docker:
- image: cypress/base:10
steps:
- attach_workspace:
at: ~/
# some examples have the server part
# so start it in the background
- run:
command: |
cd examples/$CIRCLE_JOB
npm run start --if-present
name: start the server
background: true
- run:
# only record the tests on Cypress Dashboard
# if the record key is set. Usually it is NOT set
# for forked pull request because environment variables
# are not passed to the external PRs
command: |
cd examples/$CIRCLE_JOB
if [ -z "$CYPRESS_RECORD_KEY" ]; then
npm run cypress:run
else
npm run cypress:run -- --record --group $CIRCLE_JOB
fi
name: Cypress tests
jobs:
# a single job that installs dependencies (NPM and Cypress)
build:
working_directory: ~/app
docker:
- image: cypress/base:10
steps:
- checkout
- restore_cache:
key: cache-dirs-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "circle.yml" }}
- run: npm ci
# run verify and then save cache.
# this ensures that the Cypress verified status is cached too
- run: npm run cypress:verify
- run: npm run stop-only
- save_cache:
key: cache-dirs-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "circle.yml" }}
paths:
- ~/.npm
- ~/.cache
# all other test jobs will run AFTER this build job finishes
# to avoid reinstalling dependencies, we persist the source folder "app"
# and the Cypress binary to workspace, which is the fastest way
# for Circle jobs to pass files
- persist_to_workspace:
root: ~/
paths:
- app
- .cache/Cypress
# dummy job running after all end-to-end tests
after-tests:
docker:
- image: cypress/base:10
steps:
- run: echo "all good"
# a single utility job that can run multiple examples one by one
# but with chunking
test-examples:
parallelism: 20
working_directory: ~/app
docker:
- image: cypress/base:10
steps:
- attach_workspace:
at: ~/
# when running in parallel, the total number of parallel containers
# is in variable CIRCLE_NODE_TOTAL and the current container index in CIRCLE_NODE_INDEX
# which starts at 0 and goes to $CIRCLE_NODE_TOTAL - 1
- run: npm run test:ci -- --chunk $CIRCLE_NODE_INDEX --total-chunks $CIRCLE_NODE_TOTAL
# a single utility script to run multiple examples against Chrome
test-examples-chrome:
parallelism: 10
working_directory: ~/app
docker:
- image: cypress/browsers:node12.0.0-chrome75
steps:
- attach_workspace:
at: ~/
- run: npm run test:ci:chrome -- --chunk $CIRCLE_NODE_INDEX --total-chunks $CIRCLE_NODE_TOTAL
# define a new job with defaults for each "examples/*" subfolder
blogs__a11y:
<<: *defaults
blogs__application-actions:
<<: *defaults
blogs__codepen-demo:
<<: *defaults
blogs__direct-control-angular:
<<: *defaults
blogs__e2e-api-testing:
<<: *defaults
blogs__e2e-snapshots:
<<: *defaults
blogs__element-coverage:
<<: *defaults
blogs__testing-redux-store:
<<: *defaults
blogs__vue-vuex-rest:
<<: *defaults
extending-cypress__chai-assertions:
<<: *defaults
file-upload-react:
<<: *defaults
fundamentals__node-modules:
<<: *defaults
fundamentals__fixtures:
<<: *defaults
fundamentals__add-custom-command:
<<: *defaults
logging-in__csrf-tokens:
<<: *defaults
logging-in__html-web-forms:
<<: *defaults
logging-in__single-sign-on:
<<: *defaults
logging-in__xhr-web-forms:
<<: *defaults
logging-in__jwt:
<<: *defaults
logging-in__using-app-code:
<<: *defaults
preprocessors__grep:
<<: *defaults
# in this particular example we want to grep tests
# and run only tests with name having "@admin"
environment:
CYPRESS_grep: '@admin'
preprocessors__typescript-browserify:
<<: *defaults
preprocessors__typescript-webpack:
<<: *defaults
server-communication__bootstrapping-your-app:
<<: *defaults
stubbing-spying__functions:
<<: *defaults
stubbing-spying__window-fetch:
<<: *defaults
stubbing-spying__google-analytics:
<<: *defaults
stubbing-spying__window:
<<: *defaults
stubbing-spying__console:
<<: *defaults
testing-dom__drag-drop:
<<: *defaults
testing-dom__form-interactions:
<<: *defaults
testing-dom__hover-hidden-elements:
<<: *defaults
testing-dom__tab-handling-links:
<<: *defaults
testing-dom__wait-for-resource:
<<: *defaults
testing-dom__csv-table:
<<: *defaults
unit-testing__application-code:
<<: *defaults
unit-testing__react:
<<: *defaults
server-communication__env-variables:
<<: *defaults
fundamentals__dynamic-tests:
<<: *defaults
fundamentals__module-api:
<<: *defaults
# list all jobs to run and their dependencies here
# and then use this list from workflow definition
all_jobs: &all_jobs
- build
- test-examples:
requires:
- build
filters:
branches:
only:
- master
- allow-testing-in-chunks
- test-examples-chrome:
requires:
- build
filters:
branches:
only:
- master
# when adding new example subfolder with a recipe
# add its name here to "create" CircleCI job
# Do not run Codepen demo by default - because it depends on
# the external service that sometimes gives 502 breaking our tests
# - blogs__codepen-demo:
# requires:
# - build
- blogs__a11y:
requires:
- build
- blogs__application-actions:
requires:
- build
- blogs__direct-control-angular:
requires:
- build
- blogs__e2e-api-testing:
requires:
- build
- blogs__e2e-snapshots:
requires:
- build
- blogs__element-coverage:
requires:
- build
- blogs__testing-redux-store:
requires:
- build
- blogs__vue-vuex-rest:
requires:
- build
- extending-cypress__chai-assertions:
requires:
- build
- file-upload-react:
requires:
- build
- fundamentals__node-modules:
requires:
- build
- fundamentals__add-custom-command:
requires:
- build
- logging-in__csrf-tokens:
requires:
- build
- logging-in__html-web-forms:
requires:
- build
- logging-in__single-sign-on:
requires:
- build
- logging-in__xhr-web-forms:
requires:
- build
- logging-in__jwt:
requires:
- build
- logging-in__using-app-code:
requires:
- build
- preprocessors__grep:
requires:
- build
- preprocessors__typescript-browserify:
requires:
- build
- preprocessors__typescript-webpack:
requires:
- build
- server-communication__bootstrapping-your-app:
requires:
- build
- stubbing-spying__functions:
requires:
- build
- stubbing-spying__window-fetch:
requires:
- build
- stubbing-spying__console:
requires:
- build
- stubbing-spying__window:
requires:
- build
- stubbing-spying__google-analytics:
requires:
- build
- testing-dom__drag-drop:
requires:
- build
- testing-dom__form-interactions:
requires:
- build
- testing-dom__hover-hidden-elements:
requires:
- build
- testing-dom__tab-handling-links:
requires:
- build
- testing-dom__wait-for-resource:
requires:
- build
- testing-dom__csv-table:
requires:
- build
- unit-testing__application-code:
requires:
- build
- unit-testing__react:
requires:
- build
- server-communication__env-variables:
requires:
- build
- fundamentals__dynamic-tests:
requires:
- build
- fundamentals__fixtures:
requires:
- build
- fundamentals__module-api:
requires:
- build
# to avoid constantly tweaking required jobs on CircleCI
# we can have a single job wait on all other test jobs here.
# CircleCI can then just require this 1 job to pass
# see https://glebbahmutov.com/blog/parallel-or-not/
- after-tests:
requires:
- build
- blogs__a11y
- blogs__application-actions
- blogs__direct-control-angular
- blogs__e2e-api-testing
- blogs__e2e-snapshots
- blogs__element-coverage
- blogs__testing-redux-store
- blogs__vue-vuex-rest
- extending-cypress__chai-assertions
- file-upload-react
- fundamentals__node-modules
- fundamentals__fixtures
- fundamentals__dynamic-tests
- fundamentals__module-api
- fundamentals__add-custom-command
- logging-in__csrf-tokens
- logging-in__html-web-forms
- logging-in__single-sign-on
- logging-in__xhr-web-forms
- logging-in__jwt
- logging-in__using-app-code
- preprocessors__grep
- preprocessors__typescript-browserify
- preprocessors__typescript-webpack
- server-communication__bootstrapping-your-app
- stubbing-spying__functions
- stubbing-spying__window-fetch
- stubbing-spying__google-analytics
- stubbing-spying__window
- stubbing-spying__console
- testing-dom__drag-drop
- testing-dom__form-interactions
- testing-dom__hover-hidden-elements
- testing-dom__tab-handling-links
- testing-dom__wait-for-resource
- testing-dom__csv-table
- unit-testing__application-code
- unit-testing__react
- server-communication__env-variables
# "meta" jobs
- test-examples
- test-examples-chrome
workflows:
version: 2
# run this workflow on each commit and pull request
all-recipes:
jobs: *all_jobs
# since this is testing a lot of external sites
# let's run these tests once per day (at night)
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
jobs: *all_jobs