-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
420 lines (384 loc) · 11 KB
/
.gitlab-ci.yml
File metadata and controls
420 lines (384 loc) · 11 KB
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
include:
- 'https://gitlab-templates.ddbuild.io/slack-notifier/v3-sdm/template.yml'
variables:
CURRENT_CI_IMAGE: "9"
BUILD_STABLE_REGISTRY: 486234852809.dkr.ecr.us-east-1.amazonaws.com
CI_IMAGE_REPO: "ci/dd-sdk-flutter"
CI_IMAGE_DOCKER: ${BUILD_STABLE_REGISTRY}/${CI_IMAGE_REPO}:$CURRENT_CI_IMAGE
DD_CLIENT_TOKEN: "fake-token"
DD_APPLICATION_ID: "fake-application-id"
IOS_SIMULATOR: "iPhone 16"
IOS_SDK: 'iOS-18'
ANDROID_EMULATOR_SDK: "33"
IS_ON_CI: $CI
SLACK_CHANNEL: "#mobile-sdk-ops"
FLUTTER_MIN_VERSION: '3.27.0'
KUBERNETES_MEMORY_REQUEST: "32Gi"
KUBERNETES_MEMORY_LIMIT: "48Gi"
KUBERNETES_CPU_REQUEST: 4
stages:
- ci-image
- build
- integration-test
- version-test
- e2e-test
- post
- post-nightly
# Prebuild - install necessary tools
.pre:
script:
- ulimit -S -n 2048
- export PATH=$PATH:$HOME/.pub-cache/bin
- flutter upgrade --force
- flutter --version
- flutter doctor
# SPM is the exception, make sure its disabled before starting the build
- flutter config --no-enable-swift-package-manager
- dart pub global activate melos
- dart pub global activate junitreport
- melos bootstrap
- mkdir -p $CI_PROJECT_DIR/.build/test-results/
- melos full_clean
- melos prepare
.pre-web:
script:
- pushd tools/ci && dart pub get && dart run ci_helpers chrome_driver --extract && popd
- ./tools/ci/.tmp/chromedriver-linux64/chromedriver --version
- ./tools/ci/.tmp/chrome-linux64/chrome --version
- ./tools/ci/.tmp/chromedriver-linux64/chromedriver --port=4444 &
- export CHROME_EXECUTABLE=${CI_PROJECT_DIR}/tools/ci/.tmp/chrome-linux64/chrome
- export PATH="$PATH:${CI_PROJECT_DIR}/tools/ci/.tmp/chrome-linux64/"
- echo $CHROME_EXECUTABLE
- flutter doctor
.pre-ios:
script:
- xcode-select -p
- xcodebuild -runFirstLaunch
- xcodebuild -downloadPlatform iOS
- pushd tools/ci && dart pub get && dart run ci_helpers start_sim --platform ios --sdk $IOS_SDK --device $IOS_SIMULATOR && popd
.pre-android:
script:
- yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "build-tools;36.0.0" "platform-tools" "platforms;android-36" || true
- yes | flutter doctor --android-licenses || true
# Kill all active emulators
- pushd tools/ci
- dart pub get && dart run ci_helpers stop_emu
- popd
- melos pub:get
- flutter doctor
.pre-web:
script:
- pushd tools/ci && dart pub get && dart run ci_helpers chrome_driver --extract && popd
- ./tools/ci/.tmp/chromedriver-linux64/chromedriver --version
- ./tools/ci/.tmp/chrome-linux64/chrome --version
- export CHROME_EXECUTABLE=${CI_PROJECT_DIR}/tools/ci/.tmp/chrome-linux64/chrome
- export PATH="$PATH:${CI_PROJECT_DIR}/tools/ci/.tmp/chrome-linux64/"
- echo $CHROME_EXECUTABLE
ci-image:
when: manual
stage: ci-image
except: [ tags, schedules ]
tags: [ "arch:amd64" ]
image: "$BUILDENV_REGISTRY/docker:24.0.4-jammy"
script:
- docker buildx build --tag registry.ddbuild.io/${CI_IMAGE_REPO}:${CURRENT_CI_IMAGE} --label target=build -f Dockerfile.gitlab --push .
# Build (And Analyze) Stage
build-flutter:
stage: build
except: [ schedules ]
variables:
VAULT_ADDR: "https://vault.us1.ddbuild.io"
tags:
- macos:sonoma
- specific:true
script:
- !reference [.pre, script]
- melos dartfmt_check
- melos run analyze:dart
- melos run unit_test:flutter
- melos run golden_test:flutter
artifacts:
when: always
expire_in: "30 days"
reports:
junit: $CI_PROJECT_DIR/.build/test-results/*.xml
build-android:
stage: build
except: [ schedules ]
image: $CI_IMAGE_DOCKER
tags: [ "arch:amd64" ]
script:
- !reference [.pre, script]
- melos run analyze:android
- melos run build:android
- melos run unit_test:android
artifacts:
when: always
expire_in: "30 days"
paths:
- "$CI_PROJECT_DIR/**/reports/detekt/*"
build-ios-spm:
stage: build
except: [ schedules ]
variables:
VAULT_ADDR: "https://vault.us1.ddbuild.io"
tags:
- macos:sonoma
- specific:true
script:
- !reference [.pre, script]
- !reference [.pre-ios, script]
- flutter config --enable-swift-package-manager
- melos remove_cocoapods
- melos pub:get
- melos run analyze:ios
- melos run build:ios
- melos run unit_test:ios
build-ios:
stage: build
except: [ schedules ]
variables:
VAULT_ADDR: "https://vault.us1.ddbuild.io"
tags:
- macos:sonoma
- specific:true
script:
- !reference [.pre, script]
- !reference [.pre-ios, script]
- pod repo update
- melos pub:get
- melos pod_update --no-select
- melos run analyze:ios
- melos run build:ios
- melos run unit_test:ios
build-web:
stage: build
except: [ schedules ]
image: $CI_IMAGE_DOCKER
tags:
[ "arch:amd64" ]
script:
- !reference [.pre, script]
- !reference [.pre-web, script]
- melos run build:web
- melos run unit_test:web
artifacts:
when: always
expire_in: "30 days"
reports:
junit: $CI_PROJECT_DIR/.build/test-results/*.xml
# Integration Tests
android-integration-test:
stage: integration-test
except: [ schedules ]
needs: [ build-android ]
variables:
VAULT_ADDR: "https://vault.us1.ddbuild.io"
tags:
- macos:sonoma
- specific:true
script:
- !reference [.pre, script]
- !reference [.pre-android, script]
- cd tools/ci && dart pub get && dart run ci_helpers start_sim --platform android --sdk $ANDROID_EMULATOR_SDK
- melos run integration_test:android
artifacts:
when: always
expire_in: "30 days"
reports:
junit: $CI_PROJECT_DIR/.build/test-results/*.xml
paths:
- tools/ci/logcat.txt
ios-integration-test:
stage: integration-test
except: [ schedules ]
needs: [ build-ios ]
variables:
VAULT_ADDR: "https://vault.us1.ddbuild.io"
tags:
- macos:sonoma
- specific:true
script:
- !reference [.pre, script]
- !reference [.pre-ios, script]
- pod repo update
- melos pub:get
- melos pod_update --no-select
- melos run integration_test:ios
artifacts:
when: always
expire_in: "30 days"
reports:
junit: $CI_PROJECT_DIR/.build/test-results/*.xml
web-integration-test:
stage: integration-test
except: [ schedules ]
needs: [ build-web ]
image: $CI_IMAGE_DOCKER
tags:
[ "arch:amd64" ]
script:
- !reference [.pre, script]
- !reference [.pre-web, script]
- ./tools/ci/.tmp/chromedriver-linux64/chromedriver --port=4444 &
- melos run integration_test:web
# Notify
notify-publish-develop-failure:
extends: .slack-notifier-base
stage: post
when: on_failure
only:
- develop
script:
- BUILD_URL="$CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID"
- 'MESSAGE_TEXT=":status_alert: $CI_PROJECT_NAME $CI_COMMIT_TAG develop pipeline <$BUILD_URL|$COMMIT_MESSAGE> failed."'
- postmessage "#mobile-sdk-ops" "$MESSAGE_TEXT"
notify-pipeline-succeeded:
stage: post
tags: [ "arch:amd64" ]
image: "$BUILDENV_REGISTRY/docker:24.0.4-jammy"
when: on_success
except:
- schedules
- develop
script:
- echo "Pipeline did succeed"
notify-nightly-failed:
extends: .slack-notifier-base
stage: post-nightly
when: on_failure
only:
- develop
- schedules
script:
- BUILD_URL="$CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID"
- 'MESSAGE_TEXT=":status_alert: $CI_PROJECT_NAME $CI_COMMIT_TAG Nightly develop pipeline <$BUILD_URL|$COMMIT_MESSAGE> failed."'
- postmessage "#mobile-sdk-ops" "$MESSAGE_TEXT"
# Nightly
.nightly-vars:
script:
- vault login -method=aws -no-print
- export DD_E2E_CLIENT_TOKEN=$(vault kv get -field=client_token kv/aws/arn:aws:iam::486234852809:role/ci-dd-sdk-flutter/e2e)
- export DD_E2E_APPLICATION_ID=$(vault kv get -field=application_id kv/aws/arn:aws:iam::486234852809:role/ci-dd-sdk-flutter/e2e)
.nightly:
only: [ schedules ]
when: always
variables:
VAULT_ADDR: "https://vault.us1.ddbuild.io"
tags:
- macos:sonoma
- specific:true
nightly-min-version-test:
extends: .nightly
stage: version-test
variables:
VAULT_ADDR: "https://vault.us1.ddbuild.io"
tags:
- macos:sonoma
- specific:true
script:
- !reference [.pre, script]
- !reference [.pre-ios, script]
- brew tap leoafarias/fvm
- brew install fvm
- fvm install $FLUTTER_MIN_VERSION
- fvm use $FLUTTER_MIN_VERSION
- fvm exec dart pub global activate melos
- export MELOS_PACKAGES="datadog_flutter_plugin"
- fvm exec melos pub:get
- fvm exec melos analyze:dart
artifacts:
when: always
expire_in: "30 days"
reports:
junit: $CI_PROJECT_DIR/.build/test-results/*.xml
nightly-beta-test:
extends: .nightly
stage: version-test
variables:
VAULT_ADDR: "https://vault.us1.ddbuild.io"
tags:
- macos:sonoma
- specific:true
script:
- !reference [.pre, script]
- !reference [.pre-ios, script]
- brew tap leoafarias/fvm
- brew install fvm
- fvm destroy
- fvm install beta
- fvm use beta
- fvm flutter upgrade --force
- fvm flutter precache --ios
- fvm exec dart pub global activate melos
- pod repo update
- flutter doctor
- fvm exec melos pub:get
- fvm exec melos pod_update --no-select
- fvm exec melos run analyze
- fvm exec melos run build
- fvm exec melos run unit_test:flutter
- fvm exec melos run unit_test:android
- fvm exec melos run unit_test:ios
artifacts:
when: always
expire_in: "30 days"
reports:
junit: $CI_PROJECT_DIR/.build/test-results/*.xml
nightly-beta-test-web:
extends: .nightly
stage: version-test
variables:
VAULT_ADDR: "https://vault.us1.ddbuild.io"
image: $CI_IMAGE_DOCKER
tags:
[ "arch:amd64" ]
script:
- !reference [.pre, script]
- !reference [.pre-web, script]
- git -C "$(dirname $(dirname $(which flutter)))" reset --hard
- flutter channel beta
- flutter upgrade --force
- dart pub global activate melos
- flutter doctor
- melos pub:get
- melos run analyze:dart
- melos run build:web
- melos run unit_test:web
artifacts:
when: always
expire_in: "30 days"
reports:
junit: $CI_PROJECT_DIR/.build/test-results/*.xml
nightly-ios:
extends: .nightly
stage: e2e-test
script:
- !reference [.nightly-vars, script]
- !reference [.pre, script]
- !reference [.pre-ios, script]
- pod repo update
- melos pub:get
- melos pod_update --no-select
- melos run e2e_tests:ios
artifacts:
when: always
expire_in: "30 days"
reports:
junit: $CI_PROJECT_DIR/.build/test-results/*.xml
nightly-android:
extends: .nightly
stage: e2e-test
script:
- !reference [.nightly-vars, script]
- !reference [.pre, script]
- !reference [.pre-android, script]
- cd tools/ci && dart pub get && dart run ci_helpers start_sim --platform android --sdk $ANDROID_EMULATOR_SDK
- melos run e2e_tests:android
artifacts:
when: always
expire_in: "30 days"
reports:
junit: $CI_PROJECT_DIR/.build/test-results/*.xml
paths:
- tools/ci/logcat.txt