-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
395 lines (350 loc) · 12.2 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
stages:
- dependencies
- build
- test
- publish
default:
retry:
max: 2
when:
- api_failure
- runner_system_failure
- scheduler_failure
- stale_schedule
- stuck_or_timeout_failure
- unknown_failure
variables: &default-variables
TZ: "UTC"
GIT_DEPTH: "1"
.build-resources-xs: &build-resources-xs
KUBERNETES_MEMORY_REQUEST: 512Mi
KUBERNETES_MEMORY_LIMIT: 512Mi
.build-resources-s: &build-resources-s
KUBERNETES_MEMORY_REQUEST: 1Gi
KUBERNETES_MEMORY_LIMIT: 1Gi
.build-resources-m: &build-resources-m
KUBERNETES_MEMORY_REQUEST: 2Gi
KUBERNETES_MEMORY_LIMIT: 2Gi
.build-resources-ml: &build-resources-ml
KUBERNETES_MEMORY_REQUEST: 2560Mi
KUBERNETES_MEMORY_LIMIT: 2560Mi
.haproxy_stable: &haproxy-stable
HAPROXY_GITREPO: "https://git.haproxy.org/?p=haproxy-3.0.git"
HAPROXY_VERSION: 3.0-stable
# https://git.haproxy.org/?p=haproxy-3.0.git;a=commit;h=v3.0.5
HAPROXY_GITREF: "v3.0.5"
BUILD_PATCHES_DIR: "patches-stable"
HAPROXY_LIBASAN: "false"
HAPROXY_LIBUBSAN: "false"
.haproxy_dev: &haproxy-dev
HAPROXY_GITREPO: "https://git.haproxy.org/?p=haproxy.git"
HAPROXY_VERSION: 3.1-dev
# https://git.haproxy.org/?p=haproxy.git;a=commit;h=217e467e89d15f3c22e11fe144458afbf718c8a8
HAPROXY_GITREF: "217e467e89d15f3c22e11fe144458afbf718c8a8"
BUILD_PATCHES_DIR: "patches-dev"
HAPROXY_LIBASAN: "false"
HAPROXY_LIBUBSAN: "false"
.build-job: &build-job
image: ghcr.io/mangadex-pub/debuilder:bookworm-clang18
needs: [ ]
before_script:
- apt -qq update
- apt install -y --no-install-recommends -qq build-essential ca-certificates cmake curl git libasan6 libjemalloc-dev libpcre2-dev libreadline-dev libsystemd-dev tar zlib1g-dev
- cc --version
#----------------------
# Common dependencies
#----------------------
awslc:
<<: *build-job
stage: dependencies
script: make deps/awslc
variables:
<<: *default-variables
<<: *build-resources-m
artifacts:
expire_in: 7 days
paths: [ "deps/awslc/awslc-dist.tar.gz" ]
dataplaneapi:
<<: *build-job
image: docker.io/library/golang:1.23-bookworm
stage: dependencies
script: make deps/dataplaneapi
variables:
<<: *default-variables
<<: *build-resources-ml
artifacts:
expire_in: 7 days
paths: [ "deps/dataplaneapi/dataplaneapi-dist.tar.gz" ]
lua:
<<: *build-job
stage: dependencies
script: make deps/lua
variables:
<<: *default-variables
<<: *build-resources-xs
artifacts:
expire_in: 7 days
paths: [ "deps/lua/lua-dist.tar.gz" ]
pcre2:
<<: *build-job
stage: dependencies
script: make deps/pcre2
variables:
<<: *default-variables
<<: *build-resources-xs
artifacts:
expire_in: 7 days
paths: [ "deps/pcre2/pcre2-dist.tar.gz" ]
vtest:
<<: *build-job
stage: dependencies
script: make deps/vtest
variables:
<<: *default-variables
<<: *build-resources-xs
artifacts:
expire_in: 7 days
paths: [ "deps/vtest/dist/vtest" ]
.needs-dependencies: &needs-dependencies
- job: awslc
artifacts: true
- job: dataplaneapi
artifacts: true
- job: lua
artifacts: true
- job: pcre2
artifacts: true
#----------------------
# HAProxy job templates
#----------------------
.haproxy-build: &haproxy-build
<<: *build-job
stage: build
script:
- apt install -y --no-install-recommends -qq bzip2 git
- mkdir deps/awslc/dist && tar -C deps/awslc/dist -xf deps/awslc/awslc-dist.tar.gz
- mkdir deps/lua/dist && tar -C deps/lua/dist -xf deps/lua/lua-dist.tar.gz
- mkdir deps/pcre2/dist && tar -C deps/pcre2/dist -xf deps/pcre2/pcre2-dist.tar.gz
- make -C haproxy HAPROXY_GITREPO="$HAPROXY_GITREPO" HAPROXY_VERSION="$HAPROXY_VERSION" HAPROXY_GITREF="$HAPROXY_GITREF" BUILD_PATCHES_DIR="$BUILD_PATCHES_DIR" HAPROXY_LIBASAN="$HAPROXY_LIBASAN"
needs: *needs-dependencies
artifacts:
expire_in: 7 days
paths: [ "haproxy/dist", "haproxy/haproxy-dist.tar.gz" ]
.haproxy-regtests: &haproxy-regtests
<<: *build-job
stage: test
script:
- apt install -y --no-install-recommends -qq bzip2 git
- mkdir deps/awslc/dist && tar -C deps/awslc/dist -xf deps/awslc/awslc-dist.tar.gz
- mkdir deps/lua/dist && tar -C deps/lua/dist -xf deps/lua/lua-dist.tar.gz
- mkdir deps/pcre2/dist && tar -C deps/pcre2/dist -xf deps/pcre2/pcre2-dist.tar.gz
- |
set -euo pipefail
if [ "$(ulimit -n)" = "1073741816" ]; then echo "Bad Docker ulimit: $(ulimit -n)..."; exit 1; else echo "ulimit -n = $(ulimit -n)"; fi
make -C haproxy HAPROXY_GITREPO="$HAPROXY_GITREPO" HAPROXY_VERSION="$HAPROXY_VERSION" HAPROXY_GITREF="$HAPROXY_GITREF" BUILD_PATCHES_DIR="$BUILD_PATCHES_DIR" HAPROXY_LIBASAN="$HAPROXY_LIBASAN" build test
needs:
- *needs-dependencies
- job: vtest
artifacts: true
.haproxy-debian: &haproxy-debian
<<: *build-job
stage: publish
script:
- apt install -y --no-install-recommends -qq bzip2 devscripts debhelper pkg-config
- mkdir deps/awslc/dist && tar -C deps/awslc/dist -xf deps/awslc/awslc-dist.tar.gz
- mkdir deps/dataplaneapi/dist && tar -C deps/dataplaneapi/dist -xf deps/dataplaneapi/dataplaneapi-dist.tar.gz
- mkdir deps/lua/dist && tar -C deps/lua/dist -xf deps/lua/lua-dist.tar.gz
- mkdir deps/pcre2/dist && tar -C deps/pcre2/dist -xf deps/pcre2/pcre2-dist.tar.gz
- export BUILD_MESSAGE="$CI_COMMIT_MESSAGE"
- make -C haproxy dist-deb HAPROXY_GITREPO="$HAPROXY_GITREPO" HAPROXY_VERSION="$HAPROXY_VERSION" HAPROXY_GITREF="$HAPROXY_GITREF" BUILD_PATCHES_DIR="$BUILD_PATCHES_DIR" HAPROXY_LIBASAN="$HAPROXY_LIBASAN"
- |
set -euo pipefail
PACKAGE_NAME="haproxy-debian"
DEB_VERSION="$(cat haproxy/*.dsc | grep -E '^Version:' | cut -d' ' -f2-)"
if [ "$CI_COMMIT_REF_NAME" != "$CI_DEFAULT_BRANCH" ]; then
export PACKAGE_NAME="haproxy-debian-branches"
export DEB_VERSION="branch-$CI_COMMIT_REF_SLUG"
echo "Git reference $CI_COMMIT_REF_NAME is not the default branch. Setting coordinates to $PACKAGE_NAME/$DEB_VERSION"
fi
GITLAB_PACKAGE_VERSION=$(echo "${DEB_VERSION}" | tr '~' '-')
echo "Publishing Debian package version ${DEB_VERSION} to haproxy-debian@${GITLAB_PACKAGE_VERSION}"
for artifact in haproxy/haproxy*.deb; do
artifact_filename=$(basename "${artifact}")
gitlab_is_lame_artifact_filename=$(echo "${artifact_filename}" | tr '~' '-' | tr '+' '-')
echo "Uploading to haproxy-debian@${DEB_VERSION}... ${artifact_filename} -> ${gitlab_is_lame_artifact_filename}"
curl -fsSL -H"JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file "${artifact}" \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PACKAGE_NAME}/${GITLAB_PACKAGE_VERSION}/${gitlab_is_lame_artifact_filename}"
echo "OK"
done
artifacts:
expire_in: 7 days
paths: [ "haproxy/haproxy*" ]
.haproxy-tarball: &haproxy-tarball
image: docker.io/curlimages/curl:latest
stage: publish
script: |
set -eu
PKG_VER=$HAPROXY_VERSION
if [ "$CI_COMMIT_REF_NAME" != "$CI_DEFAULT_BRANCH" ]; then
export PKG_VER="branch-$CI_COMMIT_REF_SLUG-$HAPROXY_VERSION-$HAPROXY_GITREF"
echo "Git reference $CI_COMMIT_REF_NAME is not the default branch. Setting version to $PKG_VER"
fi
curl -fsSL \
-H"JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file "haproxy/haproxy-dist.tar.gz" \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/haproxy/$PKG_VER/haproxy-$HAPROXY_VERSION.tar.gz"
.haproxy-docker: &haproxy-docker
stage: publish
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [ "" ]
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"gitlab-ci-token\",\"password\":\"$CI_JOB_TOKEN\"}}}" > /kaniko/.docker/config.json
script: |
set -eu
export DEBIAN_CODENAME="bookworm"
export JOB_TIMESTAMP="$(date -D '%Y-%m-%dT%H:%M:%S' -d "$CI_JOB_STARTED_AT" +'%Y%m%d-%H%M')"
# A.B.C -> A.B, otherwise preserve original (eg 2.x-dev -> 2.x-dev)
if echo "$HAPROXY_VERSION" | grep -E '([0-9]\.){2}[0-9]'; then
export HAPROXY_SHORTVER="$(echo "$HAPROXY_VERSION" | cut -d'.' -f1-2)"
else
export HAPROXY_SHORTVER=$HAPROXY_VERSION
fi
echo "Building image with"
echo " -> haproxy version: $HAPROXY_VERSION ($HAPROXY_SHORTVER)"
echo " -> debian codename: $DEBIAN_CODENAME"
echo " -> git commit hash: $CI_COMMIT_SHORT_SHA"
echo " -> build timestamp: $JOB_TIMESTAMP"
export IMAGE_TAG_UNIQUE="$CI_COMMIT_SHORT_SHA-$JOB_TIMESTAMP-$HAPROXY_SHORTVER-$HAPROXY_GITREF"
export IMAGE_TAG_ROLLING_COMMIT="git-$CI_COMMIT_SHORT_SHA-$HAPROXY_VERSION"
export IMAGE_TAG_ROLLING_GITREF="$CI_COMMIT_REF_SLUG-$HAPROXY_VERSION"
export IMAGE_TAG_VERSIONS="$HAPROXY_VERSION-$DEBIAN_CODENAME"
export IMAGE_TAG_SHORTVER="$HAPROXY_SHORTVER-$DEBIAN_CODENAME"
if [ "$CI_COMMIT_REF_NAME" != "$CI_DEFAULT_BRANCH" ]; then
export IMAGE_TAG_VERSIONS="branch-$CI_COMMIT_REF_SLUG-$IMAGE_TAG_VERSIONS"
export IMAGE_TAG_SHORTVER="branch-$CI_COMMIT_REF_SLUG-$IMAGE_TAG_SHORTVER"
echo "Git reference $CI_COMMIT_REF_NAME is not the default branch. Rewriting git rolling tag as $IMAGE_TAG_VERSIONS / $IMAGE_TAG_SHORTVER"
fi
echo "***"
echo "Will build and push image as:"
echo "- $CI_REGISTRY_IMAGE:$IMAGE_TAG_UNIQUE"
echo "- $CI_REGISTRY_IMAGE:$IMAGE_TAG_ROLLING_COMMIT"
echo "- $CI_REGISTRY_IMAGE:$IMAGE_TAG_ROLLING_GITREF"
echo "- $CI_REGISTRY_IMAGE:$IMAGE_TAG_VERSIONS"
echo "- $CI_REGISTRY_IMAGE:$IMAGE_TAG_SHORTVER"
echo "***"
(
set -x;
/kaniko/executor \
--context . \
--dockerfile Dockerfile \
--build-arg "CANONICAL_VERSION=$IMAGE_TAG_UNIQUE" \
--destination "$CI_REGISTRY_IMAGE:$IMAGE_TAG_UNIQUE" \
--destination "$CI_REGISTRY_IMAGE:$IMAGE_TAG_ROLLING_COMMIT" \
--destination "$CI_REGISTRY_IMAGE:$IMAGE_TAG_ROLLING_GITREF" \
--destination "$CI_REGISTRY_IMAGE:$IMAGE_TAG_VERSIONS" \
--destination "$CI_REGISTRY_IMAGE:$IMAGE_TAG_SHORTVER" \
--single-snapshot
)
#----------------------
# HAProxy jobs
#----------------------
build:stable:
<<: *haproxy-build
variables:
<<: *default-variables
<<: *build-resources-s
<<: *haproxy-stable
build:dev:
<<: *haproxy-build
variables:
<<: *default-variables
<<: *build-resources-s
<<: *haproxy-dev
regtests:stable:
<<: *haproxy-regtests
variables:
<<: *default-variables
<<: *build-resources-m
<<: *haproxy-stable
regtests:dev:
<<: *haproxy-regtests
variables:
<<: *default-variables
<<: *build-resources-m
<<: *haproxy-dev
haproxy-tarball:stable:
<<: *haproxy-tarball
variables:
<<: *default-variables
<<: *build-resources-xs
<<: *haproxy-stable
needs:
- job: "regtests:stable"
artifacts: false
- job: "build:stable"
artifacts: true
haproxy-tarball:dev:
<<: *haproxy-tarball
variables:
<<: *default-variables
<<: *build-resources-xs
<<: *haproxy-dev
needs:
- job: "regtests:dev"
artifacts: false
- job: "build:dev"
artifacts: true
docker:stable:
<<: *haproxy-docker
variables:
<<: *default-variables
<<: *build-resources-m
<<: *haproxy-stable
needs:
- job: "awslc"
artifacts: true
- job: "dataplaneapi"
artifacts: true
- job: "regtests:stable"
artifacts: false
- job: "build:stable"
artifacts: true
docker:dev:
<<: *haproxy-docker
variables:
<<: *default-variables
<<: *build-resources-m
<<: *haproxy-dev
needs:
- job: "awslc"
artifacts: true
- job: "dataplaneapi"
artifacts: true
- job: "regtests:dev"
artifacts: false
- job: "build:dev"
artifacts: true
debian:stable:
<<: *haproxy-debian
variables:
<<: *default-variables
<<: *build-resources-m
<<: *haproxy-stable
allow_failure: true
needs:
- *needs-dependencies
- job: "regtests:stable"
artifacts: false
debian:dev:
<<: *haproxy-debian
variables:
<<: *default-variables
<<: *build-resources-m
<<: *haproxy-dev
needs:
- *needs-dependencies
- job: "regtests:dev"
artifacts: false