-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
289 lines (265 loc) · 8.34 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
variables:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
FF_USE_FASTZIP: 1
ARTIFACT_COMPRESSION_LEVEL: "fastest"
CACHE_COMPRESSION_LEVEL: "fastest"
ANDROID_TARGET_SDK: "35"
stages:
- images
- basic
- complex
workflow:
auto_cancel:
on_job_failure: all
on_new_commit: interruptible
.aliases:
- &artifacts_apk_path "app/build/outputs/apk/debug/app-debug.apk"
- &artifacts_test_apk_path "app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk"
- &reports_lint_path "app/build/reports/lint-results-release.html"
- &artifacts_release_aab_path "build/outputs/bundle/**/*.aab"
- &reports_config_cache_path "build/reports/configuration-cache/**/*.html"
.cache-android-gradle-distribution: &cache_android_gradle_distribution
- key:
files:
- gradle/wrapper/gradle-wrapper.properties
paths:
- "cache/.gradle/wrapper/dists"
policy: pull-push
# Gradle User Home & Project (with Configuration Cache)
.cache-android-gradle-user-home-and-project: &cache_android_gradle_user_home_and_project
- key:
files:
- "**gradle*"
prefix: $CI_JOB_NAME
paths:
- "cache/.gradle/caches/${GRADLE_VERSION}"
- "cache/.gradle/caches/modules-2"
- "cache/.gradle/caches/jars-9"
- ".gradle"
policy: pull-push
# Gradle Build Cache - eventually move to Gradle Enterprise
.cache-android-build-cache: &cache_android_build_cache
- key:
files:
- "**gradle*"
prefix: $CI_JOB_NAME
paths:
- "cache/.gradle/caches/build-cache-1"
policy: pull-push
.android-global-cache:
cache: &android_global_cache_policy
- *cache_android_gradle_distribution
- *cache_android_gradle_user_home_and_project
- *cache_android_build_cache
.alpine_tools_job:
image: $CI_REGISTRY_IMAGE:tools-latest
needs:
- job: build_deploy_alpine_tools_ci_image
optional: true
tags:
- saas-linux-small-amd64
.alpine_jdk_job:
image: $CI_REGISTRY_IMAGE:jdk-latest
needs:
- job: build_deploy_alpine_jdk_ci_image
optional: true
tags:
- saas-linux-small-amd64
.android_sdk_job:
image: $CI_REGISTRY_IMAGE:android-sdk-latest
needs:
- job: build_deploy_android_sdk_ci_image
optional: true
tags:
- saas-linux-small-amd64
cache:
*android_global_cache_policy
before_script:
- export GRADLE_USER_HOME=`pwd`/cache/.gradle
- mkdir -p $GRADLE_USER_HOME
- export GRADLE_PROJECT_HOME=`pwd`/.gradle
- export GRADLE_VERSION="$(grep "distributionUrl" gradle/wrapper/gradle-wrapper.properties | sed -E 's/.*gradle-([0-9.]+)-(all|bin).zip/\1/')"
- git config core.hooksPath .githooks
- git lfs pull
build_apk:
extends: .android_sdk_job
stage: basic
script:
- ./gradlew :app:assembleDebug -Dorg.gradle.configuration-cache.internal.report-link-as-warning=true
artifacts:
paths:
- *artifacts_apk_path
- *reports_config_cache_path
expire_in: 1 hrs
build_base_apk:
extends: .android_sdk_job
stage: basic
rules:
- if: $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
before_script:
- git checkout $CI_MERGE_REQUEST_DIFF_BASE_SHA
script:
- ./gradlew :app:assembleDebug -Dorg.gradle.configuration-cache.internal.report-link-as-warning=true
artifacts:
paths:
- *artifacts_apk_path
- *reports_config_cache_path
expire_in: 1 hrs
build_test_apk:
extends: .android_sdk_job
stage: basic
script:
- ./gradlew :app:assembleDebugAndroidTest -Dorg.gradle.configuration-cache.internal.report-link-as-warning=true
artifacts:
paths:
- *artifacts_test_apk_path
- *reports_config_cache_path
expire_in: 1 hrs
unit_tests:
extends: .android_sdk_job
stage: basic
script:
- ./gradlew testDebugUnitTest -Dorg.gradle.configuration-cache.internal.report-link-as-warning=true
artifacts:
reports:
junit: "**/build/test-results/**/TEST-*.xml"
paths:
- *reports_config_cache_path
expire_in: 90 days
spotless_check:
extends: .android_sdk_job
stage: basic
script:
# Cannot reuse configuration cache due to https://github.com/diffplug/spotless/issues/987
- ./gradlew spotlessCheck --no-configuration-cache -Dorg.gradle.unsafe.isolated-projects=false
module_graph_check:
extends: .android_sdk_job
stage: basic
script:
- ./gradlew assertModuleGraph -Dorg.gradle.configuration-cache.internal.report-link-as-warning=true
validate_xml:
extends: .alpine_tools_job
stage: basic
script:
- ci/validate_xml.sh
validate_shell_scripts:
extends: .alpine_tools_job
stage: basic
script:
- ci/validate_shell_scripts.sh
android_lint:
extends: .android_sdk_job
stage: basic
script:
- ./gradlew :app:lintRelease
artifacts:
paths:
- *reports_lint_path
- *reports_config_cache_path
expire_in: 1 week
android_ui_tests:
extends: .alpine_jdk_job
stage: complex
variables:
APK_PATH: *artifacts_apk_path
TEST_APK_PATH: *artifacts_test_apk_path
needs:
- job: build_apk
- job: build_test_apk
script:
# https://docs.emulator.wtf/integrations/cli/#installation
- mkdir -p /tmp/bin
- curl https://maven.emulator.wtf/releases/ew-cli -o /tmp/bin/ew-cli
- chmod a+x /tmp/bin/ew-cli
- export PATH=$PATH:/tmp/bin
- mkdir -p build/test-results
- ew-cli --token $EMULATOR_WTF_API_KEY --app $APK_PATH --test $TEST_APK_PATH --outputs-dir build/test-results
artifacts:
reports:
junit: "build/test-results/**/*.xml"
diff_apk_from_base:
extends: .alpine_jdk_job
stage: complex
rules:
- if: $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
variables:
APK_PATH: *artifacts_apk_path
TEST_APK_PATH: *artifacts_test_apk_path
needs:
- job: build_apk
- job: build_base_apk
script:
# Ensure the two artifacts are downloaded correctly
- echo "Diff the APKs with Diffuse"
# Find or create the MR comment with updated Diffuse report
build_deploy_alpine_tools_ci_image:
stage: images
tags:
- saas-linux-small-amd64
image: docker:24.0.9
services:
- name: docker:24.0.9-dind
command: ["--experimental"]
script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker pull $CI_REGISTRY_IMAGE:tools-latest || true
- docker buildx create --use --name repobuilder
- docker buildx build --platform linux/x86_64 -t $CI_REGISTRY_IMAGE:tools-latest -f ci/Dockerfile-tools --push .
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- ci/Dockerfile-tools
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
paths:
- ci/Dockerfile-tools
compare_to: 'refs/heads/main'
build_deploy_alpine_jdk_ci_image:
stage: images
tags:
- saas-linux-small-amd64
image: docker:24.0.9
services:
- name: docker:24.0.9-dind
command: ["--experimental"]
script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker pull $CI_REGISTRY_IMAGE:jdk-latest || true
- docker buildx create --use --name repobuilder
- docker buildx build --platform linux/x86_64 -t $CI_REGISTRY_IMAGE:jdk-latest -f ci/Dockerfile-jdk --push .
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- ci/Dockerfile-jdk
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
paths:
- ci/Dockerfile-jdk
compare_to: 'refs/heads/main'
build_deploy_android_sdk_ci_image:
stage: images
tags:
- saas-linux-small-amd64
image: docker:24.0.9
services:
- name: docker:24.0.9-dind
command: ["--experimental"]
script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker pull $CI_REGISTRY_IMAGE:android-sdk-latest || true
- docker buildx create --use --name repobuilder
- docker buildx build --platform linux/x86_64 -t $CI_REGISTRY_IMAGE:android-sdk-latest -f ci/Dockerfile-android-sdk --push .
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- ci/Dockerfile-android-sdk
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
paths:
- ci/Dockerfile-android-sdk
compare_to: 'refs/heads/main'