-
Notifications
You must be signed in to change notification settings - Fork 25
/
.gitlab-ci.yml
491 lines (424 loc) · 12.9 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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
#
# Qubes Builder Gitlab CI
#
include:
- file: /common.yml
project: QubesOS/qubes-continuous-integration
stages:
- test
- prep
- build
variables:
DEBUG: "1"
GIT_SUBMODULE_STRATEGY: recursive
CI_RUN_PYTEST_JOBS:
description: "Run all pytest jobs, default: 1"
CI_RUN_COMPONENT_JOBS:
description: "Run components jobs, default: 0"
CI_RUN_TEMPLATE_JOBS:
description: "Run template jobs, default: 0"
CI_RUN_ISO_JOBS:
description: "Run ISO jobs, default: 0"
CI_RUN_INFRA_JOBS:
description: "Run all builderv2-github jobs, default: 0"
CI_RUN_ALL_JOBS:
description: "Run all jobs, default: 0"
builderv2-github:
rules:
- if: $CI_RUN_INFRA_JOBS == "1" || $CI_RUN_ALL_JOBS == "1"
when: always
- when: never
variables:
CI_QUBES_BUILDER_BRANCH: $CI_COMMIT_BRANCH
trigger:
project: QubesOS/qubes-builderv2-github
strategy: depend
#
# job skeletons
#
.pytest:
rules:
- if: $CI_RUN_PYTEST_JOBS != "0" || $CI_RUN_ALL_JOBS == "1"
when: always
- when: never
stage: test
tags:
- vm
artifacts:
paths:
- artifacts/htmlcov/
reports:
junit: artifacts/qubesbuilder.xml
coverage_report:
coverage_format: cobertura
path: artifacts/coverage.xml
coverage: '/TOTAL.*\s(\d+)%/'
variables:
PYTEST_ARGS: -v --color=yes --showlocals --cov qubesbuilder --cov-report term --cov-report html:artifacts/htmlcov --cov-report xml:artifacts/coverage.xml --junitxml=artifacts/qubesbuilder.xml
# https://gitlab.com/gitlab-org/gitlab/-/issues/15603
before_script:
- sudo dnf install -y python3-pip python3-pytest-cov python3-pytest python3-pytest-mock python3-lxml python3-wheel sequoia-sqv
- sudo rm -rf ~/pytest-of-user/
- docker pull registry.gitlab.com/qubesos/docker-images/qubes-builder-fedora:latest
- docker tag registry.gitlab.com/qubesos/docker-images/qubes-builder-fedora:latest qubes-builder-fedora:latest
- mkdir ~/gitlab ~/tmp
- export PYTHONPATH=".:$PYTHONPATH" BASE_ARTIFACTS_DIR=~/gitlab TMPDIR=~/tmp
- env
after_script:
- ci/codecov-wrapper -f artifacts/coverage.xml
.init_cache_job:
rules:
- if: $CI_RUN_CACHE_JOBS == "1" || $CI_RUN_COMPONENT_JOBS == "1" || $CI_RUN_ALL_JOBS == "1"
when: always
- when: never
stage: prep
tags:
- vm
artifacts:
paths:
- artifacts.tar.xz
before_script:
- docker pull registry.gitlab.com/qubesos/docker-images/qubes-builder-fedora:latest
- docker tag registry.gitlab.com/qubesos/docker-images/qubes-builder-fedora:latest qubes-builder-fedora:latest
- sudo dnf install -y python3-debian dpkg-dev openssl tree pacman
script:
- ./qb --builder-conf tests/builder-ci.yml -d "${CI_JOB_NAME#cache-}" package init-cache
- tar cJf artifacts.tar.xz --strip-components=1 artifacts
.component_job:
rules:
- if: $CI_RUN_COMPONENT_JOBS == "1" || $CI_RUN_ALL_JOBS == "1"
when: always
- when: never
.component_docker_job:
extends: .component_job
stage: build
tags:
- vm
artifacts:
paths:
- artifacts
when: always
before_script:
- cp -Tr tests/gnupg ~/.gnupg
- chmod 700 ~/.gnupg
- docker pull registry.gitlab.com/qubesos/docker-images/qubes-builder-fedora:latest
- docker tag registry.gitlab.com/qubesos/docker-images/qubes-builder-fedora:latest qubes-builder-fedora:latest
- tar xf artifacts.tar.xz
- sudo dnf install -y python3-debian dpkg-dev openssl tree pacman
script:
- ./qb --builder-conf tests/builder-ci.yml -d "${CI_JOB_NAME#docker-}" ${QB_EXTRA_ARGS} package all
after_script:
- rm -rf artifacts/cache
- tree artifacts
.component_podman_job:
extends: .component_job
stage: build
tags:
- vm
artifacts:
paths:
- artifacts
when: always
before_script:
- cp -Tr tests/gnupg ~/.gnupg
- chmod 700 ~/.gnupg
- sudo sed -i "/$(id -u -n)/d" /etc/subuid
- sudo sed -i "/$(id -g -n)/d" /etc/subgid
- echo $(id -u -n):$(( $(id -u)*65536 )):65536 | sudo tee -a /etc/subuid
- echo $(id -g -n):$(( $(id -g)*65536 )):65536 | sudo tee -a /etc/subgid
- systemctl --user start podman
- podman pull docker.io/fepitre/qubes-builder-fedora:latest
- podman tag docker.io/fepitre/qubes-builder-fedora:latest qubes-builder-fedora:latest
- tar xf artifacts.tar.xz
- sudo dnf install -y python3-debian dpkg-dev openssl tree pacman
script:
- sed -i 's/docker/podman/' tests/builder-ci.yml
- ./qb --builder-conf tests/builder-ci.yml -d "${CI_JOB_NAME#podman-}" ${QB_EXTRA_ARGS} package all
after_script:
- rm -rf artifacts/cache
- tree artifacts
.component_qubes_job:
extends: .component_job
stage: build
tags:
- qubes
artifacts:
paths:
- artifacts
when: always
before_script:
- cp -Tr tests/gnupg ~/.gnupg
- chmod 700 ~/.gnupg
- tar xf artifacts.tar.xz
- sudo dnf install -y python3-debian dpkg-dev openssl tree pacman
script:
- sed -i 's/docker/qubes/' tests/builder-ci.yml
- "sed -i 's/user: gitlab-runner/user: user/; s/group: gitlab-runner/group: user/' tests/builder-ci.yml"
- ./qb --builder-conf tests/builder-ci.yml -d "${CI_JOB_NAME#qubes-}" --option executor:type=qubes --option executor:options:dispvm=builder-dvm ${QB_EXTRA_ARGS} package all
after_script:
- rm -rf artifacts/cache
- tree artifacts
.component_local_job:
extends: .component_job
stage: build
tags:
- vm
artifacts:
paths:
- artifacts
when: always
before_script:
- cp -Tr tests/gnupg ~/.gnupg
- chmod 700 ~/.gnupg
- tar xf artifacts.tar.xz
- sudo dnf install -y python3-debian dpkg-dev openssl tree pacman
script:
- ./qb --builder-conf tests/builder-ci.yml -d "${CI_JOB_NAME#local-}" --option executor:type=local --option executor:options:directory=/home/gitlab-runner/tmp ${QB_EXTRA_ARGS} package all
after_script:
- rm -rf artifacts/cache
- tree artifacts
.template_qubes_job:
rules:
- if: $CI_RUN_TEMPLATE_JOBS == "1" || $CI_RUN_ALL_JOBS == "1"
when: always
- when: never
stage: build
tags:
- qubes
before_script:
- docker pull registry.gitlab.com/qubesos/docker-images/qubes-builder-fedora:latest
- docker tag registry.gitlab.com/qubesos/docker-images/qubes-builder-fedora:latest qubes-builder-fedora:latest
- cp -Tr tests/gnupg ~/.gnupg
- chmod 700 ~/.gnupg
- sudo dnf install -y python3-debian dpkg-dev openssl tree pacman
script:
- ./qb --builder-conf tests/builder-ci.yml -c builder-rpm -c builder-debian -c template-whonix -c builder-archlinux -c qubes-release package fetch
- ./qb --builder-conf tests/builder-ci.yml -t "${CI_JOB_NAME#qubes-template-}" --option executor:type=qubes --option executor:options:dispvm=builder-dvm template all
.installer_iso:
rules:
- if: $CI_RUN_ISO_JOBS == "1" || $CI_RUN_ALL_JOBS == "1"
when: always
- when: never
stage: build
tags:
- vm
artifacts:
paths:
- artifacts/installer
before_script:
- cp -Tr tests/gnupg ~/.gnupg
- chmod 700 ~/.gnupg
- docker pull registry.gitlab.com/qubesos/docker-images/qubes-builder-fedora:latest
- docker tag registry.gitlab.com/qubesos/docker-images/qubes-builder-fedora:latest qubes-builder-fedora:latest
- sudo dnf install -y python3-debian dpkg-dev openssl tree mktorrent
script:
- ./qb --builder-conf tests/builder-ci.yml -c qubes-release package fetch
- 'sh -c "$EXPECT_FAILURE ./qb --builder-conf tests/builder-ci.yml -o iso:kickstart=$KICKSTART_FILE installer init-cache all"'
after_script:
- rm -rf artifacts/cache
- tree artifacts
#
# test
#
lint:
extends: .lint
stage: test
variables:
DIR: qubesbuilder
mypy:
stage: test
image: fedora:39
tags:
- docker
before_script:
- sudo dnf install -y python3-mypy python3-pip
- sudo python3 -m pip install types-PyYAML types-python-dateutil
script:
- mypy --install-types --non-interactive --junit-xml mypy.xml qubesbuilder
artifacts:
reports:
junit: mypy.xml
shellcheck:
stage: test
image: fedora:39
tags:
- docker
before_script:
- sudo dnf install -y ShellCheck git
script:
- shellcheck -x -e SC1117 $(grep -l '^#!/bin/\(ba\)\?sh' $(git ls-files))
pytest:
extends: .pytest
tags:
- qubes
script:
- pytest-3 $PYTEST_ARGS tests/test_executors.py tests/test_functions.py tests/test_objects.py tests/test_scripts.py tests/test_log.py
pytest-cli-cleanup:
extends: .pytest
script:
- pytest-3 $PYTEST_ARGS tests/test_cli_cleanup.py -k test_cleanup_
pytest-cli-repository:
extends: .pytest
script:
- pytest-3 $PYTEST_ARGS tests/test_cli_repository.py -k test_repository_
pytest-cli-component-host-fc37:
extends: .pytest
script:
- pytest-3 $PYTEST_ARGS tests/test_cli.py -k test_component_host_fc37_
pytest-cli-component-vm-bookworm:
extends: .pytest
script:
- pytest-3 $PYTEST_ARGS tests/test_cli.py -k test_component_vm_bookworm
pytest-cli-component-vm-archlinux:
extends: .pytest
script:
- pytest-3 $PYTEST_ARGS tests/test_cli.py -k test_component_vm_archlinux
pytest-cli-component:
extends: .pytest
script:
- pytest-3 $PYTEST_ARGS tests/test_cli.py -k test_common_
pytest-cli-increment-component:
extends: .pytest
script:
- pytest-3 $PYTEST_ARGS tests/test_cli.py -k test_increment_component_
pytest-cli-template-fedora:
extends: .pytest
script:
- pytest-3 $PYTEST_ARGS tests/test_cli.py -k test_template_fedora
pytest-cli-template-debian:
extends: .pytest
script:
- pytest-3 $PYTEST_ARGS tests/test_cli.py -k test_template_debian
pytest-cli-installer-cache:
extends: .pytest
script:
- pytest-3 $PYTEST_ARGS tests/test_cli.py -k test_installer_init_cache
#
# Components
#
# Cache
cache-host-fc37:
extends: .init_cache_job
script:
- !reference [.init_cache_job, script ]
- tests/scripts/check-chroot-content.sh artifacts "${CI_JOB_NAME#cache-}" /usr/bin/gcc
cache-vm-fc39:
extends: .init_cache_job
cache-vm-fc40:
extends: .init_cache_job
cache-vm-bookworm:
extends: .init_cache_job
script:
- !reference [.init_cache_job, script ]
- tests/scripts/check-chroot-content.sh artifacts "${CI_JOB_NAME#cache-}" /usr/bin/quilt
cache-vm-trixie:
extends: .init_cache_job
cache-vm-archlinux:
extends: .init_cache_job
cache-vm-jammy:
extends: .init_cache_job
# Podman executor
podman-host-fc37:
extends: .component_podman_job
needs:
- cache-host-fc37
podman-vm-fc40:
extends: .component_podman_job
needs:
- cache-vm-fc40
#podman-vm-bookworm:
# extends: .component_podman_job
# Docker executor
docker-host-fc37:
extends: .component_docker_job
needs:
- cache-host-fc37
docker-vm-fc40:
extends: .component_docker_job
needs:
- cache-vm-fc40
docker-vm-bookworm:
extends: .component_docker_job
needs:
- cache-vm-bookworm
docker-vm-archlinux:
extends: .component_docker_job
needs:
- cache-vm-archlinux
docker-vm-jammy:
extends: .component_docker_job
before_script:
- cp -Tr tests/gnupg ~/.gnupg
- chmod 700 ~/.gnupg
- docker build -f dockerfiles/debian.Dockerfile -t qubes-builder-debian:latest dockerfiles/
- tar xf artifacts.tar.xz
- sudo dnf install -y python3-debian dpkg-dev openssl tree pacman
# install an update manually built until https://bugzilla.redhat.com/show_bug.cgi?id=2108872 is handled
- sudo dnf update -y https://caviar.qubes-os.org/~marmarek/reprepro-5.4.2-1.fc37.x86_64.rpm
variables:
QB_EXTRA_ARGS: "-o executor:options:image=qubes-builder-debian:latest -o +components+vmm-xen-guest -c vmm-xen-guest -c core-vchan-xen"
needs:
- cache-vm-jammy
# Qubes executor
qubes-host-fc37:
extends: .component_qubes_job
needs:
- cache-host-fc37
qubes-vm-fc40:
extends: .component_qubes_job
needs:
- cache-vm-fc40
qubes-vm-bookworm:
extends: .component_qubes_job
needs:
- cache-vm-bookworm
# Local executor
local-host-fc37:
extends: .component_local_job
needs:
- cache-host-fc37
local-vm-fc40:
extends: .component_local_job
needs:
- cache-vm-fc40
local-vm-bookworm:
extends: .component_local_job
needs:
- cache-vm-bookworm
#
# Templates
#
qubes-template-fedora-40-xfce:
extends: .template_qubes_job
qubes-template-debian-12:
extends: .template_qubes_job
qubes-template-whonix-gateway-17:
extends: .template_qubes_job
qubes-template-whonix-workstation-17:
extends: .template_qubes_job
allow_failure: true
qubes-template-archlinux:
extends: .template_qubes_job
#
# ISO
#
installer-iso-online-testing:
variables:
KICKSTART_FILE: conf/iso-online-testing.ks
EXPECT_FAILURE: ""
extends: .installer_iso
installer-iso-unsigned:
variables:
KICKSTART_FILE: conf/iso-unsigned.ks
EXPECT_FAILURE: "!"
extends: .installer_iso
installer-iso-unsigned2:
variables:
KICKSTART_FILE: conf/iso-unsigned2.ks
EXPECT_FAILURE: "!"
extends: .installer_iso
installer-iso-unknown-key:
variables:
KICKSTART_FILE: conf/iso-unknown-key.ks
EXPECT_FAILURE: "!"
extends: .installer_iso