-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.gitlab-ci.yml
536 lines (493 loc) · 14.9 KB
/
.gitlab-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
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
include:
- component: gitlab.protontech.ch/proton/devops/cicd-components/kubernetes/atlas-deploy/[email protected]
inputs:
cleanup-stage: cleanup
- component: gitlab.protontech.ch/proton/devops/cicd-components/kubernetes/atlas-deploy/[email protected]
inputs:
cleanup-stage: cleanup
deploy: manual
cleanup: manual
images: $IMAGES
features: $FEATURES
key: customenv$CI_PIPELINE_ID
suffix: ":custom"
- project: "translations/generator"
ref: master
file: "/jobs/sync-crowdin.gitlab-ci.yml"
- project: "translations/generator"
ref: master
file: "/jobs/commit-locales.gitlab-ci.yml"
stages:
- i18n
- releasing
- linting
- deploy
- unit_test
- ui_and_integration_test
- report
- cleanup
- github
variables:
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
GEM_HOME: "$CI_PROJECT_DIR/gem"
ATLAS_DEPLOY_LIST: ""
GIT_DEPTH: 20
GIT_STRATEGY: clone
FF_ENABLE_JOB_CLEANUP: "true"
IMAGES: $IMAGES
FEATURES: $FEATURES
.set_up_simulator: &set_up_simulator
- DEVICE_NAME=$CI_PIPELINE_ID-$CI_JOB_NAME
- DEVICE_OS=17.5
- DEVICE_RUNTIME=iOS$DEVICE_OS
- xcrun simctl create $DEVICE_NAME "iPhone 15" $DEVICE_RUNTIME
.add_private_ssh_key: &add_private_ssh_key
- echo "$CI_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
.clone_pmconstants: &clone_pmconstants
- rm -rf ../pmconstants
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${PROTON_GIT_URL}/apple/shared/pmconstants ../pmconstants
.tear_down_simulator: &tear_down_simulator
- DEVICE_NAME=$CI_PIPELINE_ID-$CI_JOB_NAME
- xcrun simctl delete $DEVICE_NAME
.rules_mr: &rules_mr
- if: '$CI_PIPELINE_SOURCE == "web"'
when: never
- if: "$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS"
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "develop"
variables:
ATLAS_DEPLOY_ENV: "true"
- if: $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_PIPELINE_SOURCE == "push"
when: never
- if: $CI_COMMIT_BRANCH
variables:
TEST: "manual"
releasing:
stage: releasing
needs: []
artifacts:
when: always
name: "ReleaseNotes-$CI_COMMIT_SHA"
paths:
- ReleaseNotes.md
expire_in: never
script:
- git remote set-url origin https://protoncore:$PROTONCORE_ACCESS_TOKEN@${PROTON_GIT_URL}/apple/shared/protoncore.git
- git remote -v
- bash scripts/finish_release_mr_with_new_version.sh
<<: &release_jobs
rules:
- if: '$CI_PIPELINE_SOURCE == "web"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_TITLE =~ /^Merge branch .release\/.+ into .+$/'
when: always
- if: "$CI_COMMIT_BRANCH"
when: never
allow_failure: false
interruptible: false
tags:
- macstadium-m1-protoncore
github:mirror:
stage: github
rules:
- if: '$CI_PIPELINE_SOURCE == "web"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_TITLE =~ /^Merge branch .release\/.+ into .+$/'
when: never
- if: '$CI_COMMIT_BRANCH == "develop"'
when: always
- if: "$CI_COMMIT_BRANCH"
when: never
allow_failure: false
interruptible: false
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID/github-mirror
needs: []
script:
- zsh scripts/mirror_to_github.sh develop
tags:
- account-lane-3
#
# --- Linting ---
#
linting:code-quality:
stage: linting
script:
- env
- tools/portable_swiftlint/swiftlint --config .swiftlint.yml --reporter junit > swiftlint.xml
rules: &rules_mr_and_develop
- if: $CI_PIPELINE_SOURCE == "push"
- if: $TEST == "manual"
when: manual
# We do not want to run jobs if the schedule doesn't deploy
- if: $CI_PIPELINE_SOURCE == "schedule" && $ATLAS_DEPLOY_ENV != "true"
when: never
- when: on_success
needs: []
allow_failure: false
interruptible: true
artifacts:
name: "ios-lint-$CI_COMMIT_SHA"
paths:
- swiftlint.xml
reports:
junit:
- swiftlint.xml
expire_in: 90 days
tags:
- macstadium-m1-protoncore
#
# --- Unit testing ---
#
test:unit:ios:all:
stage: unit_test
retry: 2
rules: *rules_mr_and_develop
allow_failure: true
interruptible: true
before_script:
- *add_private_ssh_key
- *clone_pmconstants
- *set_up_simulator
script:
- fastlane run_unit_tests device_name:$DEVICE_NAME
after_script:
- *tear_down_simulator
- fastlane cleanup_unit_tests
- ssh-add -D
artifacts:
name: "ios-tests-$CI_COMMIT_SHA"
when: always
paths:
- fastlane/test_output/UnitTests.xcresult/**
expire_in: 14 days
reports:
junit:
- fastlane/test_output/report.junit
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID/account-lane-1
tags:
- account-lane-1
test:unit:macos:all:
stage: unit_test
retry: 2
rules: *rules_mr_and_develop
allow_failure: true
interruptible: true
before_script:
- *add_private_ssh_key
- *clone_pmconstants
script:
- fastlane run_unit_tests_macos
after_script:
- fastlane cleanup_unit_tests_macos
artifacts:
paths:
- fastlane/test_output/*xcresult/**
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID/account-lane-2
tags:
- account-lane-2
test:apphost:macos:all:
stage: unit_test
retry: 2
rules: *rules_mr_and_develop
allow_failure: true
interruptible: true
before_script:
- *add_private_ssh_key
- *clone_pmconstants
script:
- fastlane run_apphosted_test_macos
after_script:
- fastlane cleanup_unit_tests_macos
artifacts:
paths:
- fastlane/test_output/*xcresult/**
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID/account-lane-6
tags:
- account-lane-6
test:unit:localization:
stage: unit_test
retry: 1
rules: *rules_mr_and_develop
allow_failure: false
interruptible: true
before_script:
- *add_private_ssh_key
- *set_up_simulator
script:
- fastlane run_localization_tests device_name:$DEVICE_NAME
after_script:
- *tear_down_simulator
- fastlane cleanup_localization_tests
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID/account-lane-3
tags:
- account-lane-3
#
# --- Integration testing
#
test:unit:integration:
stage: ui_and_integration_test
retry: 1
rules: *rules_mr_and_develop
allow_failure: true
interruptible: true
needs:
- job: atlas:deploy:pipenv
artifacts: true
before_script:
- *add_private_ssh_key
- *clone_pmconstants
- *set_up_simulator
script:
- fastlane run_integration_tests device_name:$DEVICE_NAME xcargs:DYNAMIC_DOMAIN="${DYNAMIC_DOMAIN}"
after_script:
- *tear_down_simulator
- fastlane cleanup_integration_tests
artifacts:
paths:
- fastlane/test_output/*xcresult/**
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID/account-lane-4
tags:
- account-lane-4
#
# --- UI testing ---
#
# UI light tests are now temporarily disable because of flakiness. CP-6530
test:ui:light:
retry: 1
rules:
- if: '$CI_PIPELINE_SOURCE == "web"'
when: never
- if: "$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS"
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
script:
- fastlane run_ui_tests device_name:$DEVICE_NAME
- bash scripts/run_ui_tests_on_ci.sh --light --device $DEVICE_NAME $DEVICE_OS --dynamic-domain ${DYNAMIC_DOMAIN}
<<: &ui_testing_common_configuration
stage: ui_and_integration_test
allow_failure: false
interruptible: true
needs:
- job: linting:code-quality
artifacts: false
- job: atlas:deploy:pipenv
artifacts: true
artifacts:
when: always
name: "test-report-$CI_PIPELINE_IID"
paths:
- UITestsResults-${CI_PIPELINE_IID}.html
expire_in: 7 days
before_script:
- *add_private_ssh_key
- *clone_pmconstants
- *set_up_simulator
after_script:
- *tear_down_simulator
- rm -rf ~/ProtonCore/UITests/${CI_PIPELINE_IID}/DerivedData/
- fastlane cleanup_ui_tests
- ssh-add -D
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID/account-lane-5
tags:
- account-lane-5
# ui tests smoke is run on merge to develop
test:ui:smoke:
rules:
- if: '$CI_PIPELINE_SOURCE == "web"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: "$CI_PIPELINE_SOURCE"
when: never
- if: "$CI_COMMIT_BRANCH"
when: never
script:
- fastlane run_ui_tests device_name:$DEVICE_NAME
- bash scripts/run_ui_tests_on_ci.sh --smoke --device $DEVICE_NAME $DEVICE_OS --dynamic-domain ${DYNAMIC_DOMAIN}
<<: *ui_testing_common_configuration
# ui tests regression is run only on schedules
test:ui:regression:
rules:
# We do not want to run the job if the schedule doesn't deploy
- if: $CI_PIPELINE_SOURCE == "schedule" && $ATLAS_DEPLOY_ENV == "true"
when: on_success
- when: never
timeout: 3 hours 30 minutes
script:
- fastlane run_ui_tests device_name:$DEVICE_NAME
- bash scripts/run_ui_tests_on_ci.sh --regression --device $DEVICE_NAME $DEVICE_OS --dynamic-domain ${DYNAMIC_DOMAIN}
<<: *ui_testing_common_configuration
#
# --- Coverage reports ---
#
report:integration:code:coverage:
retry: 1
coverage: '/Average Coverage.* (\d+\.\d+%)/'
stage: report
interruptible: true
rules: *rules_mr_and_develop
allow_failure: true
needs:
- job: test:unit:integration
artifacts: true
before_script:
- *add_private_ssh_key
- bash scripts/generate_obfuscated_constants.sh
- ls -l fastlane/test_output
script:
# Call xcov from fastlane
- fastlane integration_test_reports
# generate alt coverage json from xcresult
- xcrun xccov view --report --json fastlane/test_output/IntegrationTests.xcresult > fastlane/test_output/IntegrationTests.json
# Print and process the result for Gitlab coverage capture
- jq '"Line Coverage \(.lineCoverage * 100 |tostring | .[0:5])%"' fastlane/test_output/IntegrationTests.json
# generate cobertura xml from coverage json
- xcc generate fastlane/test_output/IntegrationTests.json fastlane/test_output cobertura-xml --verbose
# Split big cobertura file
- python3 scripts/split-by-package.py fastlane/test_output/cobertura.xml fastlane/test_output/
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: fastlane/test_output/cobertura-*.xml
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID/account-lane-4
tags:
- account-lane-4
report:apphost:macos:code:coverage:
retry: 1
coverage: '/Average Coverage.* (\d+\.\d+%)/'
stage: report
interruptible: true
rules: *rules_mr_and_develop
allow_failure: true
needs:
- job: test:apphost:macos:all
artifacts: true
before_script:
- *add_private_ssh_key
- bash scripts/generate_obfuscated_constants.sh
- ls -l fastlane/test_output
script:
# Call xcov from fastlane
- fastlane macos_apphost_test_reports
# generate alt coverage json from xcresult
- xcrun xccov view --report --json fastlane/test_output/ProtonCore-Keymaker-macOS-AppHost.xcresult > fastlane/test_output/ProtonCore-Keymaker-macOS-AppHost.json
# Print and process the result for Gitlab coverage capture
- jq '"Line Coverage \(.lineCoverage * 100 |tostring | .[0:5])%"' fastlane/test_output/ProtonCore-Keymaker-macOS-AppHost.json
# generate cobertura xml from coverage json
- xcc generate fastlane/test_output/ProtonCore-Keymaker-macOS-AppHost.json fastlane/test_output cobertura-xml --verbose
# Split big cobertura file
- python3 scripts/split-by-package.py fastlane/test_output/cobertura.xml fastlane/test_output/
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: fastlane/test_output/cobertura-*.xml
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID/account-lane-6
tags:
- account-lane-6
report:unit:macos:code:coverage:
retry: 1
coverage: '/Average Coverage.* (\d+\.\d+%)/'
stage: report
interruptible: true
rules: *rules_mr_and_develop
allow_failure: true
needs:
- job: test:unit:macos:all
artifacts: true
before_script:
- *add_private_ssh_key
- bash scripts/generate_obfuscated_constants.sh
- ls -l fastlane/test_output
script:
# Call xcov from fastlane
- fastlane macos_unit_test_reports
# generate alt coverage json from xcresult
- xcrun xccov view --report --json fastlane/test_output/UnitTests.xcresult > fastlane/test_output/UnitTests.json
# Print and process the result for Gitlab coverage capture
- jq '"Line Coverage \(.lineCoverage * 100 |tostring | .[0:5])%"' fastlane/test_output/UnitTests.json
# generate cobertura xml from coverage json
- xcc generate fastlane/test_output/UnitTests.json fastlane/test_output cobertura-xml --verbose
# Split big cobertura file
- python3 scripts/split-by-package.py fastlane/test_output/cobertura.xml fastlane/test_output/
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: fastlane/test_output/cobertura-*.xml
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID/account-lane-2
tags:
- account-lane-2
report:unit:ios:code:coverage:
retry: 1
coverage: '/Average Coverage.* (\d+\.\d+%)/'
stage: report
interruptible: true
rules: *rules_mr_and_develop
allow_failure: true
needs:
- job: test:unit:ios:all
artifacts: true
before_script:
- *add_private_ssh_key
- bash scripts/generate_obfuscated_constants.sh
- ls -l fastlane/test_output
script:
# Call xcov from fastlane
- fastlane unit_test_reports
# generate alt coverage json from xcresult
- xcrun xccov view --report --json fastlane/test_output/UnitTests.xcresult > fastlane/test_output/UnitTests.json
# Print and process the result for Gitlab coverage capture
- jq '"Line Coverage \(.lineCoverage * 100 |tostring | .[0:5])%"' fastlane/test_output/UnitTests.json
# generate cobertura xml from coverage json
- xcc generate fastlane/test_output/UnitTests.json fastlane/test_output cobertura-xml --verbose
# Split big cobertura file
- python3 scripts/split-by-package.py fastlane/test_output/cobertura.xml fastlane/test_output/
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: fastlane/test_output/cobertura-*.xml
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID/account-lane-1
tags:
- account-lane-1
#
# --- Translation related tasks ---
#
i18n-crowdin-sync:
stage: i18n
needs: []
variables:
I18N_SYNC_CROWDIN_PROJECT: "apple-core"
extends: .i18n-sync-crowdin-shared-apple
i18n-commit-locales:
stage: i18n
needs: []
variables:
I18N_COMMIT_CROWDIN_PROJECT: "apple-core"
extends: .i18n-commit-locales-shared-apple