-
Notifications
You must be signed in to change notification settings - Fork 42
/
.gitlab-ci.yml
257 lines (230 loc) · 6.88 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
include:
- 'https://gitlab-templates.ddbuild.io/slack-notifier/v1/template.yml'
variables:
CURRENT_CI_IMAGE: "7"
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 15"
VAULT_ADDR: "https://vault.us1.ddbuild.io"
IS_ON_CI: $CI
SLACK_CHANNEL: "#mobile-sdk-ops"
KUBERNETES_MEMORY_REQUEST: "8Gi"
KUBERNETES_MEMORY_LIMIT: "16Gi"
stages:
- ci-image
- build
- integration-test
- e2e-test
- post
# Prebuild - install necessary tools
.pre:
script:
- ulimit -S -n 2048
- export PATH=$PATH:$HOME/.pub-cache/bin
- flutter upgrade
- flutter --version
- dart pub global activate melos
- dart pub global activate junitreport
- melos bootstrap
- mkdir -p $CI_PROJECT_DIR/.build/test-results/
- melos prepare
.pre-ios:
script:
- xcode-select -p
- xcodebuild -runFirstLaunch
- xcodebuild -downloadPlatform iOS
ci-image:
when: manual
stage: ci-image
except: [ tags, schedules ]
tags: [ "arch:amd64" ]
image: "$BUILDENV_REGISTRY/images/docker:24.0.4-gbi-focal"
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 ]
tags:
- macos:sonoma
- specific:true
script:
- !reference [.pre, script]
- melos run analyze:dart
- melos run unit_test:flutter
- melos run build:web
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
build-ios:
stage: build
except: [ schedules ]
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 ]
tags: [ "arch:amd64" ]
image: $CI_IMAGE_DOCKER
script:
- !reference [.pre, script]
- melos run build:web
# Integration Tests
android-integration-test:
stage: integration-test
except: [ schedules ]
needs: [ build-android ]
tags:
- macos:sonoma
- specific:true
script:
- !reference [.pre, script]
# Kill all active emulators
- pushd tools/ci && dart pub get && dart run ci_helpers stop_emu && popd
- melos pub:get
- yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "build-tools;34.0.0" "platform-tools" "platforms;android-34" || true
- yes | flutter doctor --android-licenses || true
- flutter doctor
- cd tools/ci && dart pub get && dart run ci_helpers start_sim --platform android --sdk "33"
- 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 ]
tags:
- macos:sonoma
- specific:true
script:
- !reference [.pre, script]
- !reference [.pre-ios, script]
- pod repo update
- melos pub:get
- cd tools/ci && dart pub get && dart run ci_helpers start_sim --platform ios --sdk "iOS-17" --device "iPhone 15"
- 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]
- 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
- 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/images/docker:24.0.4-gbi-focal"
when: on_success
except:
- schedules
- develop
script:
- echo "Pipeline did succeed"
# 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 ]
stage: e2e-test
tags:
- macos:sonoma
- specific:true
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
- cd tools/ci && dart pub get && dart run ci_helpers start_sim --platform ios --sdk "iOS-17" --device "iPhone 15"
- 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]
# Kill all active emulators
- pushd tools/ci && dart pub get && dart run ci_helpers stop_emu && popd
- melos pub:get
- yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "build-tools;33.0.3" "platform-tools" "platforms;android-34" || true
- yes | flutter doctor --android-licenses || true
- flutter doctor
- cd tools/ci && dart pub get && dart run ci_helpers start_sim --platform android --sdk "34"
- 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