forked from DataDog/dd-sdk-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
272 lines (241 loc) · 8.59 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
include:
- 'https://gitlab-templates.ddbuild.io/slack-notifier/v1/template.yml'
# SETUP
variables:
CURRENT_CI_IMAGE: "1"
CI_IMAGE_DOCKER: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/dd-sdk-android:$CURRENT_CI_IMAGE
GIT_DEPTH: 5
DD_AGENT_HOST: "$BUILDENV_HOST_IP"
DD_SERVICE: "dd-sdk-android"
DD_ENV_TESTS: "ci"
DD_INTEGRATION_JUNIT_5_ENABLED: "true"
stages:
- ci-image
- analysis
- test
- publish
- notify
# CI IMAGE
ci-image:
stage: ci-image
when: manual
except: [ tags, schedules ]
tags: [ "runner:docker", "size:large" ]
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:18.03.1
script:
- docker build --tag $CI_IMAGE_DOCKER -f Dockerfile.gitlab .
- docker push $CI_IMAGE_DOCKER
# STATIC ANALYSIS
analysis:ktlint:
tags: [ "runner:main", "size:large" ]
image: $CI_IMAGE_DOCKER
stage: analysis
timeout: 30m
script:
- git fetch --depth=1 origin master
- GRADLE_OPTS="-XX:MaxPermSize=512m -Xmx2560m" ./gradlew :ktlintCheckAll --stacktrace --no-daemon
analysis:android-lint:
tags: [ "runner:main", "size:large" ]
image: $CI_IMAGE_DOCKER
stage: analysis
timeout: 30m
script:
- git fetch --depth=1 origin master
- GRADLE_OPTS="-XX:MaxPermSize=512m -Xmx2560m" ./gradlew :lintCheckAll --stacktrace --no-daemon
analysis:detekt:
tags: [ "runner:main", "size:large" ]
image: $CI_IMAGE_DOCKER
stage: analysis
timeout: 30m
script:
- git fetch --depth=1 origin master
- GRADLE_OPTS="-XX:MaxPermSize=512m -Xmx2560m" ./gradlew :detektAll --stacktrace --no-daemon
analysis:licenses:
tags: [ "runner:main", "size:large" ]
image: $CI_IMAGE_DOCKER
stage: analysis
timeout: 30m
script:
- git fetch --depth=1 origin master
- GRADLE_OPTS="-XX:MaxPermSize=512m -Xmx2560m" ./gradlew :dd-sdk-android:checkThirdPartyLicences :dd-sdk-android-timber:checkThirdPartyLicences --stacktrace --no-daemon
analysis:api-surface:
tags: [ "runner:main", "size:large" ]
image: $CI_IMAGE_DOCKER
stage: analysis
timeout: 30m
script:
- git fetch --depth=1 origin master
- GRADLE_OPTS="-XX:MaxPermSize=512m -Xmx2560m" ./gradlew :dd-sdk-android:checkApiSurfaceChanges :dd-sdk-android-timber:checkApiSurfaceChanges --stacktrace --no-daemon
# TESTS
test:debug:
tags: [ "runner:main", "size:large" ]
image: $CI_IMAGE_DOCKER
stage: test
timeout: 1h
script:
- git fetch --depth=1 origin master
- rm -rf ~/.gradle/daemon/
- CODECOV_TOKEN=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.codecov-token --with-decryption --query "Parameter.Value" --out text)
- GRADLE_OPTS="-XX:MaxPermSize=512m -Xmx2560m" ./gradlew :unitTestDebug --stacktrace --no-daemon
- bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN
test:release:
tags: [ "runner:main", "size:large" ]
image: $CI_IMAGE_DOCKER
stage: test
timeout: 1h
script:
- git fetch --depth=1 origin master
- rm -rf ~/.gradle/daemon/
- GRADLE_OPTS="-XX:MaxPermSize=512m -Xmx2560m" ./gradlew :unitTestRelease --stacktrace --no-daemon
test:tools:
tags: [ "runner:main", "size:large" ]
image: $CI_IMAGE_DOCKER
stage: test
timeout: 1h
script:
- git fetch --depth=1 origin master
- rm -rf ~/.gradle/daemon/
- GRADLE_OPTS="-XX:MaxPermSize=512m -Xmx2560m" ./gradlew :unitTestTools --stacktrace --no-daemon
# PUBLISH ARTIFACTS ON BINTRAY
publish:release:
tags: [ "runner:main", "size:large" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: publish
timeout: 30m
script:
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- git fetch --depth=1 origin master
- ./gradlew :dd-sdk-android:bintrayUpload --stacktrace --no-daemon
publish:release-coil:
tags: [ "runner:main", "size:large" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: publish
timeout: 30m
script:
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- git fetch --depth=1 origin master
- ./gradlew :dd-sdk-android-coil:bintrayUpload --stacktrace --no-daemon
publish:release-fresco:
tags: [ "runner:main", "size:large" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: publish
timeout: 30m
script:
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- git fetch --depth=1 origin master
- ./gradlew :dd-sdk-android-fresco:bintrayUpload --stacktrace --no-daemon
publish:release-glide:
tags: [ "runner:main", "size:large" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: publish
timeout: 30m
script:
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- git fetch --depth=1 origin master
- ./gradlew :dd-sdk-android-glide:bintrayUpload --stacktrace --no-daemon
publish:release-ktx:
tags: [ "runner:main", "size:large" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: publish
timeout: 30m
script:
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- git fetch --depth=1 origin master
- ./gradlew :dd-sdk-android-ktx:bintrayUpload --stacktrace --no-daemon
publish:release-ndk:
tags: [ "runner:main", "size:large" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: publish
timeout: 30m
script:
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- git fetch --depth=1 origin master
- ./gradlew :dd-sdk-android-ndk:bintrayUpload --stacktrace --no-daemon
publish:release-rx:
tags: [ "runner:main", "size:large" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: publish
timeout: 30m
script:
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- git fetch --depth=1 origin master
- ./gradlew :dd-sdk-android-rx:bintrayUpload --stacktrace --no-daemon
publish:release-sqldelight:
tags: [ "runner:main", "size:large" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: publish
timeout: 30m
script:
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- git fetch --depth=1 origin master
- ./gradlew :dd-sdk-android-sqldelight:bintrayUpload --stacktrace --no-daemon
publish:release-timber:
tags: [ "runner:main", "size:large" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: publish
timeout: 30m
script:
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- git fetch --depth=1 origin master
- ./gradlew :dd-sdk-android-timber:bintrayUpload --stacktrace --no-daemon
# SLACK NOTIFICATIONS
notify:release:
extends: .slack-notifier-base
stage: notify
when: on_success
only:
- tags
script:
- BINTRAY_URL="https://bintray.com/datadog/datadog-maven/dd-sdk-android/$CI_COMMIT_TAG"
- 'MESSAGE_TEXT=":package: $CI_PROJECT_NAME $CI_COMMIT_TAG published on :bintray: $BINTRAY_URL"'
- postmessage "#mobile-rum" "$MESSAGE_TEXT"
notify:failure:
extends: .slack-notifier-base
stage: notify
when: on_failure
only:
- tags
script:
- BUILD_URL="$CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID"
- 'MESSAGE_TEXT=":status_alert: $CI_PROJECT_NAME $CI_COMMIT_TAG publish pipeline <$BUILD_URL|$COMMIT_MESSAGE> failed."'
- postmessage "#mobile-rum" "$MESSAGE_TEXT"
notify:dogfood-app:
tags: [ "runner:main", "size:large" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: notify
when: on_success
script:
- pip3 install GitPython requests
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gh_token --with-decryption --query "Parameter.Value" --out text >> ./gh_token
- python3 dogfood.py -v $CI_COMMIT_TAG -t app
notify:dogfood-demo:
tags: [ "runner:main", "size:large" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: notify
when: on_success
script:
- pip3 install GitPython requests
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gh_token --with-decryption --query "Parameter.Value" --out text >> ./gh_token
- python3 dogfood.py -v $CI_COMMIT_TAG -t demo