-
Notifications
You must be signed in to change notification settings - Fork 7
/
.cirrus.yml
412 lines (331 loc) · 10.2 KB
/
.cirrus.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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# Due to the dependency on encrypted variables, this will only work in a
# specific repo
only_if: $CIRRUS_REPO_OWNER == 'anarazel' && $CIRRUS_REPO_NAME == 'pg-vm-images'
env:
CIRRUS_LOG_TIMESTAMP: true
# Prefix for image names
PREFIX: pg-ci
# See gcp_project_setup.txt for setup instructions
GCP_PROJECT_MAIN: pg-ci-images
GCP_PROJECT_DEV: pg-ci-images-dev
# the following variables are chosen in .cirrus.star, based on the branch
# being built etc
# BRANCH_TYPE = dev|main
# BUCKET = ${GCP_PROJECT_MAIN}-bucket or ${GCP_PROJECT_DEV}-bucket
# GCP_PROJECT = $GCP_PROJECT_MAIN or $GCP_PROJECT_DEV
# GCP_REGION
# GCP_REPO
# central definition for the tasks interacting with gcp
# shared gcp auth
gcp_auth: &gcp_auth
env:
GAC_DEV: ENCRYPTED[40c920fc0112638b1ada05929628f296b630db4252100f14ae966effc5bcd840d6cedeb3cbd96bc14ebbf35695bd43b1]
GAC_MAIN: ENCRYPTED[0529fb776190443002786f8e413f98d09ca79170c5a1c5cf66dd076fb232f778c9c13679b2e9f697eeede64033c1a3dd]
# gcp auth for unixoid systems
gcp_auth_unix: &gcp_auth_unix
<<: *gcp_auth
env:
GOOGLE_APPLICATION_CREDENTIALS: /gcp-service-account-${BRANCH_TYPE}.json
gcp_main_key_file:
path: /gcp-service-account-main.json
variable_name: GAC_MAIN
gcp_dev_key_file:
path: /gcp-service-account-dev.json
variable_name: GAC_DEV
gcp_auth_script:
- gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS}
- gcloud auth list
# gcp auth for windows
gcp_auth_win: &gcp_auth_win
<<: *gcp_auth
env:
GOOGLE_APPLICATION_CREDENTIALS: c:/gcp-service-account-%BRANCH_TYPE%.json
gcp_main_key_file:
path: c:/gcp-service-account-main.json
variable_name: GAC_MAIN
gcp_dev_key_file:
path: c:/gcp-service-account-dev.json
variable_name: GAC_DEV
gcp_auth_script:
- gcloud auth activate-service-account --key-file=%GOOGLE_APPLICATION_CREDENTIALS%
- gcloud auth list
# docker->gcp auth for unixoid systems
gcp_docker_auth_unix: &gcp_docker_auth_unix
<<: *gcp_auth_unix
gcp_docker_auth_script:
- gcloud auth configure-docker --quiet $GCP_REGION-docker.pkg.dev
# docker->gcp auth for windows systems
gcp_docker_auth_win: &gcp_docker_auth_win
<<: *gcp_auth_win
gcp_docker_auth_script:
- gcloud auth configure-docker --quiet %GCP_REGION%-docker.pkg.dev
task:
name: Clean up leftover running
alias: cleanup-leftover-running
container:
dockerfile: docker/linux_debian_packer
cpu: 0.5
memory: 256Mi
<<: *gcp_auth_unix
cleanup_leftover_running_script:
./gcp_delete_leftover_running.py
task:
name: 'Building VM Image: ${IMAGE_NAME}'
alias: vmbuild-${TASK_NAME}
matrix:
- env:
TASK_NAME: freebsd-13
PACKERFILE: packer/freebsd.pkr.hcl
- env:
PACKERFILE: packer/linux_debian.pkr.hcl
SCRIPTS: scripts/linux_debian_*
matrix:
- env:
TASK_NAME: bookworm
- env:
TASK_NAME: bullseye
- env:
TASK_NAME: sid
- env:
TASK_NAME: sid-newkernel
- env:
TASK_NAME: sid-newkernel-uring
- env:
PACKERFILE: packer/windows.pkr.hcl
SCRIPTS: scripts/windows*
TASK_NAME: windows-ci
env:
IMAGE_NAME: ${PREFIX}-${TASK_NAME}
depends_on: cleanup-leftover-running
container:
dockerfile: docker/linux_debian_packer
cpu: 0.5
memory: 256Mi
skip: $CIRRUS_LAST_GREEN_CHANGE != '' && $CIRRUS_CRON != 'regular-rebuild' && !changesInclude('.cirrus.yml', 'docker/linux_debian_packer', $SCRIPTS, $PACKERFILE)
allow_failures: $CIRRUS_TASK_NAME =~ '.*\[sid\].*'
auto_cancellation: false
<<: *gcp_auth_unix
info_script:
- packer --version
export_date_script: |
DATE=$(date --utc +'%Y-%m-%dt%H-%M-%S')
echo "DATE=${DATE}" | tee -a $CIRRUS_ENV
build_image_script: |
packer build \
-only "*.${TASK_NAME}" \
-timestamp-ui \
-force \
-var "image_date=$DATE" \
-var "image_name=${IMAGE_NAME}" \
-var gcp_project=$GCP_PROJECT \
"$PACKERFILE"
make_image_public_script: |
gcloud compute images add-iam-policy-binding \
--project "$GCP_PROJECT" \
--member=allAuthenticatedUsers \
--role=roles/compute.imageUser \
${IMAGE_NAME}-${DATE}
gcloud compute images update \
--project "$GCP_PROJECT" \
--family ${IMAGE_NAME} \
${IMAGE_NAME}-${DATE}
task:
name: 'Building VM Image: ${IMAGE_NAME}'
alias: vmbuild-${TASK_NAME}
matrix:
- env:
PKRVARFILE: packer/openbsd.pkrvars.hcl
matrix:
- env:
TASK_NAME: openbsd-vanilla
depends_on:
- cleanup-leftover-running
- env:
TASK_NAME: openbsd-postgres
depends_on:
- vmbuild-openbsd-vanilla
- env:
PKRVARFILE: packer/netbsd.pkrvars.hcl
matrix:
- env:
TASK_NAME: netbsd-vanilla
depends_on:
- cleanup-leftover-running
- env:
TASK_NAME: netbsd-postgres
depends_on:
- vmbuild-netbsd-vanilla
env:
PACKERFILE: packer/netbsd_openbsd.pkr.hcl
IMAGE_NAME: ${PREFIX}-${TASK_NAME}
container:
dockerfile: docker/linux_debian_packer
cpu: 2
memory: 4G
skip: $CIRRUS_LAST_GREEN_CHANGE != '' && $CIRRUS_CRON != 'regular-rebuild' && !changesInclude('.cirrus.yml', 'docker/linux_debian_packer', 'files/bsd/*', 'scripts/bsd/*', $PACKERFILE, $PKRVARFILE)
auto_cancellation: false
<<: *gcp_auth_unix
info_script:
- packer --version
export_date_script: |
DATE=$(date --utc +'%Y-%m-%dt%H-%M-%S')
echo "DATE=${DATE}" | tee -a $CIRRUS_ENV
build_image_script: |
export PACKER_LOG=1
packer build \
-only "*.${TASK_NAME}" \
-timestamp-ui \
-force \
-var-file="${PKRVARFILE}" \
-var "image_date=$DATE" \
-var "image_name=${IMAGE_NAME}" \
-var "prefix=${PREFIX}" \
-var "bucket=$BUCKET" \
-var gcp_project=$GCP_PROJECT \
"$PACKERFILE"
make_image_public_script: |
gcloud compute images add-iam-policy-binding \
--project "$GCP_PROJECT" \
--member=allAuthenticatedUsers \
--role=roles/compute.imageUser \
${IMAGE_NAME}-${DATE}
gcloud compute images update \
--project "$GCP_PROJECT" \
--family ${IMAGE_NAME} \
${IMAGE_NAME}-${DATE}
# Clean up old images regularly - after a while the individually small cost
# starts adding up
#
# Leave old images around for two weeks, to allow recreating CI failures
# precisely.
task:
name: Clean up old images
container:
dockerfile: docker/linux_debian_packer
cpu: 0.5
memory: 256Mi
<<: *gcp_auth_unix
cleanup_images_script:
./gcp_delete_old_images.py
task:
name: 'Building Container Image: ${IMAGE}'
alias: dockerbuild-${IMAGE}
compute_engine_instance:
image_project: cirrus-images
image: family/docker-builder
platform: linux
cpu: 2
memory: 8G
matrix:
- env:
DOCKER_FILE: linux_debian_ci
IMAGE: linux_debian_${DEBIAN_RELEASE}_ci
matrix:
- env:
DEBIAN_RELEASE: bullseye
- env:
DEBIAN_RELEASE: bookworm
skip: $CIRRUS_LAST_GREEN_CHANGE != '' && $CIRRUS_CRON != 'regular-rebuild' && !changesInclude('.cirrus.yml', 'scripts/linux_debian*', 'docker/linux_debian_ci')
<<: *gcp_docker_auth_unix
multibuilder_script:
- docker buildx create --name multibuilder
- docker buildx use multibuilder
- docker buildx inspect --bootstrap
# XXX: would be nicer to split into multiple steps, so that e.g. build vs
# upload time are visible
#
# XXX: would be nice to test images before tagging them as available
#
# FIXME: disabled caching for now, there doesn't appear to be a good builtin
# way of regenerating cached layers regularly.
# --cache-from type=registry,ref=$GCP_REPO/$IMAGE \
# --cache-to=type=inline \
#
# Disabled linux/arm64, fails currently due to reasons outside of our control
build_script: |
DATE=$(date --utc +'%Y-%m-%dt%H-%M-%S')
docker buildx build \
--platform linux/amd64 \
--build-arg DATE=$DATE \
--build-arg IMAGE_NAME=$IMAGE \
--build-arg DEBIAN_RELEASE=$DEBIAN_RELEASE \
--tag $GCP_REPO/$IMAGE:latest \
--tag $GCP_REPO/$IMAGE:$DATE \
-f docker/$DOCKER_FILE \
--push \
.
docker buildx imagetools inspect $GCP_REPO/$IMAGE:latest
task:
name: 'Testing Container Image: ${IMAGE_NAME}'
matrix:
- env:
IMAGE_NAME: linux_debian_bullseye_ci
- env:
IMAGE_NAME: linux_debian_bookworm_ci
depends_on:
- dockerbuild-${IMAGE_NAME}
container:
image: $GCP_REPO/${IMAGE_NAME}:latest
test_script:
- uname -a
- xsltproc --version
- env
# Disabled linux/arm64, fails currently due to reasons outside of our control
# task:
# name: 'Testing Arm Container Image: ${IMAGE_NAME}'
# matrix:
# - env:
# IMAGE_NAME: linux_debian_bullseye_ci
# - env:
# IMAGE_NAME: linux_debian_bookworm_ci
# depends_on:
# - ${IMAGE_NAME}
# arm_container:
# image: $GCP_REPO/${IMAGE_NAME}:latest
# test_script:
# - uname -a
# - xsltproc --version
task:
name: 'Testing VM Image: ${PREFIX}-${IMAGE_NAME}'
matrix:
- env:
IMAGE_NAME: netbsd-postgres
PLATFORM: netbsd
- env:
IMAGE_NAME: openbsd-postgres
PLATFORM: openbsd
depends_on:
- vmbuild-${PLATFORM}-postgres
compute_engine_instance:
image_project: $GCP_PROJECT
image: family/${PREFIX}-${IMAGE_NAME}
platform: ${PLATFORM}
test_script:
- uname -a
- env
task:
name: 'Testing VM Image: ${PREFIX}-${IMAGE_NAME}'
env:
IMAGE_NAME: windows-ci
depends_on:
- vmbuild-${IMAGE_NAME}
compute_engine_instance:
image_project: $GCP_PROJECT
image: family/${PREFIX}-${IMAGE_NAME}
platform: windows
test_vs_script:
- ver
- set
- where perl
- perl --version
- python --version
- vcvarsall x64
- bison --version
- flex --version
test_mingw_script:
- C:\msys64\usr\bin\bash.exe -lc 'where perl'
- C:\msys64\usr\bin\bash.exe -lc 'perl --version'
- C:\msys64\usr\bin\bash.exe -lc 'bison --version'
- C:\msys64\usr\bin\bash.exe -lc 'flex --version'