-
Notifications
You must be signed in to change notification settings - Fork 2k
/
config.yml
1202 lines (1143 loc) · 41.9 KB
/
config.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
orbs:
slack: circleci/slack@3.4.2
win: circleci/windows@2.2.0
references:
defaults: &defaults
working_directory: ~/wp-calypso
docker:
- image: circleci/node:12.18.4-browsers
environment:
CIRCLE_ARTIFACTS: /tmp/artifacts
CIRCLE_TEST_REPORTS: /tmp/test_results
PUPPETEER_SKIP_DOWNLOAD: 'true'
DETECT_CHROMEDRIVER_VERSION: 'false'
CHROMEDRIVER_FILEPATH: /usr/local/bin/chromedriver
NODE_OPTIONS: --max-old-space-size=3072
npm_config_cache: /home/circleci/.cache/yarn
YARN_CACHE_FOLDER: /home/circleci/.cache/yarn
desktop_defaults: &desktop_defaults
working_directory: ~/wp-calypso
setup-results-and-artifacts: &setup-results-and-artifacts
name: Create Directories for Results and Artifacts
command: |
mkdir -p \
"$CIRCLE_ARTIFACTS/notifications-panel" \
"$CIRCLE_ARTIFACTS/translate" \
"$CIRCLE_ARTIFACTS/screenshots" \
"$CIRCLE_ARTIFACTS/wpcom-block-editor" \
"$CIRCLE_TEST_REPORTS/client" \
"$CIRCLE_TEST_REPORTS/eslint" \
"$CIRCLE_TEST_REPORTS/integration" \
"$CIRCLE_TEST_REPORTS/packages" \
"$CIRCLE_TEST_REPORTS/server" \
"$CIRCLE_TEST_REPORTS/e2ereports" \
"$HOME/jest-cache"
# Jest cache caching
#
# Jest uses a cache to speed up builds. If we persist this cache across builds,
# we can improve the speed of subsequent builds.
#
# Circle caches never overwritten, so we must ensure that Jest caches from different jobs
# do not collide or we'll only cache 1 job.
#
# We also need to ensure that different nodes and different total nodes do not collide.
# When we split tests, different nodes will receive a different set of tests so each node's
# cache should be unique.
#
# Finally, we cache on the branch and revision, falling back to origin/HEAD. This should give us
# pretty good "nearest neighbor" primer for the Jest cache.
#
# More about the CircleCI cache: https://circleci.com/docs/2.0/caching
restore-jest-cache: &restore-jest-cache
name: Restore Jest cache
keys:
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v8-jest-{{ .Environment.CIRCLE_JOB }}-{{ .Environment.CIRCLE_NODE_INDEX }}/{{ .Environment.CIRCLE_NODE_TOTAL }}-{{ .Branch }}-{{ .Revision }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v8-jest-{{ .Environment.CIRCLE_JOB }}-{{ .Environment.CIRCLE_NODE_INDEX }}/{{ .Environment.CIRCLE_NODE_TOTAL }}-{{ .Branch }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v8-jest-{{ .Environment.CIRCLE_JOB }}-{{ .Environment.CIRCLE_NODE_INDEX }}/{{ .Environment.CIRCLE_NODE_TOTAL }}-trunk
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v8-jest-{{ .Environment.CIRCLE_JOB }}-{{ .Environment.CIRCLE_NODE_INDEX }}/{{ .Environment.CIRCLE_NODE_TOTAL }}
save-jest-cache: &save-jest-cache
name: Save Jest cache
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v8-jest-{{ .Environment.CIRCLE_JOB }}-{{ .Environment.CIRCLE_NODE_INDEX }}/{{ .Environment.CIRCLE_NODE_TOTAL }}-{{ .Branch }}-{{ .Revision }}
paths:
- ~/jest-cache
#
# Build cache
#
# This contains caches used by the build process (mainly webpack loaders and plugins)
restore-build-cache: &restore-build-cache
name: Restore build cache
keys:
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-build-{{ .Branch }}-{{ .Revision }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-build-{{ .Branch }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-build-trunk
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-build
save-build-cache: &save-build-cache
name: Save build cache
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-build-{{ .Branch }}-{{ .Revision }}
paths:
- .cache
# Git cache
#
# Calypso is a big repository with a lot of history. It can take a long time to do a full checkout.
# By including the `.git` directory in the cache, we can speed things up by only needing to update
# the local repository.
#
# We cache on the branch and revision, falling back to origin/HEAD, or any recent cache.
#
# More about the CircleCI cache: https://circleci.com/docs/2.0/caching
restore-git-cache: &restore-git-cache
name: Restore git cache
keys:
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v2-git-{{ .Branch }}-{{ .Revision }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v2-git-{{ .Branch }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v2-git-trunk
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v2-git
update-git: &update-git
name: Update all branches
command: git fetch --force origin
save-git-cache: &save-git-cache
name: Save git cache
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v2-git-{{ .Branch }}-{{ .Revision }}
paths:
- '.git'
# yarn cache
#
# yarn caches the modules it installs in ~/.cache/yarn.
# We cache that cache to save time pulling modules from the network.
#
#
# Some prior art:
# - https://github.com/Automattic/wp-calypso/pull/25431
# - https://github.com/Automattic/wp-calypso/pull/25487
# - https://github.com/Automattic/wp-calypso/pull/27180
#
# More about the CircleCI cache: https://circleci.com/docs/2.0/caching and https://circleci.com/docs/2.0/yarn/
restore-yarn-cache: &restore-yarn-cache
name: 'Restore yarn cache'
keys:
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-yarn-modules-{{ checksum ".nvmrc" }}-{{ checksum "yarn.lock" }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-yarn-modules-{{ checksum ".nvmrc" }}
yarn-install: &yarn-install
name: Install dependencies
command: |
source "$HOME/.nvm/nvm.sh"
nvm use
npm install -g yarn
yarn install --frozen-lockfile
update-node: &update-node
name: Update node
command: |
set +e
set +x
export NVM_DIR="$HOME/.nvm" && (
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
cd "$NVM_DIR"
git checkout v0.35.3
) && \. "$NVM_DIR/nvm.sh" --no-use
nvm install
nvm use
# This is used later to send a custom UA string. `google-chrome` is in the PATH in all circleci-browser images
save-chrome-version: &save-chrome-version
name: Save chrome version
command: |
google-chrome --version > .chromedriver_version
echo -n "Google Chrome version: " && cat .chromedriver_version
save-yarn-cache: &save-yarn-cache
name: 'Save yarn cache'
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-yarn-modules-{{ checksum ".nvmrc" }}-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
set-e2e-variables: &set-e2e-variables
name: Set e2e environment variables
command: |
echo 'export NODE_CONFIG_ENV=test' >> $BASH_ENV &&
echo 'export BRANCHNAME=$CIRCLE_BRANCH' >> $BASH_ENV &&
echo 'export HIGHLIGHT_ELEMENT=true' >> $BASH_ENV
move-e2e-artifacts: &move-e2e-artifacts
name: Move report and screenshots
when: always
command: |
cp -r ./reports $CIRCLE_TEST_REPORTS/e2ereports &&
cp -r ./screenshots $CIRCLE_ARTIFACTS/screenshots
desktop-install-app-deps: &desktop-install-app-deps
name: Install Desktop Dependencies
command: |
source "$HOME/.nvm/nvm.sh"
nvm use
npm install -g yarn
yarn run build-desktop:install-app-deps
desktop-cache-paths: &desktop-cache-paths
- desktop/build
- desktop/client
- desktop/config
- desktop/public
- desktop/resource/certificates/win.p12
- desktop/resource/certificates/mac.p12
desktop-decrypt-assets: &desktop-decrypt-assets
name: Decrypt desktop app assets
command: |
openssl aes-256-cbc -md md5 -d -in desktop/resource/calypso/secrets.json.enc -out config/secrets.json -k "${CALYPSO_SECRETS_ENCRYPTION_KEY}"
openssl aes-256-cbc -md md5 -d -in desktop/resource/certificates/mac.p12.enc -out desktop/resource/certificates/mac.p12 -k "${CALYPSO_SECRETS_ENCRYPTION_KEY}"
openssl aes-256-cbc -md md5 -d -in desktop/resource/certificates/win.p12.enc -out desktop/resource/certificates/win.p12 -k "${CALYPSO_SECRETS_ENCRYPTION_KEY}"
desktop-restore-yarn-cache: &desktop-restore-yarn-cache
name: Restore yarn cache
keys:
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-desktop-yarn-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum ".nvmrc" }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-desktop-yarn-{{ .Environment.CIRCLE_JOB }}-{{ arch }}
desktop-save-yarn-cache: &desktop-save-yarn-cache
name: Save yarn cache
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-desktop-yarn-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum ".nvmrc" }}
paths:
- ~/.cache/yarn
desktop-restore-packages-cache: &desktop-restore-packages-cache
name: Restore packages cache
keys:
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-desktop-packages-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "packages-hash" }}
desktop-save-packages-cache: &desktop-save-packages-cache
name: Save packages cache
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-desktop-packages-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "packages-hash" }}
paths:
- packages
- packages-cache-restored
desktop-restore-calypso-build-cache: &desktop-restore-calypso-build-cache
name: Restore Calypso build cache
keys:
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-desktop-calypso-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ .Branch }}-{{ .Revision }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-desktop-calypso-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ .Branch }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-desktop-calypso-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-trunk
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-desktop-calypso-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}
desktop-save-calypso-build-cache: &desktop-save-calypso-build-cache
name: Save Calypso build cache
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-desktop-calypso-build-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ .Branch }}-{{ .Revision }}
paths:
- .cache
desktop-notify-github-success: &desktop-notify-github-success
name: Notify Github Success
when: on_success
command: cd desktop && yarn ci:github:dismiss-review
desktop-notify-github-failure: &desktop-notify-github-failure
name: Notify Github Failure
when: on_fail
command: cd desktop && yarn ci:github:add-review
desktop-notify-slack-failure: &desktop-notify-slack-failure
webhook: '$SLACK_WP_DESKTOP_E2E'
fail_only: true
mentions: '$CIRCLE_USERNAME'
failure_message: ':red_circle: wp-desktop tests for $CIRCLE_BRANCH have failed.\n\nCalypso PR: $CIRCLE_PULL_REQUEST'
commands:
prepare:
description: 'Prepare Job'
steps:
# folders to collect results
- run: *setup-results-and-artifacts
- attach_workspace:
at: '~'
- run: *update-node
store-artifacts-and-test-results:
description: Stores artifacts and test results
steps:
- store_test_results:
path: /tmp/test_results
- store_artifacts:
path: /tmp/test_results
- store_artifacts:
path: /tmp/artifacts
jobs:
setup:
<<: *defaults
steps:
# repo
- restore_cache: *restore-git-cache
- checkout
- run: *update-git
- save_cache: *save-git-cache
- run: *update-node
# npm dependencies
- restore_cache: *restore-yarn-cache
- run: *yarn-install
- save_cache: *save-yarn-cache
- persist_to_workspace:
root: '~'
paths:
- wp-calypso
translate:
<<: *defaults
steps:
- prepare
- run:
name: Extract strings
working_directory: wp-babel-makepot
command: npx https://github.com/Automattic/wp-babel-makepot "~/wp-calypso/{client,packages,apps}/**/*.{js,jsx,ts,tsx}" --ignore "**/node_modules/**,**/test/**,**/*.d.ts" --base "$HOME/wp-calypso" --output "$CIRCLE_ARTIFACTS/translate/calypso-strings.pot"
- run:
name: Build New Strings .pot
when: always
command: |
git clone --single-branch --depth=1 https://github.com/Automattic/gp-localci-client.git
bash gp-localci-client/generate-new-strings-pot.sh "$CIRCLE_BRANCH" "$CIRCLE_SHA1" "$CIRCLE_ARTIFACTS/translate"
rm -rf gp-localci-client
- store-artifacts-and-test-results
- run:
name: Notify GlotPress translations are ready
when: always
command: |
curl -X POST https://translate.wordpress.com/api/localci/-relay-new-strings-to-gh \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"payload": {
"branch": "'"$CIRCLE_BRANCH"'",
"build_num": '"$CIRCLE_BUILD_NUM"',
"pull_requests": [
{
"url": "'"$CIRCLE_PULL_REQUEST"'"
}
],
"reponame": "'"$CIRCLE_PROJECT_REPONAME"'",
"username": "'"$CIRCLE_PROJECT_USERNAME"'",
"vcs_revision": "'"$CIRCLE_SHA1"'",
"vcs_type": "github"
}
}'
typecheck-strict:
<<: *defaults
parallelism: 1
steps:
- prepare
- run:
name: TypeScript strict typecheck of individual subprojects
command: yarn run tsc --project client/landing/gutenboarding
lint:
<<: *defaults
parallelism: 1
steps:
- prepare
- run:
name: Lint Config Keys
when: always
command: yarn run lint:config-defaults
- run:
name: Lint yarn.lock
when: always
command: |
yarn
DIRTY_FILES=$(git status --porcelain 2>/dev/null)
if [[ ! -z "$DIRTY_FILES" ]]; then
echo "Repository contains uncommitted changes: "
echo "$DIRTY_FILES"
echo "You need to checkout the branch, run 'yarn' and commit those files."
exit 1
fi
- run:
name: Lint Client and Server
when: always
command: |
# We may not have files to lint which returns non-0 exit
# Ensure this does not cause job failure (see `|| exit 0`)
FILES_TO_LINT=$(
git diff --name-only --diff-filter=d origin... \
| grep -E '^(client/|server/|packages/)' \
| grep -E '\.[jt]sx?$'
) || exit 0
if [[ ! -z $FILES_TO_LINT ]]; then
./node_modules/.bin/eslint \
--format junit \
--output-file "$CIRCLE_TEST_REPORTS/eslint/results.xml" \
$FILES_TO_LINT
fi
- store_test_results:
path: /tmp/test_results
build-notifications:
<<: *defaults
parallelism: 1
steps:
- prepare
- run:
name: Build Notifications Panel
command: |
cd apps/notifications/ && NODE_ENV=production yarn run build --output-path=$CIRCLE_ARTIFACTS/notifications-panel
- store-artifacts-and-test-results
build-o2-blocks:
<<: *defaults
parallelism: 1
steps:
- prepare
- run:
name: Build Gutenberg Blocks for internal p2s
command: |
cd apps/o2-blocks/ && NODE_ENV=production yarn run build --output-path=$CIRCLE_ARTIFACTS/o2-blocks
- store-artifacts-and-test-results
build-wpcom-block-editor:
<<: *defaults
parallelism: 1
steps:
- prepare
- run:
name: Build the block editor in WordPress.com integration utils package
command: |
cd apps/wpcom-block-editor/ && yarn build --output-path=$CIRCLE_ARTIFACTS/wpcom-block-editor
- store-artifacts-and-test-results
test-client:
<<: *defaults
parallelism: 6
steps:
- prepare
- restore_cache: *restore-jest-cache
- run:
name: Run Client Tests
no_output_timeout: 2m
command: |
# Use Jest to list tests to run via config
./node_modules/.bin/jest \
--listTests \
--config=test/client/jest.config.js \
> ~/jest-tests
# Run jest on the CircleCI split for parallelization across containers
# Avoid using `--split-by=timings` here so that per-node Jest caches
# receive a stable sub-set of tests for optimal cache usage.
JEST_JUNIT_OUTPUT_DIR="$CIRCLE_TEST_REPORTS/client" \
JEST_JUNIT_OUTPUT_NAME="results.xml" \
./node_modules/.bin/jest \
--cacheDirectory="$HOME/jest-cache" \
--ci \
--maxWorkers=2 \
--reporters=default \
--reporters=jest-junit \
--runTestsByPath \
--silent \
--config=test/client/jest.config.js \
$( circleci tests split < ~/jest-tests )
- save_cache: *save-jest-cache
- store-artifacts-and-test-results
test-integration:
<<: *defaults
parallelism: 1
steps:
- prepare
- restore_cache: *restore-jest-cache
- run:
name: Run Integration Tests
command: |
JEST_JUNIT_OUTPUT_DIR="$CIRCLE_TEST_REPORTS/integration" \
JEST_JUNIT_OUTPUT_NAME="results.xml" \
./node_modules/.bin/jest \
--cacheDirectory="$HOME/jest-cache" \
--ci \
--maxWorkers=2 \
--reporters=default \
--reporters=jest-junit \
--silent \
--config=test/integration/jest.config.js
- save_cache: *save-jest-cache
- store-artifacts-and-test-results
test-packages:
<<: *defaults
parallelism: 1
steps:
- prepare
- restore_cache: *restore-jest-cache
- run:
name: Run Package Tests
no_output_timeout: 2m
command: |
JEST_JUNIT_OUTPUT_DIR="$CIRCLE_TEST_REPORTS/packages" \
JEST_JUNIT_OUTPUT_NAME="results.xml" \
./node_modules/.bin/jest \
--cacheDirectory="$HOME/jest-cache" \
--ci \
--maxWorkers=2 \
--reporters=default \
--reporters=jest-junit \
--silent \
--config=test/packages/jest.config.js
- save_cache: *save-jest-cache
- store-artifacts-and-test-results
test-server:
<<: *defaults
parallelism: 1
steps:
- prepare
- restore_cache: *restore-jest-cache
- run:
name: Run Server Tests
no_output_timeout: 2m
command: |
JEST_JUNIT_OUTPUT_DIR="$CIRCLE_TEST_REPORTS/server" \
JEST_JUNIT_OUTPUT_NAME="results.xml" \
./node_modules/.bin/jest \
--cacheDirectory="$HOME/jest-cache" \
--ci \
--maxWorkers=2 \
--reporters=default \
--reporters=jest-junit \
--silent \
--config=test/server/jest.config.js
- save_cache: *save-jest-cache
- store-artifacts-and-test-results
# Prime calypso.live so it has a build ready
#
# We can send a request to calypso.live so that it gets a build ready.
# This saves time waiting later when waiting for the calypso.live
#
# Expected usage:
# - After setup
# - Only on branches (not the primary branch)
#
prime-calypso-live:
docker:
- image: buildpack-deps
working_directory: ~/wp-calypso
steps:
- run:
name: Prime calypso.live
command: |
if [[ -z $CIRCLE_PR_USERNAME ]]; then
curl --silent "https://hash-$CIRCLE_SHA1.calypso.live"
fi
# Wait for calypso.live to be ready
#
# Expected usage:
# - After main tests have passed (test-client, test-server)
# - Before e2e tests run
#
wait-calypso-live:
docker:
- image: buildpack-deps
working_directory: ~/wp-calypso
steps:
- run:
name: Check external author
command: |
if [[ ! -z $CIRCLE_PR_USERNAME ]]; then
echo 'PRs from external authors cannot run on calypso.live'
exit 1
fi
- restore_cache: *restore-git-cache
- checkout
# Don't bother updating the git cache here, it would be the second time in the workflow
- run:
name: Wait for calypso.live build
command: ./test/e2e/scripts/wait-for-running-branch.sh
test-e2e:
<<: *defaults
working_directory: ~/wp-calypso/test/e2e
parallelism: 2
steps:
- prepare
- run: *set-e2e-variables
- run: *save-chrome-version
- run: yarn run decryptconfig
- run: ./scripts/randomize.sh specs
- run: ./scripts/run-wrapper.sh
- run: *move-e2e-artifacts
- store-artifacts-and-test-results
- slack/status:
webhook: $SLACK_E2E
test-e2e-canary:
<<: *defaults
working_directory: ~/wp-calypso/test/e2e
parameters:
test-flags:
type: string
default: '-C'
test-target:
type: string
default: ''
jetpack-host:
type: string
default: ''
slack-webhook:
type: string
default: $SLACK_E2E
steps:
- prepare
- run: *set-e2e-variables
- run: *save-chrome-version
- run: sudo apt-get install -y fonts-ipafont-gothic xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic fonts-wqy-zenhei
- run:
name: Skip Jetpack Tests if needed
command: |
# If the skip jetpack env var is set, notify slack channel and skip the rest of the steps
if [[ "$SKIP_JETPACK" == "true" && "<< parameters.test-target >>" == "JETPACK" ]]; then
curl -X POST -H 'Content-type: application/json' \
--data \
"{ \
\"attachments\": [ \
{ \
\"text\": \"Jetpack tests were skipped\", \
\"fields\": [ \
{ \
\"title\": \"Project\", \
\"value\": \"$CIRCLE_PROJECT_REPONAME\", \
\"short\": true \
}, \
{ \
\"title\": \"Job Number\", \
\"value\": \"$CIRCLE_BUILD_NUM\", \
\"short\": true \
} \
], \
\"actions\": [ \
{ \
\"type\": \"button\", \
\"text\": \"Visit Job\", \
\"url\": \"$CIRCLE_BUILD_URL\" \
} \
], \
\"color\": \"#FF0000\" \
} \
] \
}" << parameters.slack-webhook >>
circleci-agent step halt
fi
- run: yarn run decryptconfig
- run:
name: Run Canary Tests
command: |
env TARGET=<< parameters.test-target >> JETPACKHOST=<< parameters.jetpack-host >> ./run.sh -R << parameters.test-flags >>
- run: *move-e2e-artifacts
- store-artifacts-and-test-results
- slack/status:
webhook: << parameters.slack-webhook >>
wp-desktop-source:
# Use Linux machine executor, NOT docker image for higher available RAM (7.5GB)
machine:
image: ubuntu-1604:202004-01
resource_class: medium
<<: *desktop_defaults
environment:
NVM_DIR: '/opt/circleci/.nvm'
VERSION: << pipeline.git.tag >>
CHROMEDRIVER_SKIP_DOWNLOAD: 'true'
DETECT_CHROMEDRIVER_VERSION: 'false'
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true'
NODE_OPTIONS: --max-old-space-size=6144
YARN_CACHE_FOLDER: ~/.cache/yarn
steps:
- checkout
- when:
condition: << pipeline.git.tag >>
steps:
- run:
name: Ensure package.json Version And Tag Match
command: cd desktop/bin && node validate_tag.js $VERSION
- run: *desktop-decrypt-assets
- run:
name: Compute cache checksums
command: |
# Get latest commit that modified packages directory
echo "$(git log -n 1 --format='%h' -- packages .nvmrc yarn.lock)" > packages-hash
- restore_cache: *desktop-restore-yarn-cache
- restore_cache: *desktop-restore-packages-cache
- restore_cache: *desktop-restore-calypso-build-cache
- run:
name: Install Linux deps
command: |
sudo apt update
sudo apt-get install -y git-restore-mtime bc
- run:
name: Restore file modified time
command: |
# Webpack cache-loader depends on file mtime, which is reset by "git clone".
# Use git-restore-mtime to restore original modification time of files based
# on date of most recent commit that modified them.
# Ref: http://manpages.ubuntu.com/manpages/bionic/man1/git-restore-mtime.1.html
#
# Note: this utility is highly optimized and is able to process all Calypso
# files in less than 10 seconds!
/usr/lib/git-core/git-restore-mtime --force --commit-time --skip-missing
- run:
name: Install Dependencies
command: |
# Install Node
# Note: this syntax is required to load NVM_DIR in the machine executor.
# Ref: https://discuss.circleci.com/t/circleci-forgetting-node-version-on-machine-executor/28813
set +e
set +x
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install
nvm use
npm install -g yarn
# defer to restored packages whenever possible
# On a Machine executor, using cached built packages is significant:
# https://github.com/Automattic/wp-calypso/pull/44696#discussion_r468010942
if [ -f packages-cache-restored ]; then
export DISABLEPOSTINSTALL=1
fi
yarn install --frozen-lockfile
echo "$(cat packages-hash)" > packages-cache-restored
- save_cache: *desktop-save-yarn-cache
- run:
name: Build Desktop and Calypso source
no_output_timeout: 15m
command: |
set +e
set +x
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use
yarn run build-desktop:source
- save_cache: *desktop-save-packages-cache
- save_cache: *desktop-save-calypso-build-cache
- persist_to_workspace:
root: /home/circleci/wp-calypso
paths: *desktop-cache-paths
- run: *desktop-notify-github-failure
- slack/status: *desktop-notify-slack-failure
wp-desktop-mac:
macos:
xcode: '10.1.0'
shell: /bin/bash --login
working_directory: /Users/distiller/wp-calypso
steps:
- checkout
- attach_workspace:
at: /Users/distiller/wp-calypso
- run: *update-node
- run: *desktop-install-app-deps
- run:
name: Build Desktop Mac
no_output_timeout: 30m
environment:
CSC_LINK: resource/certificates/mac.p12
CSC_FOR_PULL_REQUEST: true
command: |
set +e
source $HOME/.nvm/nvm.sh
nvm use
# Build all artifacts only when project config changes.
# Otherwise only build application executable required for end-to-end testing.
! git diff --name-only origin/master...HEAD | grep -E -q 'desktop/package.json|desktop/yarn.lock' && ELECTRON_BUILDER_ARGS='-c.mac.target=dir'
ELECTRON_BUILDER_ARGS=$ELECTRON_BUILDER_ARGS yarn run build-desktop:app
- run:
name: e2e Tests
command: |
source $HOME/.nvm/nvm.sh
nvm use
npm install -g yarn
yarn run test-desktop:e2e
- run:
when: always
name: Persist Mac Executable
command: |
# If this isn't a full artifact build, ensure to persist the built application for inspection
test -f desktop/release/*.zip || ditto -ck --rsrc --sequesterRsrc desktop/release/mac desktop/release/mac.app.zip
- run:
when: always
name: Clean Up
command: |
rm -rf desktop/release/mac
- store_artifacts:
when: always
path: desktop/release
- store_artifacts:
when: always
path: desktop/e2e/logs
- store_artifacts:
when: always
path: desktop/e2e/screenshots
- persist_to_workspace:
root: ~/wp-calypso
paths:
- desktop/release
- run: *desktop-notify-github-success
- run: *desktop-notify-github-failure
- slack/status: *desktop-notify-slack-failure
wp-desktop-linux:
docker:
- image: circleci/node:12.18.4-browsers
<<: *desktop_defaults
shell: /bin/bash --login
steps:
- checkout
- attach_workspace:
at: ~/wp-calypso
- run: *update-node
- run: *desktop-install-app-deps
- run:
name: Build Desktop Linux
environment:
CSC_LINK: resource/certificates/win.p12
command: |
set +e
source $HOME/.nvm/nvm.sh
nvm use
# Build all artifacts only when project config changes.
# Otherwise only build application executable required for end-to-end testing.
! git diff --name-only origin/master...HEAD | grep -E -q 'desktop/package.json|desktop/yarn.lock' && ELECTRON_BUILDER_ARGS='-c.linux.target=dir'
ELECTRON_BUILDER_ARGS=$ELECTRON_BUILDER_ARGS yarn run build-desktop:app
- run:
name: e2e Tests
command: |
source $HOME/.nvm/nvm.sh
nvm use
npm install -g yarn
yarn run test-desktop:e2e
- run:
when: always
name: Persist Linux Executable
command: |
# If this isn't a full artifact build, ensure to persist the built application for inspection
test -f desktop/release/*.tar.gz || tar -zcf desktop/release/linux-unpacked.tar.gz desktop/release/linux-unpacked
- run:
when: always
name: Clean Up
command: |
set +e
rm -rf desktop/release/github
rm -rf desktop/release/linux-unpacked
rm -rf desktop/release/.icon-set
- store_artifacts:
when: always
path: desktop/release
- store_artifacts:
when: always
path: desktop/e2e/logs
- persist_to_workspace:
root: ~/wp-calypso
paths:
- desktop/release
wp-desktop-windows:
executor:
name: win/default
working_directory: C:\Users\circleci\wp-calypso
environment:
steps:
- checkout
- attach_workspace:
at: C:\Users\circleci\wp-calypso
- run:
name: Install Node Version
command: |
$NODE_VERSION = Get-Content .nvmrc
nvm install $NODE_VERSION
nvm use $NODE_VERSION
- run:
name: Install Yarn
command: npm install -g yarn
- run:
name: Install Make
command: cinst make
- run:
name: Install Desktop Dependencies
command: yarn run build-desktop:install-app-deps
- when:
condition: << pipeline.git.tag >>
steps:
- run:
name: Import Codesigning Certificate
command: |
# Workaround for Sign Tool "private key filter" bug in Circle's Windows image.
# Ref: https://travis-ci.community/t/codesigning-on-windows/
#
# Fix: Import .p12 into the local certificate store. Sign Tool will use
# package.json's `certificateSubjectName` to find the imported cert.
$env:CSC_LINK='C:\Users\circleci\wp-calypso\desktop\resource\certificates\win.p12'
Import-PfxCertificate -FilePath $env:CSC_LINK -CertStoreLocation Cert:\LocalMachine\Root -Password (ConvertTo-SecureString -String $env:WIN_CSC_KEY_PASSWORD -AsPlainText -Force)
- run:
name: Build Desktop Windows
command: |
# Use make for bash-like environment variable substitution
# Codesign release (tagged) builds only
If ( $env:CIRCLE_TAG ) { $env:ARG1='-c.win.certificateSubjectName=""Automattic, Inc.""' }
# Build all artifacts only when project config changes.
# Otherwise only build application executable required for end-to-end testing.
If ( -Not $(git diff --name-only origin/master...HEAD | Select-String -Pattern desktop/package.json,desktop/yarn.lock) ) { $env:ARG2='-c.win.target=dir' }
make -f desktop/Makefile package ELECTRON_BUILDER_ARGS=$($env:ARG1,$env:ARG2 -join " ")
- run:
name: Archive Unpacked Directories
command: |
tar -zcf desktop/release/win-unpacked-x64.tar.gz desktop/release/win-unpacked
# Check if win-ia32 build is present before archiving: if this isn't a full
# artifact build, the win-ia32-unpacked executable will not be generated.
If ( $(Test-Path -Path release\win-ia32-unpacked) ) {
tar -zcf desktop/release/win-unpacked-ia32.tar.gz desktop/release/win-ia32-unpacked
} else {
echo "Skipping tar archive for 'desktop\release\win-ia32-unpacked' (not built)"
}
- run:
when: always
name: Clean Up
command: |
set +e
rm -rf desktop/release/github
rm -rf desktop/release/win-unpacked
rm -rf desktop/release/win-ia32-unpacked
shell: bash.exe
- store_artifacts:
when: always
path: desktop\release
- persist_to_workspace:
root: C:\Users\circleci\wp-calypso
paths:
- desktop\release
wp-desktop-publish:
docker:
- image: circleci/golang:1.12
working_directory: /home/circleci/wp-calypso
environment:
VERSION: << pipeline.git.tag >>
steps:
- attach_workspace:
at: /home/circleci/wp-calypso
- run:
name: Install Dependencies
command: go get github.com/tcnksm/ghr
- run:
name: Publish Github Release
command: |
echo "Publishing draft release for wp-desktop $VERSION..."
NAME="WP-Desktop ${VERSION#?}"
ghr \
--token "${GH_TOKEN}" \
--username "${CIRCLE_PROJECT_USERNAME}" \
--repository "${CIRCLE_PROJECT_REPONAME}" \
--commitish "${CIRCLE_SHA1}" \
--name "${NAME}" \
--delete \
--draft \
"${VERSION}" desktop/release/
echo "Publish complete"
workflows:
version: 2
calypso:
jobs:
- setup
- prime-calypso-live:
filters:
branches:
ignore: master
- build-notifications:
requires:
- setup
- build-o2-blocks:
requires:
- setup
- build-wpcom-block-editor:
requires:
- setup
- translate:
requires:
- setup
- lint:
requires:
- setup
- test-client:
requires:
- setup
- test-packages:
requires:
- setup
- test-server:
requires:
- setup
- typecheck-strict:
requires:
- setup
- wait-calypso-live:
requires:
- test-client
- test-server
filters:
branches:
ignore:
# Do not spin up calypso.live for `master`
- master
# Do not spin up calypso.live for fork pull requests. Calypso.live will not build them.
- /pull\/[0-9]+/
# - test-e2e-canary: