Skip to content

Commit 27b1cd7

Browse files
committed
ci: Add C10S containerized ephemeral test workflow
Add a complete end-to-end test workflow for running ephemeral integration tests in a CentOS Stream 10 container environment. This tests two things very different from the default main.yml workflow: - Running in a nested container environment - bcvk on RHEL-based systems where qemu is at /usr/libexec/qemu-kvm The implementation provides both GitHub Actions CI and local testing: **CI Workflow (.github/workflows/main-c10s.yml):** - Simplified single-job workflow that builds and runs the test container - Uses the ubuntu-24.04 runner with privileged podman - All 13 ephemeral integration tests run in the container **Local Testing (just test-ephemeral-c10s):** - Builds the test container from tests/fixtures/Containerfile - Runs with KVM device access and container storage volume - Provides quick iteration for C10S-specific testing **Container Structure (tests/fixtures/Containerfile):** - Multi-stage build: compile bcvk and create nextest archive in build stage - Runtime stage: C10S base with qemu/libvirt/podman dependencies - Includes full workspace structure for nextest archive execution - Pulls test images and runs ephemeral tests by default **Supporting Files:** - .dockerignore: Includes .config/ for nextest configuration - Justfile: Adds build-image-c10s and test-ephemeral-c10s targets Successfully tested locally with all 13 ephemeral tests passing. Assisted-by: Claude Code (Sonnet 4.5) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent ae915e8 commit 27b1cd7

File tree

4 files changed

+127
-0
lines changed

4 files changed

+127
-0
lines changed

.dockerignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Exclude everything by default, then include just what we need
2+
# Especially note this means that .git is not included, and not tests/
3+
# to avoid spurious rebuilds.
4+
*
5+
6+
# Toplevel build bits
7+
!Makefile
8+
!Cargo.*
9+
# Docs
10+
!docs
11+
# We use the spec file
12+
!packaging/
13+
# Workaround for podman bug with secrets + remote
14+
# https://github.com/containers/podman/issues/25314
15+
!podman-build-secret*
16+
# Nextest configuration
17+
!.config/
18+
# And finally of course all the Rust sources
19+
!crates/

.github/workflows/main-c10s.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI (c10s)
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test-ephemeral:
12+
runs-on: ubuntu-24.04
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Build C10S test container
18+
run: podman build -f tests/fixtures/Containerfile -t localhost/bcvk:c10s .
19+
20+
- name: Run ephemeral integration tests
21+
run: |
22+
podman run --rm --privileged --device=/dev/kvm \
23+
-v bcvk-test-storage:/var/lib/containers \
24+
localhost/bcvk:c10s

Justfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,10 @@ archive: build
9696
install: build
9797
cp target/release/bck ~/.local/bin/
9898

99+
build-image-c10s:
100+
podman build -f tests/fixtures/Containerfile -t localhost/bcvk:c10s .
101+
102+
test-ephemeral-c10s: build-image-c10s
103+
# TODO try downgrading to --cap-add=all --security-opt=label=type:container_runtime_t, I think
104+
# we'll need to assume `--net=host` mainly in bcvk in this situation.
105+
podman run --rm --privileged --device=/dev/kvm -v bcvk-test-storage:/var/lib/containers localhost/bcvk:c10s

tests/fixtures/Containerfile

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Container for running bcvk ephemeral tests on C10S
2+
# This mirrors the CI workflow in .github/workflows/main-c10s.yml
3+
4+
ARG base=quay.io/centos/centos:stream10
5+
FROM $base as build
6+
7+
# Install build dependencies
8+
RUN dnf clean all && \
9+
dnf -y install dnf-utils && \
10+
dnf config-manager --set-enabled crb && \
11+
dnf install -y pkgconfig go-md2man gcc make openssl-devel openssh-clients
12+
13+
# Install Rust
14+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
15+
ENV PATH="/root/.cargo/bin:${PATH}"
16+
17+
# Install nextest
18+
RUN cargo install cargo-nextest --locked
19+
20+
# Copy source code
21+
COPY . /src
22+
WORKDIR /src
23+
24+
# Build bcvk and create integration test archive
25+
RUN make && \
26+
cargo nextest archive --release -P integration -p integration-tests --archive-file integration-tests.tar.zst
27+
28+
# Runtime stage
29+
FROM $base
30+
31+
# Install runtime dependencies for running VMs
32+
RUN dnf clean all && \
33+
dnf -y install dnf-utils && \
34+
dnf config-manager --set-enabled crb && \
35+
dnf install -y \
36+
libvirt-daemon \
37+
libvirt-daemon-driver-qemu \
38+
libvirt-client \
39+
qemu-kvm \
40+
virtiofsd \
41+
podman && \
42+
dnf clean all
43+
44+
# Install Rust (needed for cargo nextest)
45+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
46+
ENV PATH="/root/.cargo/bin:${PATH}"
47+
48+
# Install nextest
49+
RUN cargo install cargo-nextest --locked
50+
51+
# Copy built artifacts
52+
COPY --from=build /src/target/release/bcvk /usr/local/bin/bcvk
53+
COPY --from=build /src/integration-tests.tar.zst /tests/integration-tests.tar.zst
54+
55+
# Copy source tree metadata needed by nextest
56+
# Nextest needs the workspace structure even when using archives
57+
COPY --from=build /src/Cargo.toml /src/Cargo.lock /tests/
58+
COPY --from=build /src/.config /tests/.config
59+
COPY --from=build /src/crates /tests/crates
60+
61+
# Set up environment
62+
ENV BCVK_PATH=/usr/local/bin/bcvk
63+
ENV LIBVIRT_DEFAULT_URI=qemu:///system
64+
WORKDIR /tests
65+
66+
# Create entrypoint script that pulls images and runs tests
67+
RUN printf '#!/bin/bash\n\
68+
set -euo pipefail\n\
69+
echo "Pulling test images..."\n\
70+
podman pull -q quay.io/fedora/fedora-bootc:42 quay.io/centos-bootc/centos-bootc:stream9 quay.io/centos-bootc/centos-bootc:stream10\n\
71+
echo "Running ephemeral integration tests..."\n\
72+
exec cargo nextest run --archive-file integration-tests.tar.zst --workspace-remap /tests ephemeral\n\
73+
' > /usr/local/bin/run-tests.sh && \
74+
chmod +x /usr/local/bin/run-tests.sh
75+
76+
# Default command runs the test script
77+
CMD ["/usr/local/bin/run-tests.sh"]

0 commit comments

Comments
 (0)