Skip to content

Commit a78b96d

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 <[email protected]>
1 parent 19e82be commit a78b96d

File tree

18 files changed

+217
-514
lines changed

18 files changed

+217
-514
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
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,6 +107,7 @@ 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?
110+
sudo just build
108111
sudo just build-integration-test-image
109112
sudo podman build -t localhost/bootc-fsverity -f ci/Containerfile.install-fsverity
110113

.github/workflows/integration.yml

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,85 @@
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]
20+
test_os: [centos-10]
21+
test_runner: [ubuntu-24.04]
1222

1323
runs-on: ${{ matrix.test_runner }}
1424

1525
steps:
16-
- name: Install podman for heredoc support
26+
- name: Install dependencies
1727
run: |
1828
set -eux
1929
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
2030
sudo apt update
21-
sudo apt install -y crun/testing podman/testing
31+
sudo apt install -y crun/testing podman/testing just qemu-utils
2232
2333
- uses: actions/checkout@v4
2434

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
35+
- name: Set architecture variable
36+
id: set_arch
37+
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
2938

30-
- name: Grant sudo user permission to archive files
39+
- name: Build container and disk image
3140
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
41+
sudo tests/build.sh ${{ matrix.test_os }}
4142
42-
- name: Archive SSH private key - id_rsa
43-
if: matrix.test_runner == 'ubuntu-latest'
43+
- name: Archive disk image
4444
uses: actions/upload-artifact@v4
4545
with:
46-
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-id_rsa
47-
path: /tmp/tmp-bootc-build/id_rsa
46+
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-disk
47+
path: target/bootc-integration-test.qcow2
4848
retention-days: 1
4949

5050
test:
5151
needs: build
5252
strategy:
53+
fail-fast: false
5354
matrix:
54-
test_os: [fedora-41, fedora-42, fedora-43, centos-9]
55+
#test_os: [fedora-42, fedora-43, centos-9, centos-10]
56+
test_os: [centos-10]
5557
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]
5658

5759
runs-on: ubuntu-latest
5860

5961
steps:
6062
- uses: actions/checkout@v4
6163

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

7178
- name: Download disk.raw
7279
uses: actions/download-artifact@v4
7380
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
81+
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-disk
82+
path: target
8283

8384
- name: Enable KVM group perms
8485
run: |
@@ -87,14 +88,17 @@ jobs:
8788
sudo udevadm trigger --name-match=kvm
8889
ls -l /dev/kvm
8990
91+
- name: Workaround https://github.com/teemtee/testcloud/issues/18
92+
run: sudo rm -f /usr/bin/chcon && sudo ln -sr /usr/bin/true /usr/bin/chcon
93+
9094
- 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
95+
run: |
96+
ls -al target
97+
tests/run-tmt.sh plan --name "/tmt/plans/integration/"${{ matrix.tmt_plan }}
9498
9599
- name: Archive TMT logs
96100
if: always()
97101
uses: actions/upload-artifact@v4
98102
with:
99-
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ matrix.tmt_plan }}
103+
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-${{ matrix.tmt_plan }}
100104
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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ 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
810

911
# Run container integration tests
1012
run-container-integration: build-integration-test-image

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
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
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Container]
2+
Image=quay.io/curl/curl:latest
3+
GlobalArgs=--storage-opt=additionalimagestore=/usr/lib/bootc/storage
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This is not symlinked to bound-images.d so it should not be pulled.
2+
# It's here to represent an app image that exists
3+
# in a bootc image but is not logically bound.
4+
[Image]
5+
Image=registry.redhat.io/jboss-webserver-5/jws5-rhel8-operator:latest
6+
AuthFile=/root/auth.json
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Image]
2+
Image=registry.access.redhat.com/ubi9/podman:latest

hack/packages.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Needed by tmt
2+
rsync
3+
cloud-init
4+
/usr/bin/flock
5+
/usr/bin/awk

0 commit comments

Comments
 (0)