-
Notifications
You must be signed in to change notification settings - Fork 375
/
.gitlab-ci.yml
233 lines (214 loc) · 6.67 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
stages:
- manual-images
- package
- integration-tests
- deploy
- macrobenchmarks
- microbenchmarks
- benchmarks
include:
- remote: https://gitlab-templates.ddbuild.io/apm/packaging.yml
- local: ".gitlab/benchmarks.yml"
- local: ".gitlab/onboarding_tests.yml"
variables:
DOWNSTREAM_BRANCH:
value: "master"
description: "Run a specific datadog-reliability-env branch downstream"
RUBY_CUSTOM_IMAGE_BASE: $DOCKER_REGISTRY/ci/dd-trace-rb/custom_ruby
default:
tags: ["runner:main", "size:large"]
.build-image-base:
stage: manual-images
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push"
changes:
- .gitlab/Dockerfile-*
when: manual
allow_failure: true
image: $DOCKER_REGISTRY/docker:20.10.13
parallel:
matrix:
# ADD NEW RUBIES HERE
- RUBY_VERSION: ["3.2.2", "3.1.4", "3.0.6", "2.7.8"]
script:
- >
docker build
--tag $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-$ARCHITECTURE:$CI_PIPELINE_ID
--file .gitlab/Dockerfile-$RUBY_VERSION
.
- docker push --all-tags $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-$ARCHITECTURE
build-image-amd64:
extends: .build-image-base
tags: ["runner:docker"]
variables:
ARCHITECTURE: amd64
build-image-arm64:
extends: .build-image-base
tags: ["runner:docker-arm", "platform:arm64"]
variables:
ARCHITECTURE: arm64
promote-image:
stage: manual-images
when: manual
tags: ["runner:docker"]
image: $DOCKER_REGISTRY/docker:20.10.13
parallel:
matrix:
# ADD NEW RUBIES HERE
- RUBY_VERSION: ["3.2.2", "3.1.4", "3.0.6", "2.7.8"]
ARCHITECTURE: ["amd64", "arm64"]
script:
- docker pull $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-$ARCHITECTURE:$CI_PIPELINE_ID
- docker tag $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-$ARCHITECTURE:$CI_PIPELINE_ID $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-$ARCHITECTURE:current
- docker push $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-$ARCHITECTURE:current
build-gem:
image: $DOCKER_REGISTRY/images/mirror/ruby:3.2.2
stage: package
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: on_success
- if: $CI_COMMIT_TAG
when: on_success
- if: $CI_COMMIT_BRANCH == 'master'
when: on_success
- when: manual
allow_failure: true
script:
- |
if [ -z "$CI_COMMIT_TAG" ]; then
echo CI_JOB_ID=$CI_JOB_ID
echo CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME
echo CI_COMMIT_SHA=$CI_COMMIT_SHA
.gitlab/patch_gem_version.sh glci $CI_JOB_ID $CI_COMMIT_REF_NAME $CI_COMMIT_SHA
fi
- bundle install && chmod go-w -R . && bundle exec rake build
- mkdir -p tmp && ruby -Ilib -rdatadog/version -e 'puts Gem::Version.new(Datadog::VERSION::STRING).to_s' >> tmp/version.txt
artifacts:
paths:
- pkg
- tmp
- lib/datadog/version.rb
.install-dependencies:
parallel:
matrix:
- RUBY_VERSION: ["2.7.8", "3.0.6", "3.1.4", "3.2.2"]
stage: package
needs:
- build-gem
script:
- export RUBY_PACKAGE_VERSION=$(cat tmp/version.txt)
- export DATADOG_GEM_LOCATION=$(readlink -f pkg/datadog-*.gem)
- ruby .gitlab/install_datadog_deps.rb
artifacts:
paths:
- pkg
- tmp
- lib/datadog/version.rb
install-dependencies-amd64:
extends: .install-dependencies
image: $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-amd64:current
tags: ["runner:main"]
install-dependencies-arm64:
extends: .install-dependencies
image: $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-arm64:current
tags: ["arch:arm64"]
package-amd64:
extends: .package
needs:
- build-gem
- install-dependencies-amd64
script:
- ls ../pkg
- cp ../lib-injection/host_inject.rb ../tmp
- export RUBY_PACKAGE_VERSION=$(cat ../tmp/version.txt)
- ../.gitlab/build-deb-rpm.sh
- find . -iregex '.*\.\(deb\|rpm\)' -printf '%f\0' | xargs -0 dd-pkg lint
package-arm64:
extends: .package-arm
needs:
- build-gem
- install-dependencies-arm64
script:
- ls ../pkg
- cp ../lib-injection/host_inject.rb ../tmp
- export RUBY_PACKAGE_VERSION=$(cat ../tmp/version.txt)
- ../.gitlab/build-deb-rpm.sh
- find . -iregex '.*\.\(deb\|rpm\)' -printf '%f\0' | xargs -0 dd-pkg lint
onboarding_tests:
extends: .base_job_onboarding_tests
stage: integration-tests
needs: [ package-amd64, package-arm64]
allow_failure: false
variables:
TEST_LIBRARY: ruby
ONBOARDING_FILTER_ENV: prod
parallel:
matrix:
- ONBOARDING_FILTER_WEBLOG: [test-app-ruby]
SCENARIO: [SIMPLE_HOST_AUTO_INJECTION]
- ONBOARDING_FILTER_WEBLOG: [test-app-ruby-container]
SCENARIO: [SIMPLE_CONTAINER_AUTO_INJECTION]
script:
- git clone https://git@github.com/DataDog/system-tests.git system-tests
- cp packaging/*.rpm system-tests/binaries
- cp packaging/*.deb system-tests/binaries
- ls system-tests/binaries
- cd system-tests
- ./build.sh -i runner
- timeout 2700s ./run.sh $SCENARIO --vm-weblog ${ONBOARDING_FILTER_WEBLOG} --vm-env prod --vm-library ${TEST_LIBRARY} --vm-provider aws --vm-skip-branches ubuntu18_amd64
.release-package:
stage: deploy
variables:
PRODUCT_NAME: auto_inject-ruby
deploy_to_reliability_env:
stage: deploy
needs: [] # This allows the job to run without prerequisites
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: on_success
- when: manual
allow_failure: true
trigger:
project: DataDog/apm-reliability/datadog-reliability-env
branch: $DOWNSTREAM_BRANCH
variables:
UPSTREAM_BRANCH: $CI_COMMIT_REF_NAME
UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
deploy_to_docker_registries:
stage: deploy
rules:
- if: "$POPULATE_CACHE"
when: never
- if: $CI_COMMIT_TAG =~ /^v(\d+)\.(\d+)\.(\d+)$/ # Exclude prerelease
when: delayed
start_in: 1 day
- when: manual
allow_failure: true
trigger:
project: DataDog/public-images
branch: main
strategy: depend
variables:
IMG_SOURCES: ghcr.io/datadog/dd-trace-rb/dd-lib-ruby-init:$CI_COMMIT_TAG
IMG_DESTINATIONS: dd-lib-ruby-init:$CI_COMMIT_TAG
IMG_SIGNING: "false"
deploy_latest_tag_to_docker_registries:
stage: deploy
rules:
- if: "$POPULATE_CACHE"
when: never
- if: $CI_COMMIT_TAG =~ /^v(\d+)\.(\d+)\.(\d+)$/ && $CI_COMMIT_BRANCH == 'master' # Exclude prerelease and only for master branch
when: delayed
start_in: 1 day
- when: manual
allow_failure: true
trigger:
project: DataDog/public-images
branch: main
strategy: depend
variables:
IMG_SOURCES: ghcr.io/datadog/dd-trace-rb/dd-lib-ruby-init:$CI_COMMIT_TAG
IMG_DESTINATIONS: dd-lib-ruby-init:latest
IMG_SIGNING: "false"