-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
workflows.yml
3583 lines (3405 loc) · 121 KB
/
workflows.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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
version: 2.1
defaults: &defaults
parallelism: 1
working_directory: ~/cypress
parameters: &defaultsParameters
executor:
type: executor
default: cy-doc
only-cache-for-root-user:
type: boolean
default: false
executor: <<parameters.executor>>
environment: &defaultsEnvironment
## set specific timezone
TZ: "/usr/share/zoneinfo/America/New_York"
## store artifacts here
CIRCLE_ARTIFACTS: /tmp/artifacts
## set so that e2e tests are consistent
COLUMNS: 100
LINES: 24
mainBuildFilters: &mainBuildFilters
filters:
branches:
only:
- develop
- /^release\/\d+\.\d+\.\d+$/
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- 'update-v8-snapshot-cache-on-develop'
- 'jquery-patch-remove-unload'
- 'publish-binary'
- 'chore/use_build_docker_file_for_centos7'
# usually we don't build Mac app - it takes a long time
# but sometimes we want to really confirm we are doing the right thing
# so just add your branch to the list here to build and test on Mac
macWorkflowFilters: &darwin-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'fix/webpack-batteries-included-for-yarn-pnp', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'chore/use_build_docker_file_for_centos7', << pipeline.git.branch >> ]
- equal: [ 'jquery-patch-remove-unload', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
# uncomment & add to the branch conditions below to disable the main linux
# flow if we don't want to test it for a certain branch
linuxWorkflowExcludeFilters: &linux-x64-workflow-exclude-filters
unless:
or:
- matches:
pattern: /^pull\/[0-9]+/
value: << pipeline.git.branch >>
- false
# windows is slow and expensive in CI, so it normally only runs on main branches
# add your branch to this list to run the full Windows build on your PR
windowsWorkflowFilters: &windows-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'fix/webpack-batteries-included-for-yarn-pnp', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
executors:
# the Docker image with Cypress dependencies and Chrome browser
cy-doc:
docker:
- image: cypress/browsers-internal:node18.17.1-chrome124-ff125
# by default, we use "medium" to balance performance + CI costs. bump or reduce on a per-job basis if needed.
resource_class: medium
environment:
PLATFORM: linux
CI_DOCKER: "true"
kitchensink-executor:
docker:
- image: cypress/browsers-internal:node20.15.0-chrome126-ff127
# by default, we use "medium" to balance performance + CI costs. bump or reduce on a per-job basis if needed.
resource_class: medium
environment:
PLATFORM: linux
CI_DOCKER: "true"
# Docker image with non-root "node" user
non-root-docker-user:
docker:
- image: cypress/browsers-internal:node18.17.1-chrome124-ff125
user: node
environment:
PLATFORM: linux
# executor to run on Mac OS
# https://circleci.com/docs/2.0/executor-types/#using-macos
# https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions
darwin-amd64:
machine: true
environment:
PLATFORM: darwin
# executor to run on Windows - based off of the windows-orb default executor since it is
# not customizable enough to align with our existing setup.
# https://github.com/CircleCI-Public/windows-orb/blob/master/src/executors/default.yml
# https://circleci.com/docs/2.0/hello-world-windows/#software-pre-installed-in-the-windows-image
windows: &windows-executor
machine:
image: windows-server-2022-gui:stable
shell: bash.exe -eo pipefail
resource_class: windows.large
environment:
PLATFORM: windows
darwin-arm64: &darwin-arm64-executor
machine: true
environment:
PLATFORM: darwin
linux-arm64: &linux-arm64-executor
machine:
image: ubuntu-2004:2023.07.1
resource_class: arm.medium
environment:
PLATFORM: linux
# TODO: Disabling snapshots for now on Linux Arm 64 architectures. Will revisit with https://github.com/cypress-io/cypress/issues/23557
DISABLE_SNAPSHOT_REQUIRE: 1
commands:
# This command inserts SHOULD_PERSIST_ARTIFACTS into BASH_ENV. This way, we can define the variable in one place and use it in multiple steps.
# Run this command in a job before you want to use the SHOULD_PERSIST_ARTIFACTS variable.
setup_should_persist_artifacts:
steps:
- run:
name: Set environment variable to determine whether or not to persist artifacts
command: |
echo "Setting SHOULD_PERSIST_ARTIFACTS variable"
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "chore/use_build_docker_file_for_centos7" ]]; then
export SHOULD_PERSIST_ARTIFACTS=true
fi' >> "$BASH_ENV"
# You must run `setup_should_persist_artifacts` command and be using bash before running this command
verify_should_persist_artifacts:
steps:
- run:
name: Check current branch to persist artifacts
command: |
if [[ -z "$SHOULD_PERSIST_ARTIFACTS" ]]; then
echo "Not uploading artifacts or posting install comment for this branch."
circleci-agent step halt
fi
maybe_skip_binary_jobs:
steps:
- run:
name: Skip binary job if external PR
command: |
if [[ -z "$CIRCLE_TOKEN" ]]; then
echo "There is no CIRCLE_TOKEN set for this job. Cannot trigger binary build. Skipping job."
circleci-agent step halt
fi
restore_workspace_binaries:
steps:
- attach_workspace:
at: ~/
# make sure we have cypress.zip received
- run: ls -l
- run: ls -l cypress.zip cypress.tgz
- run: node --version
- run: npm --version
restore_cached_workspace:
steps:
- attach_workspace:
at: ~/
- install-required-node
- unpack-dependencies
restore_cached_binary:
steps:
- attach_workspace:
at: ~/
prepare-modules-cache:
parameters:
dont-move:
type: boolean
default: false
steps:
- run: node scripts/circle-cache.js --action prepare
- unless:
condition: << parameters.dont-move >>
steps:
- run:
name: Move to /tmp dir for consistent caching across root/non-root users
command: |
mkdir -p /tmp/node_modules_cache
mv ~/cypress/node_modules /tmp/node_modules_cache/root_node_modules
mv ~/cypress/cli/node_modules /tmp/node_modules_cache/cli_node_modules
mv ~/cypress/system-tests/node_modules /tmp/node_modules_cache/system-tests_node_modules
mv ~/cypress/globbed_node_modules /tmp/node_modules_cache/globbed_node_modules
install-webkit-deps:
steps:
- run:
name: Install WebKit dependencies
command: |
npx playwright install webkit
npx playwright install-deps webkit
build-and-persist:
description: Save entire folder as artifact for other jobs to run without reinstalling
steps:
- run:
name: Sync Cloud Validations
command: |
source ./scripts/ensure-node.sh
yarn gulp syncCloudValidations
- run:
name: Build packages
command: |
source ./scripts/ensure-node.sh
yarn build
- run:
name: Generate v8 snapshot
command: |
source ./scripts/ensure-node.sh
# Minification takes some time. We only really need to do that for the binary (and we regenerate snapshots separately there)
V8_SNAPSHOT_DISABLE_MINIFY=1 yarn build-v8-snapshot-prod
- prepare-modules-cache # So we don't throw these in the workspace cache
- persist_to_workspace:
root: ~/
paths:
- cypress
install_cache_helpers_dependencies:
steps:
- run:
# Dependencies needed by circle-cache.js, before we "yarn" or unpack cached node_modules
name: Cache Helper Dependencies
working_directory: ~/
command: npm i glob@7.1.6 fs-extra@10.0.0 minimist@1.2.5 fast-json-stable-stringify@2.1.0
unpack-dependencies:
description: 'Unpacks dependencies associated with the current workflow'
steps:
- install_cache_helpers_dependencies
- run:
name: Generate Circle Cache Key
command: node scripts/circle-cache.js --action cacheKey > circle_cache_key
- run:
name: Generate platform key
command: node ./scripts/get-platform-key.js > platform_key
- restore_cache:
name: Restore cache state, to check for known modules cache existence
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
- run:
name: Move node_modules back from /tmp
command: |
if [[ -d "/tmp/node_modules_cache" ]]; then
mv /tmp/node_modules_cache/root_node_modules ~/cypress/node_modules
mv /tmp/node_modules_cache/cli_node_modules ~/cypress/cli/node_modules
mv /tmp/node_modules_cache/system-tests_node_modules ~/cypress/system-tests/node_modules
mv /tmp/node_modules_cache/globbed_node_modules ~/cypress/globbed_node_modules
rm -rf /tmp/node_modules_cache
fi
- run:
name: Restore all node_modules to proper workspace folders
command: node scripts/circle-cache.js --action unpack
restore_cached_system_tests_deps:
description: 'Restore the cached node_modules for projects in "system-tests/projects/**"'
steps:
- run:
name: Generate Circle Cache key for system tests
command: ./system-tests/scripts/cache-key.sh > system_tests_cache_key
- run:
name: Generate platform key
command: node ./scripts/get-platform-key.js > platform_key
- restore_cache:
name: Restore system tests node_modules cache
keys:
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
update_cached_system_tests_deps:
description: 'Update the cached node_modules for projects in "system-tests/projects/**"'
steps:
- run:
name: Generate Circle Cache key for system tests
command: ./system-tests/scripts/cache-key.sh > system_tests_cache_key
- run:
name: Generate platform key
command: node ./scripts/get-platform-key.js > platform_key
- restore_cache:
name: Restore cache state, to check for known modules cache existence
keys:
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
- run:
name: Bail if specific cache exists
command: |
if [[ -f "/tmp/system_tests_node_modules_installed" ]]; then
echo "No updates to system tests node modules, exiting"
circleci-agent step halt
fi
- restore_cache:
name: Restore system tests node_modules cache
keys:
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-
- run:
name: Update system-tests node_modules cache
command: yarn workspace @tooling/system-tests projects:yarn:install
- save_cache:
name: Save system tests node_modules cache
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
paths:
- /tmp/cy-system-tests-node-modules
- run: touch /tmp/system_tests_node_modules_installed
- save_cache:
name: Save system tests node_modules cache state key
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
paths:
- /tmp/system_tests_node_modules_installed
caching-dependency-installer:
description: 'Installs & caches the dependencies based on yarn lock & package json dependencies'
parameters:
only-cache-for-root-user:
type: boolean
default: false
build-better-sqlite3:
type: boolean
default: false
steps:
- install_cache_helpers_dependencies
- run:
name: Generate Circle Cache Key
command: node scripts/circle-cache.js --action cacheKey > circle_cache_key
- run:
name: Generate platform key
command: node ./scripts/get-platform-key.js > platform_key
- when:
condition: <<parameters.build-better-sqlite3>>
steps:
- restore_cache:
name: Restore cache state, to check for known modules cache existence
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}-centos7
- unless:
condition: <<parameters.build-better-sqlite3>>
steps:
- restore_cache:
name: Restore cache state, to check for known modules cache existence
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
- run:
name: Bail if cache exists
command: |
if [[ -f "node_modules_installed" ]]; then
echo "Node modules already cached for dependencies, exiting"
circleci-agent step halt
fi
- run: date +%Y-%U > cache_date
- restore_cache:
name: Restore weekly yarn cache
keys:
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }}
- run:
name: Install Node Modules
command: |
source ./scripts/ensure-node.sh
# avoid installing Percy's Chromium every time we use @percy/cli
# https://docs.percy.io/docs/caching-asset-discovery-browser-in-ci
PERCY_POSTINSTALL_BROWSER=true \
yarn --prefer-offline --frozen-lockfile --cache-folder ~/.yarn
no_output_timeout: 20m
- when:
condition: <<parameters.build-better-sqlite3>>
steps:
- build-better-sqlite3
- prepare-modules-cache:
dont-move: <<parameters.only-cache-for-root-user>> # we don't move, so we don't hit any issues unpacking symlinks
- when:
condition: <<parameters.only-cache-for-root-user>> # we don't move to /tmp since we don't need to worry about different users
steps:
- save_cache:
name: Saving node modules for root, cli, and all globbed workspace packages
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
paths:
- node_modules
- cli/node_modules
- system-tests/node_modules
- globbed_node_modules
- unless:
condition: <<parameters.only-cache-for-root-user>>
steps:
- save_cache:
name: Saving node modules for root, cli, and all globbed workspace packages
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
paths:
- /tmp/node_modules_cache
- run: touch node_modules_installed
- when:
condition: <<parameters.build-better-sqlite3>>
steps:
- save_cache:
name: Saving node-modules cache state key
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}-centos7
paths:
- node_modules_installed
- unless:
condition: <<parameters.build-better-sqlite3>>
steps:
- save_cache:
name: Saving node-modules cache state key
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
paths:
- node_modules_installed
- save_cache:
name: Save weekly yarn cache
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }}
paths:
- ~/.yarn
- ~/.cy-npm-cache
verify-build-setup:
description: Common commands run when setting up for build or yarn install
parameters:
executor:
type: executor
default: cy-doc
steps:
- run: pwd
- run:
name: print global yarn cache path
command: echo $(yarn global bin)
- run:
name: print yarn version
command: yarn versions
- unless:
condition:
# stop-only does not correctly match on windows: https://github.com/bahmutov/stop-only/issues/78
equal: [ *windows-executor, << parameters.executor >> ]
steps:
- run:
name: Stop .only
# this will catch ".only"s in js/coffee as well
command: |
source ./scripts/ensure-node.sh
yarn stop-only-all
- run:
name: Check terminal variables
## make sure the TERM is set to 'xterm' in node (Linux only)
## else colors (and tests) will fail
## See the following information
## * http://andykdocs.de/development/Docker/Fixing+the+Docker+TERM+variable+issue
## * https://unix.stackexchange.com/questions/43945/whats-the-difference-between-various-term-variables
command: |
source ./scripts/ensure-node.sh
yarn check-terminal
install-required-node:
# https://discuss.circleci.com/t/switch-nodejs-version-on-machine-executor-solved/26675/2
description: Install Node version matching .node-version
steps:
- run:
name: Install Node
command: |
source ./scripts/ensure-node.sh
echo "Installing Yarn"
npm install yarn --location=global # ensure yarn is installed with the correct node engine
yarn check-node-version
- run:
name: Check Node
command: |
source ./scripts/ensure-node.sh
yarn check-node-version
install-chrome:
description: Install Google Chrome
parameters:
channel:
description: browser channel to install
type: string
version:
description: browser version to install
type: string
steps:
- run:
name: Install Google Chrome (<<parameters.channel>>)
command: |
echo "Installing Chrome (<<parameters.channel>>) v<<parameters.version>>"
wget -O /usr/src/google-chrome-<<parameters.channel>>_<<parameters.version>>_amd64.deb "http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-<<parameters.channel>>/google-chrome-<<parameters.channel>>_<<parameters.version>>-1_amd64.deb" && \
dpkg -i /usr/src/google-chrome-<<parameters.channel>>_<<parameters.version>>_amd64.deb ; \
apt-get install -f -y && \
rm -f /usr/src/google-chrome-<<parameters.channel>>_<<parameters.version>>_amd64.deb
which google-chrome-<<parameters.channel>> || (printf "\n\033[0;31mChrome was not successfully downloaded - bailing\033[0m\n\n" && exit 1)
echo "Location of Google Chrome Installation: `which google-chrome-<<parameters.channel>>`"
echo "Google Chrome Version: `google-chrome-<<parameters.channel>> --version`"
# This code builds better-sqlite3 on CentOS 7. This is necessary because CentOS 7 has the oldest glibc version
# that we support. This job uses the cypress/centos7-builder https://hub.docker.com/repository/docker/cypress/centos7-builder/general
# image to build better-sqlite3 against an older version of glibc (2.17).
# Since this is running Docker remote, we need to copy the project into the container, and copy the built plugin out
# of the container because the host running docker does not have access to the project directory so volume mounts are
# not possible. The built plugin is copied to the project directory so it can be injected into the final binary.
build-better-sqlite3:
description: Build better-sqlite3 for CentOS 7
steps:
- setup_remote_docker
- run:
name: Build better-sqlite3 for CentOS 7
command: |
if [[ ! -f better_sqlite3.node ]]; then
set -x
apt update && apt install -y docker.io
docker run -d --name centos7-builder cypress/centos7-builder:latest /bin/bash -c "sleep 1000000000"
docker cp ~/cypress/node_modules/better-sqlite3 centos7-builder:/better-sqlite3
docker exec -it centos7-builder /bin/bash -c "cd /better-sqlite3 && source /root/.bashrc && chown -R root:root . && npm install --ignore-scripts && npx --no-install prebuild -r electron -t 27.1.3 --include-regex 'better_sqlite3.node$'"
docker cp centos7-builder:/better-sqlite3/build/Release/better_sqlite3.node ~/cypress/node_modules/better-sqlite3/build/Release/better_sqlite3.node
docker rm -f centos7-builder
cp ~/cypress/node_modules/better-sqlite3/build/Release/better_sqlite3.node ~/cypress/better_sqlite3.node
else
cp ~/cypress/better_sqlite3.node ~/cypress/node_modules/better-sqlite3/build/Release/better_sqlite3.node
fi
- save_cache:
key: better-sqlite3-{{ checksum "node_modules/better-sqlite3/package.json" }}-{{ checksum "node_modules/electron/package.json" }}-centos7
paths:
- better_sqlite3.node
- run:
name: Clean up top level better-sqlite3 file
command: |
rm ~/cypress/better_sqlite3.node
run-driver-integration-tests:
parameters:
browser:
description: browser shortname to target
type: string
install-chrome-channel:
description: chrome channel to install
type: string
default: ''
steps:
- restore_cached_workspace
- when:
condition: <<parameters.install-chrome-channel>>
steps:
- install-chrome:
channel: <<parameters.install-chrome-channel>>
version: $(node ./scripts/get-browser-version.js chrome:<<parameters.install-chrome-channel>>)
- when:
condition:
equal: [ webkit, << parameters.browser >> ]
steps:
- install-webkit-deps
- run:
name: Run driver tests in Cypress
environment:
CYPRESS_CONFIG_ENV: production
command: |
echo Current working directory is $PWD
echo Total containers $CIRCLE_NODE_TOTAL
if [[ -v MAIN_RECORD_KEY ]]; then
# internal PR
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
CYPRESS_INTERNAL_ENABLE_TELEMETRY="true" \
yarn cypress:run --record --parallel --group 5x-driver-<<parameters.browser>> --browser <<parameters.browser>> --runner-ui
else
# external PR
TESTFILES=$(circleci tests glob "cypress/e2e/**/*.cy.*" | circleci tests split --total=$CIRCLE_NODE_TOTAL)
echo "Test files for this machine are $TESTFILES"
if [[ -z "$TESTFILES" ]]; then
echo "Empty list of test files"
fi
yarn cypress:run --browser <<parameters.browser>> --spec $TESTFILES --runner-ui
fi
working_directory: packages/driver
- verify-mocha-results
- store_test_results:
path: /tmp/cypress
- store_artifacts:
path: /tmp/artifacts
- store-npm-logs
windows-install-chrome:
parameters:
browser:
description: browser shortname to target
type: string
steps:
- run:
# TODO: How can we have preinstalled browsers on CircleCI?
name: 'Install Chrome on Windows'
command: |
# install with `--ignore-checksums` to avoid checksum error
# https://www.gep13.co.uk/blog/chocolatey-error-hashes-do-not-match
[[ $PLATFORM == 'windows' && '<<parameters.browser>>' == 'chrome' ]] && choco install googlechrome -y --ignore-checksums || [[ $PLATFORM != 'windows' ]]
run-new-ui-tests:
parameters:
package:
description: package to target
type: enum
enum: ['frontend-shared', 'launchpad', 'app', 'reporter']
browser:
description: browser shortname to target
type: string
percy:
description: enable percy
type: boolean
default: false
type:
description: ct or e2e
type: enum
enum: ['ct', 'e2e']
debug:
description: debug option
type: string
default: ''
steps:
- restore_cached_workspace
- windows-install-chrome:
browser: <<parameters.browser>>
- run:
command: |
echo Current working directory is $PWD
echo Total containers $CIRCLE_NODE_TOTAL
if [[ -v MAIN_RECORD_KEY ]]; then
# internal PR
cmd=$([[ <<parameters.percy>> == 'true' ]] && echo 'yarn percy exec --parallel -- --') || true
DEBUG=<<parameters.debug>> \
CYPRESS_CONFIG_ENV=production \
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \
PERCY_ENABLE=${PERCY_TOKEN:-0} \
PERCY_PARALLEL_TOTAL=-1 \
CYPRESS_INTERNAL_ENABLE_TELEMETRY="true" \
$cmd yarn workspace @packages/<<parameters.package>> cypress:run:<<parameters.type>> --browser <<parameters.browser>> --record --parallel --group <<parameters.package>>-<<parameters.type>>
else
# external PR
# To make `circleci tests` work correctly, we need to step into the package folder.
cd packages/<<parameters.package>>
if [[ <<parameters.type>> == 'ct' ]]; then
# component tests are located side by side with the source codes.
# for the app component tests, ignore specs that are known to cause failures on contributor PRs (see https://discuss.circleci.com/t/how-to-exclude-certain-files-from-circleci-test-globbing/41028)
TESTFILES=$(find src -regextype posix-extended -name '*.cy.*' -not -regex '.*(FileMatch|PromoAction|SelectorPlayground|useDurationFormat|useTestingType|SpecPatterns).cy.*' | circleci tests split --total=$CIRCLE_NODE_TOTAL)
else
GLOB="cypress/e2e/**/*cy.*"
TESTFILES=$(circleci tests glob "$GLOB" | circleci tests split --total=$CIRCLE_NODE_TOTAL)
fi
echo "Test files for this machine are $TESTFILES"
# To run the `yarn` command, we need to walk out of the package folder.
cd ../..
DEBUG=<<parameters.debug>> \
CYPRESS_CONFIG_ENV=production \
PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \
PERCY_ENABLE=${PERCY_TOKEN:-0} \
PERCY_PARALLEL_TOTAL=-1 \
yarn workspace @packages/<<parameters.package>> cypress:run:<<parameters.type>> --browser <<parameters.browser>> --spec $TESTFILES
fi
- run:
command: |
if [[ <<parameters.package>> == 'app' && <<parameters.percy>> == 'true' && -d "packages/app/cypress/screenshots/runner/screenshot/screenshot.cy.tsx/percy" ]]; then
PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \
PERCY_ENABLE=${PERCY_TOKEN:-0} \
PERCY_PARALLEL_TOTAL=-1 \
yarn percy upload packages/app/cypress/screenshots/runner/screenshot/screenshot.cy.tsx/percy
else
echo "skipping percy screenshots uploading"
fi
- store_test_results:
path: /tmp/cypress
- store-npm-logs
run-system-tests:
parameters:
browser:
description: browser shortname to target
type: string
steps:
- restore_cached_workspace
- restore_cached_system_tests_deps
- when:
condition:
equal: [ webkit, << parameters.browser >> ]
steps:
- install-webkit-deps
- run:
name: Run system tests
environment:
CYPRESS_COMMERCIAL_RECOMMENDATIONS: '0'
command: |
ALL_SPECS=`circleci tests glob "/root/cypress/system-tests/test/*spec*"`
SPECS=
for file in $ALL_SPECS; do
# filter out non_root tests, they have their own stage
if [[ "$file" == *"non_root"* ]]; then
echo "Skipping $file"
continue
fi
SPECS="$SPECS $file"
done
SPECS=`echo $SPECS | xargs -n 1 | circleci tests split --split-by=timings`
echo SPECS=$SPECS
yarn workspace @tooling/system-tests test:ci $SPECS --browser <<parameters.browser>>
- verify-mocha-results
- store_test_results:
path: /tmp/cypress
- store_artifacts:
path: /tmp/artifacts
- store-npm-logs
run-binary-system-tests:
steps:
- restore_cached_workspace
- restore_cached_system_tests_deps
- run:
name: Run system tests
environment:
CYPRESS_COMMERCIAL_RECOMMENDATIONS: '0'
command: |
ALL_SPECS=`circleci tests glob "$HOME/cypress/system-tests/test-binary/*spec*"`
SPECS=`echo $ALL_SPECS | xargs -n 1 | circleci tests split --split-by=timings`
echo SPECS=$SPECS
yarn workspace @tooling/system-tests test:ci $SPECS
- verify-mocha-results
- store_test_results:
path: /tmp/cypress
- store_artifacts:
path: /tmp/artifacts
- store-npm-logs
store-npm-logs:
description: Saves any NPM debug logs as artifacts in case there is a problem
steps:
- store_artifacts:
path: ~/.npm/_logs
post-install-comment:
parameters:
package_url_path:
type: string
default: npm-package-url.json
binary_url_path:
type: string
default: binary-url.json
description: Post GitHub comment with a blurb on how to install pre-release version
steps:
- run:
name: Post pre-release install comment
command: |
node scripts/add-install-comment.js \
--npm << parameters.package_url_path >> \
--binary << parameters.binary_url_path >>
verify-mocha-results:
description: Double-check that Mocha tests ran as expected.
parameters:
expectedResultCount:
description: The number of result files to expect, ie, the number of Mocha test suites that ran.
type: integer
## by default, assert that at least 1 test ran
default: 0
steps:
- run:
name: 'Verify Mocha Results'
command: |
source ./scripts/ensure-node.sh
yarn verify:mocha:results <<parameters.expectedResultCount>>
clone-repo-and-checkout-branch:
description: |
Clones an external repo and then checks out the branch that matches the next version otherwise uses 'master' branch.
parameters:
repo:
description: "Name of the github repo to clone like: cypress-example-kitchensink"
type: string
pull_request_id:
description: Pull request number to check out before installing and testing
type: integer
default: 0
steps:
- restore_cached_binary
- run:
name: "Cloning test project and checking out release branch: <<parameters.repo>>"
working_directory: /tmp/<<parameters.repo>>
command: |
git clone --depth 1 --no-single-branch https://github.com/cypress-io/<<parameters.repo>>.git .
cd ~/cypress/..
# install some deps for get-next-version
npm i semver@7.3.2 conventional-recommended-bump@6.1.0 conventional-changelog-angular@5.0.12 minimist@1.2.5
NEXT_VERSION=$(node ./cypress/scripts/get-next-version.js)
cd -
git checkout $NEXT_VERSION || true
- when:
condition: <<parameters.pull_request_id>>
steps:
- run:
name: Check out PR <<parameters.pull_request_id>>
working_directory: /tmp/<<parameters.repo>>
command: |
git fetch origin pull/<<parameters.pull_request_id>>/head:pr-<<parameters.pull_request_id>>
git checkout pr-<<parameters.pull_request_id>>
test-binary-against-rwa:
description: |
Takes the built binary and NPM package, clones the RWA repo
and runs the new version of Cypress against it.
parameters:
repo:
description: "Name of the github repo to clone like"
type: string
default: "cypress-realworld-app"
browser:
description: Name of the browser to use, like "electron", "chrome", "firefox"
type: enum
enum: ["", "electron", "chrome", "firefox"]
default: ""
command:
description: Test command to run to start Cypress tests
type: string
default: "CYPRESS_INTERNAL_ENABLE_TELEMETRY=1 CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY CYPRESS_PROJECT_ID=ypt4pf yarn cypress:run"
# if the repo to clone and test is a monorepo, you can
# run tests inside a specific subfolder
folder:
description: Subfolder to test in
type: string
default: ""
# you can test new features in the test runner against recipes or other repos
# by opening a pull request in those repos and running this test job
# against a pull request number in the example repo
pull_request_id:
description: Pull request number to check out before installing and testing
type: integer
default: 0
wait-on:
description: Whether to use wait-on to wait on a server to be booted
type: string
default: ""
server-start-command:
description: Server start command for repo
type: string
default: "CI=true yarn start"
steps:
- clone-repo-and-checkout-branch:
repo: <<parameters.repo>>
- when:
condition: <<parameters.pull_request_id>>
steps:
- run:
name: Check out PR <<parameters.pull_request_id>>
working_directory: /tmp/<<parameters.repo>>
command: |
git fetch origin pull/<<parameters.pull_request_id>>/head:pr-<<parameters.pull_request_id>>
git checkout pr-<<parameters.pull_request_id>>
git log -n 2
- run:
command: yarn
working_directory: /tmp/<<parameters.repo>>
- run:
name: Install Cypress
working_directory: /tmp/<<parameters.repo>>
# force installing the freshly built binary
command: |
CYPRESS_INSTALL_BINARY=~/cypress/cypress.zip npm i --legacy-peer-deps ~/cypress/cypress.tgz && [[ -f yarn.lock ]] && yarn
- run:
name: Print Cypress version
working_directory: /tmp/<<parameters.repo>>
command: npx cypress version
- run:
name: Types check 🧩 (maybe)
working_directory: /tmp/<<parameters.repo>>
command: yarn types
- run:
# NOTE: we do not need to wait for the vite dev server to start
working_directory: /tmp/<<parameters.repo>>
command: <<parameters.server-start-command>>
background: true
- when:
condition: <<parameters.folder>>
steps:
- when:
condition: <<parameters.browser>>
steps:
- run:
name: Run tests using browser "<<parameters.browser>>"
working_directory: /tmp/<<parameters.repo>>/<<parameters.folder>>
command: |
<<parameters.command>> --browser <<parameters.browser>> --record false
- unless:
condition: <<parameters.browser>>
steps:
- run:
name: Run tests using command
working_directory: /tmp/<<parameters.repo>>/<<parameters.folder>>
command: <<parameters.command>>
- unless:
condition: <<parameters.folder>>
steps:
- when:
condition: <<parameters.browser>>
steps:
- run:
name: Run tests using browser "<<parameters.browser>>"
working_directory: /tmp/<<parameters.repo>>
command: <<parameters.command>> --browser <<parameters.browser>> --record false
- unless:
condition: <<parameters.browser>>
steps:
- run:
name: Run tests using command
working_directory: /tmp/<<parameters.repo>>
command: <<parameters.command>>
- store-npm-logs
test-binary-against-repo:
description: |
Takes the built binary and NPM package, clones given example repo
and runs the new version of Cypress against it.
parameters:
repo:
description: "Name of the github repo to clone like: cypress-example-kitchensink"
type: string
browser:
description: Name of the browser to use, like "electron", "chrome", "firefox"
type: enum
enum: ["", "electron", "chrome", "firefox"]
default: ""
command:
description: Test command to run to start Cypress tests
type: string
default: "npm run e2e"
build-project:
description: Should the project build script be executed
type: boolean
default: true
# if the repo to clone and test is a monorepo, you can
# run tests inside a specific subfolder
folder:
description: Subfolder to test in
type: string
default: ""
# you can test new features in the test runner against recipes or other repos
# by opening a pull request in those repos and running this test job
# against a pull request number in the example repo
pull_request_id:
description: Pull request number to check out before installing and testing
type: integer
default: 0
wait-on:
description: Whether to use wait-on to wait on a server to be booted
type: string
default: ""
server-start-command:
description: Server start command for repo
type: string
default: "npm start --if-present"
steps:
- run:
name: Install yarn if not already installed
command: |
yarn --version || npm i -g yarn
- clone-repo-and-checkout-branch:
repo: <<parameters.repo>>
pull_request_id: <<parameters.pull_request_id>>
- run:
# Ensure we're installing the node-version for the cloned repo
command: |
if [[ -f .node-version ]]; then
branch="<< pipeline.git.branch >>"