Skip to content

Commit d81c395

Browse files
committed
ci: Unify more of hack/ and tests/
A key thing for me is that the `Justfile` should be a one-stop shop for development of the project. It can't have everything but it should answer the basic questions of "how do I build and test this project". This aligns the recently added tmt-on-GHA flow a *bit* more closely with some of that. Biggest is to use the `just build-integration-test-image` as the canonical way to build a container image with our testing stuff in it; which uses our main Dockerfile Other cleanups: - Change test script to move into tests/tmt/ as a workaround for teemtee/tmt#3037 (comment) - Change the qemu logic to use SMBIOS credentials so we don't have to carry around both a disk image and a SSH key - Change qemu to use `-snapshot` so we can reuse disks - Change the scripts to accept data via argv[1] and not environment - Drop the hardcoded testing directory and use `target/` as a generic build artifact dir Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 19e82be commit d81c395

23 files changed

+239
-615
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ jobs:
5656
run: sudo apt update && sudo apt install just
5757
- uses: actions/checkout@v4
5858
- name: Build and run container integration tests
59-
run: sudo just run-container-integration run-container-external-tests
59+
run: |
60+
sudo just build
61+
sudo just run-container-integration run-container-external-tests
6062
container-continuous:
6163
if: ${{ !contains(github.event.pull_request.labels.*.name, 'control/skip-ci') }}
6264
runs-on: ubuntu-24.04
@@ -105,7 +107,8 @@ jobs:
105107
set -xeu
106108
# Build images to test; TODO investigate doing single container builds
107109
# via GHA and pushing to a temporary registry to share among workflows?
108-
sudo just build-integration-test-image
110+
sudo just build
111+
sudo just build-install-test-image
109112
sudo podman build -t localhost/bootc-fsverity -f ci/Containerfile.install-fsverity
110113
111114
# TODO move into a container, and then have this tool run other containers
@@ -120,9 +123,9 @@ jobs:
120123
sudo podman run --privileged --pid=host -v /:/run/host -v $(pwd):/src:ro -v /var/tmp:/var/tmp \
121124
-v /run/dbus:/run/dbus -v /run/systemd:/run/systemd localhost/bootc /src/crates/ostree-ext/ci/priv-integration.sh
122125
# Nondestructive but privileged tests
123-
sudo bootc-integration-tests host-privileged localhost/bootc-integration
126+
sudo bootc-integration-tests host-privileged localhost/bootc-integration-install
124127
# Install tests
125-
sudo bootc-integration-tests install-alongside localhost/bootc-integration
128+
sudo bootc-integration-tests install-alongside localhost/bootc-integration-install
126129
127130
# system-reinstall-bootc tests
128131
cargo build --release -p system-reinstall-bootc

.github/workflows/integration.yml

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,81 @@
1-
name: bootc integration test
1+
# This workflow builds a container across a matrix of OSes,
2+
# generates a disk image from that, and runs integration tests
3+
# using tmt + libvirt (using nested virt support in the default GHA runners).
4+
name: Build+TMT
25
on:
36
pull_request:
4-
branches: [main]
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
513

614
jobs:
715
build:
816
strategy:
17+
fail-fast: false
918
matrix:
10-
test_os: [fedora-41, fedora-42, fedora-43, centos-9]
11-
test_runner: [ubuntu-latest, ubuntu-24.04-arm]
19+
test_os: [fedora-42, fedora-43, centos-9, centos-10]
1220

13-
runs-on: ${{ matrix.test_runner }}
21+
runs-on: ubuntu-24.04
1422

1523
steps:
16-
- name: Install podman for heredoc support
24+
- name: Install dependencies
1725
run: |
1826
set -eux
1927
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
2028
sudo apt update
21-
sudo apt install -y crun/testing podman/testing
29+
sudo apt install -y crun/testing podman/testing just qemu-utils
2230
2331
- uses: actions/checkout@v4
2432

25-
- name: Build bootc and bootc image
26-
env:
27-
TEST_OS: ${{ matrix.test_os }}
28-
run: sudo -E TEST_OS=$TEST_OS tests/build.sh
33+
- name: Set architecture variable
34+
id: set_arch
35+
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
2936

30-
- name: Grant sudo user permission to archive files
37+
- name: Build container and disk image
3138
run: |
32-
sudo chmod 0755 /tmp/tmp-bootc-build/id_rsa
33-
34-
- name: Archive bootc disk image - disk.raw
35-
if: matrix.test_runner == 'ubuntu-latest'
36-
uses: actions/upload-artifact@v4
37-
with:
38-
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-disk
39-
path: /tmp/tmp-bootc-build/disk.raw
40-
retention-days: 1
39+
sudo tests/build.sh ${{ matrix.test_os }}
4140
42-
- name: Archive SSH private key - id_rsa
43-
if: matrix.test_runner == 'ubuntu-latest'
41+
- name: Archive disk image
4442
uses: actions/upload-artifact@v4
4543
with:
46-
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-id_rsa
47-
path: /tmp/tmp-bootc-build/id_rsa
44+
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-disk
45+
path: target/bootc-integration-test.qcow2
4846
retention-days: 1
4947

5048
test:
5149
needs: build
5250
strategy:
51+
fail-fast: false
5352
matrix:
54-
test_os: [fedora-41, fedora-42, fedora-43, centos-9]
55-
tmt_plan: [test-01-readonly, test-20-local-upgrade, test-21-logically-bound-switch, test-22-logically-bound-install, test-23-install-outside-container, test-24-local-upgrade-reboot]
53+
test_os: [fedora-42, fedora-43, centos-9, centos-10]
5654

5755
runs-on: ubuntu-latest
5856

5957
steps:
6058
- uses: actions/checkout@v4
6159

62-
- name: Install dependence
60+
- name: Set architecture variable
61+
id: set_arch
62+
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
63+
64+
- name: Install deps
6365
run: |
6466
sudo apt-get update
65-
sudo apt install -y qemu-kvm qemu-system
66-
pip install --user tmt
67+
# see https://tmt.readthedocs.io/en/stable/overview.html#install
68+
sudo apt install -y libkrb5-dev pkg-config libvirt-dev genisoimage qemu-kvm qemu-utils libvirt-daemon-system
69+
pip install --user "tmt[provision-virtual]"
6770
6871
- name: Create folder to save disk image
69-
run: mkdir -p /tmp/tmp-bootc-build
72+
run: mkdir -p target
7073

7174
- name: Download disk.raw
7275
uses: actions/download-artifact@v4
7376
with:
74-
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-disk
75-
path: /tmp/tmp-bootc-build
76-
77-
- name: Download id_rsa
78-
uses: actions/download-artifact@v4
79-
with:
80-
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-id_rsa
81-
path: /tmp/tmp-bootc-build
77+
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-disk
78+
path: target
8279

8380
- name: Enable KVM group perms
8481
run: |
@@ -87,14 +84,16 @@ jobs:
8784
sudo udevadm trigger --name-match=kvm
8885
ls -l /dev/kvm
8986
87+
- name: Workaround https://github.com/teemtee/testcloud/issues/18
88+
run: sudo rm -f /usr/bin/chcon && sudo ln -sr /usr/bin/true /usr/bin/chcon
89+
9090
- name: Run test
91-
env:
92-
TMT_PLAN_NAME: ${{ matrix.tmt_plan }}
93-
run: chmod 600 /tmp/tmp-bootc-build/id_rsa && tests/test.sh
91+
run: |
92+
tests/run-tmt.sh
9493
9594
- name: Archive TMT logs
9695
if: always()
9796
uses: actions/upload-artifact@v4
9897
with:
99-
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ matrix.tmt_plan }}
98+
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-${{ matrix.tmt_plan }}
10099
path: /var/tmp/tmt

.packit.yaml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,26 @@ jobs:
5959
owner: rhcontainerbot
6060
project: bootc
6161
enable_net: true
62+
# TODO
6263
notifications:
6364
failure_comment:
6465
message: "bootc Copr build failed for {commit_sha}. @admin check logs {logs_url} and packit dashboard {packit_dashboard_url}"
6566

66-
- job: tests
67-
trigger: pull_request
68-
targets:
69-
- centos-stream-9-x86_64
70-
- centos-stream-9-aarch64
71-
- centos-stream-10-x86_64
72-
- centos-stream-10-aarch64
73-
- fedora-42-x86_64
74-
- fedora-42-aarch64
75-
- fedora-rawhide-x86_64
76-
- fedora-rawhide-aarch64
77-
tmt_plan: /integration
78-
skip_build: true
79-
identifier: integration-test
67+
# TODO: Readd some tmt tests that install the built RPM and e.g. test out system-reinstall-bootc
68+
# - job: tests
69+
# trigger: pull_request
70+
# targets:
71+
# - centos-stream-9-x86_64
72+
# - centos-stream-9-aarch64
73+
# - centos-stream-10-x86_64
74+
# - centos-stream-10-aarch64
75+
# - fedora-42-x86_64
76+
# - fedora-42-aarch64
77+
# - fedora-rawhide-x86_64
78+
# - fedora-rawhide-aarch64
79+
# tmt_plan: /integration
80+
# skip_build: true
81+
# identifier: integration-test
8082

8183
- job: propose_downstream
8284
trigger: release

Justfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ build *ARGS:
33
podman build --jobs=4 -t localhost/bootc {{ARGS}} .
44

55
# This container image has additional testing content and utilities
6-
build-integration-test-image *ARGS: build
6+
build-integration-test-image *ARGS:
77
podman build --jobs=4 -t localhost/bootc-integration -f hack/Containerfile {{ARGS}} .
8+
# Keep these in sync with what's used in hack/lbi
9+
podman pull -q --retry 5 --retry-delay 5s quay.io/curl/curl:latest quay.io/curl/curl-base:latest registry.access.redhat.com/ubi9/podman:latest
10+
11+
# Only used by ci.yml right now
12+
build-install-test-image: build-integration-test-image
13+
cd hack && podman build -t localhost/bootc-integration-install -f Containerfile.drop-lbis
814

915
# Run container integration tests
1016
run-container-integration: build-integration-test-image

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ bin-archive: all
9696
test-bin-archive: all
9797
$(MAKE) install-all DESTDIR=tmp-install && $(TAR_REPRODUCIBLE) --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf
9898

99-
test-tmt:
100-
cargo xtask test-tmt
101-
10299
test:
103100
tests/build.sh && tests/test.sh
104101

crates/tests-integration/src/install.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ pub(crate) fn delete_ostree(sh: &Shell) -> Result<(), anyhow::Error> {
2626
if !Path::new("/ostree/").exists() {
2727
return Ok(());
2828
}
29+
// TODO: This shouldn't be leaking out of installs
30+
cmd!(sh, "sudo umount -Rl /ostree/bootc/storage/overlay")
31+
.ignore_status()
32+
.run()?;
2933
cmd!(sh, "sudo /bin/sh -c 'rm -rf /ostree/'").run()?;
3034
Ok(())
3135
}

crates/xtask/src/xtask.rs

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ use xshell::{cmd, Shell};
1313
mod man;
1414

1515
const NAME: &str = "bootc";
16-
const TEST_IMAGES: &[&str] = &[
17-
"quay.io/curl/curl-base:latest",
18-
"quay.io/curl/curl:latest",
19-
"registry.access.redhat.com/ubi9/podman:latest",
20-
];
2116
const TAR_REPRODUCIBLE_OPTS: &[&str] = &[
2217
"--sort=name",
2318
"--owner=0",
@@ -43,7 +38,6 @@ const TASKS: &[(&str, fn(&Shell) -> Result<()>)] = &[
4338
("package", package),
4439
("package-srpm", package_srpm),
4540
("spec", spec),
46-
("test-tmt", test_tmt),
4741
];
4842

4943
fn try_main() -> Result<()> {
@@ -100,78 +94,6 @@ fn gitrev(sh: &Shell) -> Result<String> {
10094
}
10195
}
10296

103-
#[context("test-integration")]
104-
fn all_plan_files(sh: &Shell) -> Result<Vec<(u32, String)>> {
105-
// We need to split most of our tests into separate plans because tmt doesn't
106-
// support automatic isolation. (xref)
107-
let mut all_plan_files =
108-
sh.read_dir("plans")?
109-
.into_iter()
110-
.try_fold(Vec::new(), |mut acc, ent| -> Result<_> {
111-
let path = Utf8PathBuf::try_from(ent)?;
112-
let Some(ext) = path.extension() else {
113-
return Ok(acc);
114-
};
115-
if ext != "fmf" {
116-
return Ok(acc);
117-
}
118-
let stem = path.file_stem().expect("file stem");
119-
let Some((prefix, suffix)) = stem.split_once('-') else {
120-
return Ok(acc);
121-
};
122-
if prefix != "test" {
123-
return Ok(acc);
124-
}
125-
let Some((priority, _)) = suffix.split_once('-') else {
126-
anyhow::bail!("Invalid test {path}");
127-
};
128-
let priority: u32 = priority
129-
.parse()
130-
.with_context(|| format!("Parsing {path}"))?;
131-
acc.push((priority, stem.to_string()));
132-
Ok(acc)
133-
})?;
134-
all_plan_files.sort_by_key(|v| v.0);
135-
println!("Discovered plans: {all_plan_files:?}");
136-
Ok(all_plan_files)
137-
}
138-
139-
#[context("test-integration")]
140-
fn test_tmt(sh: &Shell) -> Result<()> {
141-
let mut tests = all_plan_files(sh)?;
142-
if let Ok(name) = std::env::var("TMT_TEST") {
143-
tests.retain(|x| x.1.as_str() == name);
144-
if tests.is_empty() {
145-
anyhow::bail!("Failed to match test: {name}");
146-
}
147-
}
148-
149-
// pull some small images that are used for LBI installation tests
150-
cmd!(sh, "podman pull {TEST_IMAGES...}").run()?;
151-
152-
for (_prio, name) in tests {
153-
// cc https://pagure.io/testcloud/pull-request/174
154-
cmd!(sh, "rm -vf /var/tmp/tmt/testcloud/images/disk.qcow2").run()?;
155-
let verbose_enabled = std::env::var("TMT_VERBOSE")
156-
.ok()
157-
.and_then(|s| s.parse::<u32>().ok())
158-
.unwrap_or(0);
159-
160-
let verbose = if verbose_enabled == 1 {
161-
Some("-vvvvv".to_string())
162-
} else {
163-
None
164-
};
165-
166-
if let Err(e) = cmd!(sh, "tmt {verbose...} run plans -n {name}").run() {
167-
// tmt annoyingly does not output errors by default
168-
let _ = cmd!(sh, "tmt run -l report -vvv").run();
169-
return Err(e.into());
170-
}
171-
}
172-
Ok(())
173-
}
174-
17597
/// Return a string formatted version of the git commit timestamp, up to the minute
17698
/// but not second because, well, we're not going to build more than once a second.
17799
#[context("Finding git timestamp")]

hack/Containerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# This injects some extra testing stuff into our image
1+
# Build a container image that has extra testing stuff in it, such
2+
# as nushell, some preset logically bound images, etc. This expects
3+
# to create an image derived FROM localhost/bootc which was created
4+
# by the Dockerfile at top.
25

36
FROM scratch as context
47
# We only need this stuff in the initial context
@@ -11,7 +14,15 @@ ARG variant=
1114
# And this layer has additional stuff for testing, such as nushell etc.
1215
RUN --mount=type=bind,from=context,target=/run/context <<EORUN
1316
set -xeuo pipefail
14-
/run/context/hack/provision-derived.sh "$variant"
17+
cd /run/context/hack
18+
./provision-derived.sh "$variant"
19+
20+
# For test-22-logically-bound-install
21+
cp -a lbi/usr/. /usr
22+
for x in curl.container curl-base.image podman.image; do
23+
ln -s /usr/share/containers/systemd/$x /usr/lib/bootc/bound-images.d/$x
24+
done
25+
1526
# Add some testing kargs into our dev builds
1627
install -D -t /usr/lib/bootc/kargs.d /run/context/hack/test-kargs/*
1728
# Also copy in some default install configs we use for testing

hack/Containerfile.drop-lbis

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM localhost/bootc-integration
2+
# Workaround for https://github.com/bootc-dev/bootc/issues/1618
3+
RUN rm -rf /usr/lib/bootc/bound-images.d/*
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Image]
2+
Image=quay.io/curl/curl-base:latest

0 commit comments

Comments
 (0)