Skip to content

Commit 6a1fcc0

Browse files
committed
ci: Unify more of hack/ and tests/, move tmt to subdir
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: - Move tmt/ 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 f4dfd81 commit 6a1fcc0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+141
-159
lines changed

.github/workflows/integration.yml

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
name: bootc integration test
22
on:
33
pull_request:
4-
branches: [main]
4+
branches: [main]
5+
workflow_dispatch:
56

67
jobs:
78
build:
89
strategy:
910
matrix:
10-
test_os: [fedora-41, fedora-42, fedora-43, centos-9]
11-
test_runner: [ubuntu-latest, ubuntu-24.04-arm]
11+
#test_os: [fedora-42, fedora-43, centos-9, centos-10]
12+
test_os: [centos-10]
13+
test_runner: [ubuntu-24.04, ubuntu-24.04-arm]
1214

1315
runs-on: ${{ matrix.test_runner }}
1416

@@ -18,67 +20,56 @@ jobs:
1820
set -eux
1921
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
2022
sudo apt update
21-
sudo apt install -y crun/testing podman/testing
23+
sudo apt install -y crun/testing podman/testing just
2224
2325
- uses: actions/checkout@v4
2426

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
27+
- name: Set architecture variable
28+
id: set_arch
29+
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
2930

30-
- name: Grant sudo user permission to archive files
31+
- name: Build bootc and bootc image
3132
run: |
32-
sudo chmod 0755 /tmp/tmp-bootc-build/id_rsa
33+
sudo tests/build.sh ${{ matrix.test_os }}
3334
3435
- 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-
42-
- name: Archive SSH private key - id_rsa
43-
if: matrix.test_runner == 'ubuntu-latest'
4436
uses: actions/upload-artifact@v4
4537
with:
46-
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-id_rsa
47-
path: /tmp/tmp-bootc-build/id_rsa
38+
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-disk
39+
path: target/disk.raw
4840
retention-days: 1
4941

5042
test:
5143
needs: build
5244
strategy:
5345
matrix:
54-
test_os: [fedora-41, fedora-42, fedora-43, centos-9]
46+
#test_os: [fedora-42, fedora-43, centos-9, centos-10]
47+
test_os: [centos-10]
5548
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]
5649

5750
runs-on: ubuntu-latest
5851

5952
steps:
6053
- uses: actions/checkout@v4
6154

62-
- name: Install dependence
55+
- name: Set architecture variable
56+
id: set_arch
57+
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
58+
59+
- name: Install deps
6360
run: |
6461
sudo apt-get update
65-
sudo apt install -y qemu-kvm qemu-system
62+
sudo apt install -y qemu-kvm qemu-system just
6663
pip install --user tmt
6764
6865
- name: Create folder to save disk image
69-
run: mkdir -p /tmp/tmp-bootc-build
66+
run: mkdir -p target
7067

7168
- name: Download disk.raw
7269
uses: actions/download-artifact@v4
7370
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
71+
name: PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-disk
72+
path: target
8273

8374
- name: Enable KVM group perms
8475
run: |
@@ -88,13 +79,13 @@ jobs:
8879
ls -l /dev/kvm
8980
9081
- 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
82+
run: |
83+
ls -al target
84+
tests/test.sh ${{ matrix.tmt_plan }}
9485
9586
- name: Archive TMT logs
9687
if: always()
9788
uses: actions/upload-artifact@v4
9889
with:
99-
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ matrix.tmt_plan }}
90+
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ env.ARCH }}-${{ matrix.tmt_plan }}
10091
path: /var/tmp/tmt

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/packages.txt

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

hack/provision-derived.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ case "${ID}-${VERSION_ID}" in
1616
dnf config-manager --set-enabled crb
1717
dnf -y install epel-release epel-next-release
1818
dnf -y install nu
19-
dnf clean all
2019
;;
2120
"rhel-9."*)
2221
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
2322
dnf -y install nu
24-
dnf clean all
2523
;;
2624
"centos-10"|"rhel-10."*)
2725
# nu is not available in CS10
@@ -32,10 +30,13 @@ case "${ID}-${VERSION_ID}" in
3230
;;
3331
"fedora-"*)
3432
dnf -y install nu
35-
dnf clean all
3633
;;
3734
esac
3835

36+
# Extra packages we install
37+
grep -Ev -e '^#' packages.txt | xargs dnf -y install
38+
dnf clean all
39+
3940
# Stock extra cleaning of logs and caches in general (mostly dnf)
4041
rm /var/log/* /var/cache /var/lib/{dnf,rpm-state,rhsm} -rf
4142
# And clean root's homedir
File renamed without changes.

tests/build.sh

Lines changed: 33 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -4,116 +4,59 @@ set -exuo pipefail
44
# This script basically builds bootc from source using the provided base image,
55
# then runs the target tests.
66

7-
mkdir -p /tmp/tmp-bootc-build
8-
BOOTC_TEMPDIR="/tmp/tmp-bootc-build"
9-
10-
# Get OS info from TEST_OS env
11-
OS_ID=$(echo "$TEST_OS" | cut -d '-' -f 1)
12-
OS_VERSION_ID=$(echo "$TEST_OS" | cut -d '-' -f 2)
13-
14-
# Base image
15-
case "$OS_ID" in
16-
"centos")
17-
TIER1_IMAGE_URL="quay.io/centos-bootc/centos-bootc:stream${OS_VERSION_ID}"
7+
# If provided should be of the form fedora-42 or centos-10
8+
target=${1:-}
9+
10+
build_args=()
11+
if test -n "${target:-}"; then
12+
shift
13+
# Get OS info from TEST_OS env
14+
OS_ID=$(echo "$target" | cut -d '-' -f 1)
15+
OS_VERSION_ID=$(echo "$target" | cut -d '-' -f 2)
16+
17+
# Base image
18+
case "$OS_ID" in
19+
"centos")
20+
BASE="quay.io/centos-bootc/centos-bootc:stream${OS_VERSION_ID}"
1821
;;
19-
"fedora")
20-
TIER1_IMAGE_URL="quay.io/fedora/fedora-bootc:${OS_VERSION_ID}"
22+
"fedora")
23+
BASE="quay.io/fedora/fedora-bootc:${OS_VERSION_ID}"
2124
;;
22-
esac
23-
24-
CONTAINERFILE="${BOOTC_TEMPDIR}/Containerfile"
25-
tee "$CONTAINERFILE" > /dev/null << CONTAINERFILEOF
26-
FROM $TIER1_IMAGE_URL as build
27-
28-
WORKDIR /code
29-
30-
RUN <<EORUN
31-
set -xeuo pipefail
32-
. /usr/lib/os-release
33-
case \$ID in
34-
centos|rhel) dnf config-manager --set-enabled crb;;
35-
fedora) dnf -y install dnf-utils 'dnf5-command(builddep)';;
36-
esac
37-
dnf -y distro-sync ostree{,-libs} systemd
38-
dnf -y builddep contrib/packaging/bootc.spec
39-
dnf -y install git-core
40-
EORUN
41-
42-
RUN mkdir -p /build/target/dev-rootfs
43-
# git config --global --add safe.directory /code to fix "fatal: detected dubious ownership in repository at '/code'" error
44-
RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome git config --global --add safe.directory /code && make test-bin-archive && mkdir -p /out && cp target/bootc.tar.zst /out
45-
46-
FROM $TIER1_IMAGE_URL
47-
48-
# Inject our built code
49-
COPY --from=build /out/bootc.tar.zst /tmp
50-
RUN tar -C / --zstd -xvf /tmp/bootc.tar.zst && rm -vrf /tmp/*
51-
52-
RUN <<EORUN
53-
set -xeuo pipefail
54-
55-
# Provision test requirement
56-
/code/hack/provision-derived.sh
57-
# Also copy in some default install configs we use for testing
58-
cp -a /code/hack/install-test-configs/* /usr/lib/bootc/install/
59-
# And some test kargs
60-
cp -a /code/hack/test-kargs/* /usr/lib/bootc/kargs.d/
61-
62-
# For testing farm
63-
mkdir -p -m 0700 /var/roothome
64-
65-
# Enable ttyS0 console
66-
mkdir -p /usr/lib/bootc/kargs.d/
67-
cat <<KARGEOF >> /usr/lib/bootc/kargs.d/20-console.toml
68-
kargs = ["console=ttyS0,115200n8"]
69-
KARGEOF
70-
71-
# For test-22-logically-bound-install
72-
cp -a /code/tmt/tests/lbi/usr/. /usr
73-
ln -s /usr/share/containers/systemd/curl.container /usr/lib/bootc/bound-images.d/curl.container
74-
ln -s /usr/share/containers/systemd/curl-base.image /usr/lib/bootc/bound-images.d/curl-base.image
75-
ln -s /usr/share/containers/systemd/podman.image /usr/lib/bootc/bound-images.d/podman.image
76-
77-
# Install rsync which is required by tmt
78-
dnf -y install cloud-init rsync
79-
dnf -y clean all
80-
81-
rm -rf /var/cache /var/lib/dnf
82-
EORUN
83-
CONTAINERFILEOF
25+
*) echo "Unknown OS: ${OS_ID}" 1>&2; exit 1
26+
;;
27+
esac
28+
build_args+=("--build-arg=base=$BASE")
29+
fi
8430

85-
LOCAL_IMAGE="localhost/bootc:test"
86-
podman build \
87-
--retry 5 \
88-
--retry-delay 5s \
89-
-v "$(pwd)":/code:z \
90-
-t "$LOCAL_IMAGE" \
91-
-f "$CONTAINERFILE" \
92-
"$BOOTC_TEMPDIR"
31+
just build ${build_args[@]}
32+
just build-integration-test-image
9333

94-
SSH_KEY=${BOOTC_TEMPDIR}/id_rsa
95-
ssh-keygen -f "${SSH_KEY}" -N "" -q -t rsa-sha2-256 -b 2048
34+
# Host builds will have this already, but we use it as a general dumping space
35+
# for output artifacts
36+
mkdir -p target
9637

97-
truncate -s 10G "${BOOTC_TEMPDIR}/disk.raw"
38+
rm -vf target/disk.raw
39+
truncate -s 10G "target/disk.raw"
9840

9941
# For test-22-logically-bound-install
10042
podman pull --retry 5 --retry-delay 5s quay.io/curl/curl:latest
10143
podman pull --retry 5 --retry-delay 5s quay.io/curl/curl-base:latest
10244
podman pull --retry 5 --retry-delay 5s registry.access.redhat.com/ubi9/podman:latest
10345

46+
mkdir -p target/disks
47+
10448
podman run \
10549
--rm \
10650
--privileged \
10751
--pid=host \
10852
--security-opt label=type:unconfined_t \
10953
-v /var/lib/containers:/var/lib/containers \
11054
-v /dev:/dev \
111-
-v "$BOOTC_TEMPDIR":/output \
112-
"$LOCAL_IMAGE" \
55+
-v $(pwd)/target:/target \
56+
localhost/bootc-integration \
11357
bootc install to-disk \
11458
--filesystem "xfs" \
115-
--root-ssh-authorized-keys "/output/id_rsa.pub" \
11659
--karg=console=ttyS0,115200n8 \
11760
--generic-image \
11861
--via-loopback \
119-
/output/disk.raw
62+
/target/disk.raw

0 commit comments

Comments
 (0)