-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy path.gitlab-ci.yml
449 lines (412 loc) · 12.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
default:
image: ${PROTON_CI_REGISTRY}/android-shared/docker-android/oci:v2.1.6
interruptible: true
tags:
- shared-small
before_script:
- if [[ -f /load-env.sh ]]; then source /load-env.sh; fi
- bundle config set path ${BUNDLE_GEM_PATH}
- bundle config set without 'production'
- bundle install
variables:
# Clean up cache when extraction fails
FF_CLEAN_UP_FAILED_CACHE_EXTRACT: "true"
# Output upload and download progress every 5 seconds
TRANSFER_METER_FREQUENCY: "5s"
# Use no compression for artifacts
ARTIFACT_COMPRESSION_LEVEL: "fastest"
# Use low compression for caches
CACHE_COMPRESSION_LEVEL: "fast"
# Gem path
BUNDLE_GEM_PATH: 'vendor/ruby'
# Makes sure we do not create separate merge request and branch pipelines.
# See https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: '$CI_COMMIT_TAG != null'
when: never
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
.gradle-cache-dev: &gradle-cache-dev
key:
prefix: gradle-cache-dev
files:
- gradle/wrapper/gradle-wrapper.properties
paths:
- .gradle
policy: pull
.gradle-cache-alpha: &gradle-cache-alpha
key:
prefix: gradle-cache-alpha
files:
- gradle/wrapper/gradle-wrapper.properties
paths:
- .gradle
policy: pull
.gradle-cache-prod: &gradle-cache-prod
key:
prefix: gradle-cache-prod
files:
- gradle/wrapper/gradle-wrapper.properties
paths:
- .gradle
policy: pull
.ruby-cache: &ruby-cache
key:
prefix: ruby-cache
files:
- Gemfile.lock
paths:
- ${BUNDLE_GEM_PATH}
policy: pull
stages:
- analyse
- danger-review
- localise
- build
- startReview
- test
- deploy
- tag
- publish
- stopReview
detekt:
stage: analyse
cache:
- <<: *gradle-cache-dev
policy: !reference [ .cache-policy, cache, policy ]
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
tags:
- shared-medium
script:
- bundle exec fastlane analyse
artifacts:
expire_in: 1 month
reports:
codequality: config/detekt/reports/mergedReport.json
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: manual
allow_failure: true
- when: always
danger-review:
stage: danger-review
cache:
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
tags:
- shared-small
when: always
script:
- bundle exec danger --fail-on-errors=false
allow_failure: true
variables:
DANGER_GITLAB_API_TOKEN: $DANGER_GITLAB_API_TOKEN
interruptible: true
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
i18n-send-crowdin:
stage: localise
extends: .i18n-sync-crowdin-shared
tags:
- shared-small
variables:
I18N_FILTER_OUT_ITEMS: 'proton-libs'
I18N_SYNC_CROWDIN_PROJECT: 'android-mail-new'
I18N_SYNC_BRANCH: 'main'
i18n-commit-locales:
stage: localise
extends: .i18n-commit-locales-shared
tags:
- shared-small
variables:
I18N_COMMIT_CROWDIN_PROJECT: 'android-mail-new'
I18N_COMMIT_BRANCH_PUSH: 'main'
I18N_COMMIT_BRANCH_ALLOWED: 'main'
build_dev_debug:
extends: .build_job
cache:
- <<: *gradle-cache-dev
policy: !reference [ .cache-policy, cache, policy ]
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
script:
- base64 -d - < "$GOOGLE_SERVICES_JSON_FILE" > app/google-services.json
- bundle exec fastlane setupUiTestsAssets
- bundle exec fastlane assembleDevDebug
- bundle exec fastlane assembleDevDebugAndroidTest
build_alpha_release:
extends: .build_job
cache:
- <<: *gradle-cache-alpha
policy: !reference [ .cache-policy, cache, policy ]
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
script:
- base64 -d - < "$PRIVATE_PROPERTIES_FILE" > private.properties
- base64 -d - < "$SENTRY_PROPERTIES_FILE" > sentry.properties
- base64 -d - < "$PROTON_RELEASE_KEYSTORE_BASE64" > keystore/ProtonMail.keystore
- base64 -d - < "$GOOGLE_SERVICES_JSON_FILE" > app/google-services.json
- bundle exec fastlane assembleAlphaRelease
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
# Always build on merge requests
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "parent_pipeline"
when: never
build_prod_release:
extends: .build_job
cache:
- <<: *gradle-cache-prod
policy: !reference [ .cache-policy, cache, policy ]
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
script:
- base64 -d - < "$PRIVATE_PROPERTIES_FILE" > private.properties
- base64 -d - < "$SENTRY_PROPERTIES_FILE" > sentry.properties
- base64 -d - < "$PROTON_RELEASE_KEYSTORE_BASE64" > keystore/ProtonMail.keystore
- base64 -d - < "$GOOGLE_SERVICES_JSON_FILE" > app/google-services.json
- bundle exec fastlane assembleProdRelease
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
# Always build on merge requests
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "parent_pipeline"
when: never
startReview:
stage: startReview
tags:
- shared-small
before_script:
- export REVIEW_APP_ARTIFACT_PATH="app/build/outputs/apk/alpha/release/app-alpha-release.apk"
- echo ${REVIEW_APP_ARTIFACT_PATH}
extends: .startReview
dependencies:
- build_alpha_release
only:
- merge_requests
stopReview:
stage: stopReview
cache:
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
extends: .stopReview
tags:
- shared-small
before_script: [ ]
rules:
# The cleanup is always manual on a Merge Request
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: manual
allow_failure: true
# But it's not needed when not on a Merge Request
- when: never
run_unit_test:
stage: test
cache:
- <<: *gradle-cache-dev
policy: !reference [ .cache-policy, cache, policy ]
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
tags:
- xlarge-k8s
dependencies:
- build_dev_debug
script:
- base64 -d - < "$GOOGLE_SERVICES_JSON_FILE" > app/google-services.json
- bundle exec fastlane unitTest
- bundle exec fastlane coverageReport
coverage: /TotalLineCoverage.*?(\d{1,3}\.\d{0,2})%/
interruptible: true
artifacts:
when: always
expire_in: 1 week
paths:
- '**/build/reports/kover/cobertura*.xml'
- './coverage/build/reports/kover/html/'
reports:
junit: ./**/test-results/*/TEST-*.xml
coverage_report:
coverage_format: cobertura
path: '**/build/reports/kover/cobertura*.xml'
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: manual
allow_failure: true
- when: always
run_firebase_proton_core_libs_tests:
extends: .firebase_test_job
cache:
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
allow_failure: true # Temporary, as long as we don't have a more specific test environment.
script:
- bundle exec fastlane coreLibsTest
rules:
- if: ('$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH') && ($NIGHTLY_ALPHA_BUILD == "true" || $INTERNAL_ALPHA_RELEASE == "true")
run_firebase_smoke_tests:
extends: .firebase_test_job
cache:
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
script:
- bundle exec fastlane smokeTest
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: ('$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH') || $NIGHTLY_ALPHA_BUILD == "true"
when: never
- when: on_success
run_firebase_full_regression_tests:
extends: .firebase_test_job
cache:
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
script:
- bundle exec fastlane fullRegressionTest
rules:
- if: ('$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH') && ($NIGHTLY_ALPHA_BUILD == "true" || $INTERNAL_ALPHA_RELEASE == "true")
# Allow manual regression test runs on MRs if needed.
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: manual
allow_failure: true
tag_release:
stage: tag
cache:
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
tags:
- shared-small
script:
- bundle exec fastlane tagRelease
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: ('$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH') && ($INTERNAL_ALPHA_RELEASE != "true")
when: manual
allow_failure: true
- if: ('$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH') && ($INTERNAL_ALPHA_RELEASE == "true")
deploy_to_firebase_dev:
extends: .firebase_deploy_job
cache:
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
script:
- bundle exec fastlane deployToFirebaseDevGroup
rules:
- !reference [ .firebase_deploy_job, rules ]
- if: $NIGHTLY_ALPHA_BUILD == "true"
when: never
- if: $INTERNAL_ALPHA_RELEASE == "true"
when: never
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: manual
allow_failure: true
deploy_to_firebase_nightly:
extends: .firebase_deploy_job
cache:
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
script:
- bundle exec fastlane deployToFirebaseNightlyGroup
rules:
- !reference [ .firebase_deploy_job, rules ]
- if: $NIGHTLY_ALPHA_BUILD == "true"
deploy_to_firebase_alpha:
extends: .firebase_deploy_job
cache:
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
script:
- bundle exec fastlane deployToFirebaseInternalAlphaGroup
rules:
- !reference [ .firebase_deploy_job, rules ]
- if: $INTERNAL_ALPHA_RELEASE == "true"
deploy_play_store_internal:
stage: deploy
cache:
- <<: *ruby-cache
policy: !reference [ .cache-policy, cache, policy ]
dependencies:
- build_prod_release
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: manual
allow_failure: true
script:
- base64 -d - < "$PLAY_STORE_SERVICE_ACCOUNT_JSON" > /tmp/play_store_service_account.json
- bundle exec fastlane deployToPlayStoreInternal
distribute_debug_mr:
stage: deploy
image: $CI_REGISTRY/tpe/test-scripts
dependencies:
- build_dev_debug
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
allow_failure: true
before_script: []
script:
- MAIN_APK=app/build/outputs/apk/dev/debug/app-dev-debug.apk
- TEST_APK=app/build/outputs/apk/androidTest/dev/debug/app-dev-debug-androidTest.apk
- /usr/local/bin/nexus/mr_created_commit_pushed.py
--token "$MAIL_ANDROID_READ_ACCESS_TOKEN"
--component "/Mail/Android"
--file_paths "$MAIN_APK" "$TEST_APK"
--file_names "mail-dev-debug.apk" "mail-dev-debug-test.apk"
distribute_debug_post_merge:
stage: deploy
image: $CI_REGISTRY/tpe/test-scripts
dependencies:
- build_dev_debug
rules:
- if: '$CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
allow_failure: true
before_script: []
script:
- MAIN_APK=app/build/outputs/apk/dev/debug/app-dev-debug.apk
- TEST_APK=app/build/outputs/apk/androidTest/dev/debug/app-dev-debug-androidTest.apk
- /usr/local/bin/nexus/mr_merged_with_post_merge_pipeline.py
--token "$MAIL_ANDROID_READ_ACCESS_TOKEN"
--component "/Mail/Android"
--file_paths "$MAIN_APK" "$TEST_APK"
--file_names "mail-dev-debug.apk" "mail-dev-debug-test.apk"
release_publish_github:
stage: publish
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: manual
- when: never
script:
- ./tools/private/publish/publish-to-github.sh
tags:
- shared-medium
include:
# Push the cache if it's the default branch
- rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
local: /ci/cache-policy-push-pull.yml
# Do not push the cache if it's not the default branch (e.g. MRs)
- rules:
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
local: /ci/cache-policy-pull.yml
- component: gitlab.protontech.ch/proton/devops/cicd-components/kits/devsecops/[email protected]
inputs:
stage: analyse
- component: gitlab.protontech.ch/proton/devops/cicd-components/community/gradle-wrapper/[email protected]
inputs:
stage: analyse
- project: 'translations/generator'
ref: master
file: '/jobs/sync-crowdin.gitlab-ci.yml'
- project: 'translations/generator'
ref: master
file: '/jobs/commit-locales.gitlab-ci.yml'
- project: 'proton/mobile/android/proton-libs'
ref: main
file: '/ci/templates-shared/appetize-integration.yml'
- local: '/ci/templates/base-jobs.gitlab-ci.yml'