Skip to content

Commit fb29cbe

Browse files
committed
ci: add EXCLUDE_BASE_IMAGES variable
Used to exclude specific base images from testing. Also move the logic to extract kernels to be built to a dedicated python helper script; this is getting too complicated for a one-liner jq query.
1 parent c5dc3f4 commit fb29cbe

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

.gitlab-ci.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ variables:
22
RELEASE_BRANCH: master
33
DRBD_VERSION_BASE: 9.2.0
44
DRBD9_TESTS_REF: master
5-
BUILD_HELPERS_VERSION: 2c873ab6e6e6bb6ec83f571eeada63d54ff805b5
5+
BUILD_HELPERS_VERSION: 01525254f2e841c1c67d9a57cad859955340b1e7
66
# we have to change the way GitLab CI clones the repository.
77
# by default, it is shallow, which gives us a wrong commit count when
88
# we do `git rev-list --count origin/master` below.
99
GIT_DEPTH: 0
1010
GIT_STRATEGY: clone
1111
GIT_SUBMODULE_STRATEGY: normal
12+
# comma separated list of base images to exclude when testing
13+
EXCLUDE_BASE_IMAGES: ''
1214

1315
stages:
1416
- check
@@ -24,10 +26,7 @@ stages:
2426
- git clone --branch ${DRBD9_TESTS_REF} https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/drbd/drbd9-tests.git
2527
- |
2628
kernels_from_vms() {
27-
rq -t < drbd9-tests/virter/vms.toml | \
28-
jq -r '.vms[].metadata
29-
| select(has("BuildDistribution"))
30-
| .BuildDistribution + " " + .BuildKernel'
29+
python3 .gitlab/kernels-from-vms.py < drbd9-tests/virter/vms.toml
3130
}
3231
3332
# parameters: [version]
@@ -229,7 +228,7 @@ build:all:
229228
export DRBD_VERSION=$DRBD_VERSION
230229
export DRBD_UTILS_VERSION=9.0.0.latest-*
231230
cd drbd9-tests
232-
./virter/run-test.sh --out-dir=../tests-out "$@"
231+
./virter/run-test.sh --out-dir=../tests-out "$@" --exclude-base-image "$EXCLUDE_BASE_IMAGES"
233232
}
234233
dependencies:
235234
- build:for-tests

.gitlab/kernels-from-vms.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import sys
5+
6+
import toml
7+
8+
# kernels-from-vms.py
9+
# Extract kernel versions to be built from a vmshed vms.toml file supplied on stdin
10+
# Respects the EXCLUDE_BASE_IMAGES environment variable to exclude specific base images
11+
12+
exclude_base_images = os.getenv("EXCLUDE_BASE_IMAGES", "").split(",")
13+
14+
vms = toml.load(sys.stdin)
15+
for vm in vms["vms"]:
16+
meta = vm["metadata"]
17+
if vm["base_image"] in exclude_base_images or "BuildDistribution" not in meta:
18+
continue
19+
print(f"{meta['BuildDistribution']} {meta['BuildKernel']}")

0 commit comments

Comments
 (0)