-
Notifications
You must be signed in to change notification settings - Fork 291
/
.gitlab-ci.yml
275 lines (257 loc) · 9.46 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
include:
- remote: https://gitlab-templates.ddbuild.io/libdatadog/include/ci_authenticated_job.yml
- remote: https://gitlab-templates.ddbuild.io/libdatadog/include/one-pipeline.yml
- local: ".gitlab/benchmarks.yml"
- local: ".gitlab/macrobenchmarks.yml"
- local: ".gitlab/exploration-tests.yml"
- local: ".gitlab/ci-visibility-tests.yml"
stages:
- build
- shared-pipeline
- publish
- benchmarks
- macrobenchmarks
- tests
- exploration-tests
- ci-visibility-tests
- generate-signing-key
variables:
REGISTRY: 486234852809.dkr.ecr.us-east-1.amazonaws.com
BUILD_JOB_NAME: "build"
.common: &common
tags: [ "runner:main", "size:large" ]
.gradle_build: &gradle_build
<<: *common
image: ghcr.io/datadog/dd-trace-java-docker-build:v23.10-base
variables:
GRADLE_OPTS: "-Dorg.gradle.jvmargs='-Xmx2560M -Xms2560M'"
GRADLE_ARGS: " -PskipTests --build-cache --stacktrace --no-daemon --parallel --max-workers=8"
KUBERNETES_CPU_REQUEST: 8
KUBERNETES_MEMORY_REQUEST: 4Gi
cache: &default_cache
key: '$CI_SERVER_VERSION' # Reset the cache every time gitlab is upgraded. ~Every couple months
paths:
- .gradle/wrapper
- .gradle/caches
policy: pull
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
# for weird reasons, gradle will always "chmod 700" the .gradle folder
# with Gitlab caching, .gradle is always owned by root and thus gradle's chmod invocation fails
# This dance is a hack to have .gradle owned by the Gitlab runner user
- mkdir -p .gradle
- cp -r .gradle .gradle-copy
- rm -rf .gradle
- mv .gradle-copy .gradle
- ls -la
build: &build
<<: *gradle_build
stage: build
script:
- ./gradlew clean :dd-java-agent:shadowJar :dd-trace-api:jar :dd-trace-ot:shadowJar $GRADLE_ARGS
- echo UPSTREAM_TRACER_VERSION=$(java -jar workspace/dd-java-agent/build/libs/*.jar) >> upstream.env
- echo "BUILD_JOB_NAME=$CI_JOB_NAME" >> build.env
- echo "BUILD_JOB_ID=$CI_JOB_ID" >> build.env
artifacts:
paths:
- 'workspace/dd-java-agent/build/libs/*.jar'
- 'workspace/dd-trace-api/build/libs/*.jar'
- 'workspace/dd-trace-ot/build/libs/*.jar'
- 'upstream.env'
reports:
dotenv: build.env
build_with_cache:
<<: *build
rules:
- if: '$POPULATE_CACHE'
when: on_success
- when: manual
allow_failure: true
cache:
<<: *default_cache
policy: push
deploy_to_profiling_backend:
stage: publish
needs: [ build ]
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: on_success
- if: '$CI_COMMIT_TAG =~ /^v.*/'
when: on_success
- when: manual
allow_failure: true
trigger:
project: DataDog/profiling-backend
branch: dogfooding
variables:
UPSTREAM_PACKAGE_JOB: $BUILD_JOB_NAME
UPSTREAM_PACKAGE_JOB_ID: $BUILD_JOB_ID
UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
UPSTREAM_PIPELINE_ID: $CI_PIPELINE_ID
UPSTREAM_BRANCH: $CI_COMMIT_BRANCH
UPSTREAM_TAG: $CI_COMMIT_TAG
trigger_tibco_tests:
stage: tests
needs: [ build ]
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: on_success
- if: '$CI_COMMIT_TAG =~ /^v.*/'
when: on_success
- when: manual
allow_failure: true
trigger:
project: DataDog/tibco-testing
branch: main
strategy: depend
variables:
UPSTREAM_PACKAGE_JOB: $BUILD_JOB_NAME
UPSTREAM_PACKAGE_JOB_ID: $BUILD_JOB_ID
UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
UPSTREAM_PIPELINE_ID: $CI_PIPELINE_ID
UPSTREAM_BRANCH: $CI_COMMIT_BRANCH
UPSTREAM_TAG: $CI_COMMIT_TAG
FORCE_TRIGGER: $FORCE_TRIGGER
deploy_to_di_backend:manual:
stage: publish
needs: [ build ]
rules:
- if: '$POPULATE_CACHE'
when: never
- when: manual
allow_failure: true
trigger:
project: DataDog/debugger-demos
branch: main
variables:
UPSTREAM_PACKAGE_JOB: build
UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
UPSTREAM_PIPELINE_ID: $CI_PIPELINE_ID
UPSTREAM_BRANCH: $CI_COMMIT_BRANCH
UPSTREAM_TAG: $CI_COMMIT_TAG
UPSTREAM_COMMIT_AUTHOR: $CI_COMMIT_AUTHOR
UPSTREAM_COMMIT_SHORT_SHA: $CI_COMMIT_SHORT_SHA
deploy_to_sonatype:
<<: *gradle_build
stage: publish
needs: [ build ]
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
# Do not deploy release candidate versions
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
when: on_success
- when: manual
allow_failure: true
script:
- export SONATYPE_USERNAME=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.sonatype_username --with-decryption --query "Parameter.Value" --out text)
- export SONATYPE_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.sonatype_password --with-decryption --query "Parameter.Value" --out text)
- export GPG_PRIVATE_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.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-trace-java.signing.gpg_passphrase --with-decryption --query "Parameter.Value" --out text)
- ./gradlew -PbuildInfo.build.number=$CI_JOB_ID publishToSonatype closeSonatypeStagingRepository $GRADLE_ARGS
artifacts:
paths:
- 'workspace/dd-java-agent/build/libs/*.jar'
- 'workspace/dd-trace-api/build/libs/*.jar'
- 'workspace/dd-trace-ot/build/libs/*.jar'
deploy_artifacts_to_github:
stage: publish
image: registry.ddbuild.io/github-cli:v27480869-eafb11d-2.43.0
tags: [ "arch:amd64" ]
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
when: on_success
# Requires the deploy_to_sonatype job to have run first the UP-TO-DATE gradle check across jobs is broken
# This will deploy the artifacts built from the publishToSonatype task to the GitHub release
needs:
- job: deploy_to_sonatype
# The deploy_to_sonatype job is not run for release candidate versions
optional: true
script:
- aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.gh_release_token --with-decryption --query "Parameter.Value" --out text > github-token.txt
- gh auth login --with-token < github-token.txt
- gh auth status # Maybe helpful to have this output in logs?
- export VERSION=${CI_COMMIT_TAG##v} # remove "v" from front of tag to get version
- cp workspace/dd-java-agent/build/libs/dd-java-agent-${VERSION}.jar workspace/dd-java-agent/build/libs/dd-java-agent.jar # we upload two filenames
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-java-agent/build/libs/dd-java-agent.jar
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-java-agent/build/libs/dd-java-agent-${VERSION}.jar
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-trace-api/build/libs/dd-trace-api-${VERSION}.jar
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-trace-ot/build/libs/dd-trace-ot-${VERSION}.jar
retry:
max: 2
when: always
requirements_json_test:
rules:
- when: on_success
variables:
REQUIREMENTS_BLOCK_JSON_PATH: "metadata/requirements-block.json"
REQUIREMENTS_ALLOW_JSON_PATH: "metadata/requirements-allow.json"
package-oci:
needs: [ build ]
onboarding_tests_installer:
parallel:
matrix:
- ONBOARDING_FILTER_WEBLOG: [test-app-java, test-app-java-container, test-app-java-alpine]
SCENARIO: [ SIMPLE_INSTALLER_AUTO_INJECTION, SIMPLE_AUTO_INJECTION_PROFILING ]
onboarding_tests_k8s_injection:
parallel:
matrix:
- WEBLOG_VARIANT: [dd-lib-java-init-test-app]
create_key:
stage: generate-signing-key
when: manual
needs: [ ]
tags: [ "arch:amd64", "size:large" ]
variables:
PROJECT_NAME: "dd-trace-java"
EXPORT_TO_KEYSERVER: "true"
image: $REGISTRY/ci/agent-key-management-tools/gpg:1
script:
- /create.sh
artifacts:
expire_in: 13 mos
paths:
- pubkeys
tracer-base-image-release:
extends: .ci_authenticated_job
stage: publish
needs: [ build ]
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_TAG =~ /^v1\..*/'
when: on_success
dependencies:
- build
script:
- echo $GH_TOKEN|docker login ghcr.io/datadog -u uploader --password-stdin
- mkdir -p ./tooling/ci/binaries/ && cp workspace/dd-java-agent/build/libs/*.jar ./tooling/ci/binaries/dd-java-agent.jar
- docker buildx build -t ghcr.io/datadog/dd-trace-java/dd-trace-java:latest -f ./tooling/ci/Dockerfile .
- docker push ghcr.io/datadog/dd-trace-java/dd-trace-java:latest
tracer-base-image-snapshot:
extends: .ci_authenticated_job
stage: publish
needs: [ build ]
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
dependencies:
- build
script:
- echo $GH_TOKEN|docker login ghcr.io/datadog -u uploader --password-stdin
- mkdir -p ./tooling/ci/binaries/ && cp workspace/dd-java-agent/build/libs/*.jar ./tooling/ci/binaries/dd-java-agent.jar
- docker buildx build -t ghcr.io/datadog/dd-trace-java/dd-trace-java:latest_snapshot -f ./tooling/ci/Dockerfile .
- docker push ghcr.io/datadog/dd-trace-java/dd-trace-java:latest_snapshot