Skip to content

Commit e6e15a6

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 e6e15a6

File tree

4 files changed

+123
-0
lines changed

4 files changed

+123
-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: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 -y install dnf-utils && \
9+
dnf config-manager --set-enabled crb && \
10+
dnf install -y pkgconfig go-md2man gcc make openssl-devel openssh-clients && \
11+
dnf clean all
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 -y install dnf-utils && \
33+
dnf config-manager --set-enabled crb && \
34+
dnf install -y \
35+
libvirt-daemon \
36+
libvirt-daemon-driver-qemu \
37+
libvirt-client \
38+
qemu-kvm \
39+
virtiofsd \
40+
podman && \
41+
dnf clean all
42+
43+
# Copy cargo-nextest from build stage
44+
COPY --from=build /root/.cargo/bin/cargo-nextest /usr/local/bin/cargo-nextest
45+
46+
# Copy built artifacts
47+
COPY --from=build /src/target/release/bcvk /usr/local/bin/bcvk
48+
COPY --from=build /src/integration-tests.tar.zst /tests/integration-tests.tar.zst
49+
50+
# Copy source tree metadata needed by nextest
51+
# Nextest needs the workspace structure even when using archives
52+
COPY --from=build /src/Cargo.toml /src/Cargo.lock /tests/
53+
COPY --from=build /src/.config /tests/.config
54+
COPY --from=build /src/crates /tests/crates
55+
56+
# Set up environment
57+
ENV BCVK_PATH=/usr/local/bin/bcvk
58+
ENV LIBVIRT_DEFAULT_URI=qemu:///system
59+
WORKDIR /tests
60+
61+
# Create entrypoint script that pulls images and runs tests
62+
RUN <<EOF cat > /usr/local/bin/run-tests.sh
63+
#!/bin/bash
64+
set -euo pipefail
65+
echo "Pulling test images..."
66+
podman pull -q quay.io/fedora/fedora-bootc:42 quay.io/centos-bootc/centos-bootc:stream9 quay.io/centos-bootc/centos-bootc:stream10
67+
echo "Running ephemeral integration tests..."
68+
exec /usr/local/bin/cargo-nextest run --archive-file integration-tests.tar.zst --workspace-remap /tests ephemeral
69+
EOF
70+
RUN chmod +x /usr/local/bin/run-tests.sh
71+
72+
# Default command runs the test script
73+
CMD ["/usr/local/bin/run-tests.sh"]

0 commit comments

Comments
 (0)