-
Notifications
You must be signed in to change notification settings - Fork 9
/
.gitlab-ci.yml
198 lines (173 loc) · 6.73 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
include:
- 'https://gitlab-templates.ddbuild.io/slack-notifier/v1/template.yml'
# SETUP
variables:
CURRENT_CI_IMAGE: "9"
CI_IMAGE_DOCKER: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/dd-sdk-android-gradle-plugin:$CURRENT_CI_IMAGE
GIT_DEPTH: 5
DD_SERVICE: "dd-sdk-android-gradle-plugin"
DD_ENV_TESTS: "ci"
DD_INTEGRATION_JUNIT_5_ENABLED: "true"
DD_CIVISIBILITY_ENABLED: "true"
DD_INSIDE_CI: "true"
DD_COMMON_AGENT_CONFIG: "dd.env=ci,dd.trace.enabled=false,dd.jmx.fetch.enabled=false"
KUBERNETES_MEMORY_REQUEST: "8Gi"
KUBERNETES_MEMORY_LIMIT: "16Gi"
stages:
- ci-image
- security
- analysis
- test
- publish
- notify
# CI IMAGE
ci-image:
stage: ci-image
when: manual
except: [ tags, schedules ]
tags: [ "arch:amd64" ]
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal
script:
- docker buildx build --tag $CI_IMAGE_DOCKER -f Dockerfile.gitlab --push .
# SECURITY
create_key:
stage: security
when: manual
tags: [ "arch:amd64" ]
variables:
PROJECT_NAME: "dd-sdk-android-gradle-plugin"
EXPORT_TO_KEYSERVER: "true"
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/agent-key-management-tools/gpg:1
script:
- /create.sh
artifacts:
expire_in: 13 mos
paths:
- pubkeys
# STATIC ANALYSIS
static-analysis:
stage: analysis
variables:
DETEKT_PUBLIC_API: "true"
trigger:
include: "https://gitlab-templates.ddbuild.io/mobile/v25558398-8517309a/static-analysis.yml"
strategy: depend
analysis:licenses:
tags: [ "arch:amd64" ]
image: $CI_IMAGE_DOCKER
stage: analysis
timeout: 30m
script:
- git fetch --depth=1 origin main
- GRADLE_OPTS="-Xmx2560m" ./gradlew :dd-sdk-android-gradle-plugin:checkThirdPartyLicences --stacktrace --no-daemon
analysis:woke:
tags: [ "arch:amd64" ]
image: $CI_IMAGE_DOCKER
stage: analysis
timeout: 30m
script:
- git fetch --depth=1 origin master
- /usr/bin/woke --exit-1-on-failure
# TESTS
test:plugin:
tags: [ "arch:amd64" ]
image: $CI_IMAGE_DOCKER
stage: test
timeout: 1h
script:
- git fetch --depth=1 origin main
- rm -rf ~/.gradle/daemon/
- CODECOV_TOKEN=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android-gradle-plugin.codecov-token --with-decryption --query "Parameter.Value" --out text)
- export DD_AGENT_HOST="$BUILDENV_HOST_IP"
- GRADLE_OPTS="-Xmx2560m" DD_TAGS="test.module:dd-sdk-android-gradle-plugin" ./gradlew :dd-sdk-android-gradle-plugin:test --stacktrace --no-daemon -Dorg.gradle.jvmargs=-javaagent:$(pwd)/libs/dd-java-agent-1.26.1.jar=$DD_COMMON_AGENT_CONFIG
- bash <(cat ./codecov.sh) -t $CODECOV_TOKEN
artifacts:
reports:
junit: dd-sdk-android-gradle-plugin/build/test-results/test/TEST-*.xml
# PUBLISH ARTIFACTS
publish:publish-sonatype:
tags: [ "arch:amd64" ]
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-plugin.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- export GPG_PRIVATE_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android-gradle-plugin.signing.gpg_private_key --with-decryption --query "Parameter.Value" --out text)
- export GPG_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android-gradle-plugin.signing.gpg_passphrase --with-decryption --query "Parameter.Value" --out text)
- export OSSRH_USERNAME=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android-gradle-plugin.signing.ossrh_username --with-decryption --query "Parameter.Value" --out text)
- export OSSRH_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android-gradle-plugin.signing.ossrh_password --with-decryption --query "Parameter.Value" --out text)
- git fetch --depth=1 origin main
- ./gradlew :dd-sdk-android-gradle-plugin:publishPluginMavenPublicationToMavenRepository --stacktrace --no-daemon
publish:publish-gradle-portal:
tags: [ "arch:amd64" ]
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-plugin.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- export GPG_PRIVATE_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android-gradle-plugin.signing.gpg_private_key --with-decryption --query "Parameter.Value" --out text)
- export GPG_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android-gradle-plugin.signing.gpg_passphrase --with-decryption --query "Parameter.Value" --out text)
- git fetch --depth=1 origin main
- ./gradlew :dd-sdk-android-gradle-plugin:publishPlugins --stacktrace --no-daemon
# SLACK NOTIFICATIONS
notify:release:
extends: .slack-notifier-base
stage: notify
when: on_success
only:
- tags
script:
- MAVEN_URL="https://search.maven.org/artifact/com.datadoghq/dd-sdk-android-gradle-plugin/$CI_COMMIT_TAG/aar"
- 'MESSAGE_TEXT=":package: $CI_PROJECT_NAME $CI_COMMIT_TAG published on :maven: $MAVEN_URL"'
- postmessage "#mobile-sdk-ops" "$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-sdk-ops" "$MESSAGE_TEXT"
# DOGFOOD
notify:dogfood-app:
tags: [ "arch:amd64" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: notify
when: on_success
script:
- pip3 install GitPython requests
# reuse service account
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android-gradle-plugin.gh_token --with-decryption --query "Parameter.Value" --out text >> ./gh_token
- python3 dogfood.py -v $CI_COMMIT_TAG -t app
notify:dogfood-demo:
tags: [ "arch:amd64" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: notify
when: on_success
script:
- pip3 install GitPython requests
# reuse service account
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android-gradle-plugin.gh_token --with-decryption --query "Parameter.Value" --out text >> ./gh_token
- python3 dogfood.py -v $CI_COMMIT_TAG -t demo
notify:dogfood-gradle-plugin:
tags: [ "arch:amd64" ]
only:
- tags
image: $CI_IMAGE_DOCKER
stage: notify
when: on_success
script:
- pip3 install GitPython requests
# reuse service account
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android-gradle-plugin.gh_token --with-decryption --query "Parameter.Value" --out text >> ./gh_token
- python3 dogfood.py -v $CI_COMMIT_TAG -t gradle-plugin