Skip to content

Commit a8675d7

Browse files
cgwaltersclaude
andcommitted
ci: Split RPM building into separate job
This splits the RPM package building into a separate CI job that runs before the integration tests. The built packages are then downloaded and used by the integration test jobs, avoiding redundant builds. Changes: - Add new 'package' job to build RPMs for each test OS - Make integration test jobs depend on the package job - Update Dockerfile to use bind-mounted packages instead of COPY - Add Justfile targets for building from pre-existing packages - Update .dockerignore to allow target/ directory 🤖 Generated with [Claude Code](https://claude.com/claude-code) Assisted-by: Claude Code (Sonnet 4.5) Co-Authored-By: Claude <[email protected]>
1 parent c797b37 commit a8675d7

File tree

7 files changed

+84
-9
lines changed

7 files changed

+84
-9
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@
2121
# Workaround for podman bug with secrets + remote
2222
# https://github.com/containers/podman/issues/25314
2323
!podman-build-secret*
24+
# Pre-built packages for builds that use them
25+
!target/
2426
# And finally of course all the Rust sources
2527
!crates/

.github/workflows/ci.yml

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,40 @@ jobs:
114114
uses: ./.github/actions/bootc-ubuntu-setup
115115
- name: Build mdbook
116116
run: just build-mdbook
117+
# Build packages for each test OS
118+
package:
119+
strategy:
120+
fail-fast: false
121+
matrix:
122+
test_os: [fedora-42, fedora-43, centos-9, centos-10]
123+
124+
runs-on: ubuntu-24.04
125+
126+
steps:
127+
- uses: actions/checkout@v6
128+
- name: Bootc Ubuntu Setup
129+
uses: ./.github/actions/bootc-ubuntu-setup
130+
131+
- name: Setup env
132+
run: |
133+
BASE=$(just pullspec-for-os ${{ matrix.test_os }})
134+
echo "BOOTC_base=${BASE}" >> $GITHUB_ENV
135+
136+
- name: Build packages
137+
run: just package
138+
139+
- name: Upload package artifacts
140+
uses: actions/upload-artifact@v5
141+
with:
142+
name: packages-${{ matrix.test_os }}
143+
path: target/*.rpm
144+
retention-days: 1
145+
117146
# Build bootc from source into a container image FROM each specified base `test_os`
118147
# running unit and integration tests (using TMT, leveraging the support for nested virtualization
119148
# in the GHA runners)
120149
test-integration:
150+
needs: package
121151
strategy:
122152
fail-fast: false
123153
matrix:
@@ -139,9 +169,15 @@ jobs:
139169
BASE=$(just pullspec-for-os ${{ matrix.test_os }})
140170
echo "BOOTC_base=${BASE}" >> $GITHUB_ENV
141171
172+
- name: Download package artifacts
173+
uses: actions/download-artifact@v5
174+
with:
175+
name: packages-${{ matrix.test_os }}
176+
path: target/
177+
142178
- name: Build container
143179
run: |
144-
just build-integration-test-image
180+
just build-integration-test-image-from-package target
145181
# Extra cross-check (duplicating the integration test) that we're using the right base
146182
used_vid=$(podman run --rm localhost/bootc-integration bash -c '. /usr/lib/os-release && echo ${ID}-${VERSION_ID}')
147183
test ${{ matrix.test_os }} = "${used_vid}"
@@ -175,6 +211,7 @@ jobs:
175211
176212
# This variant does composefs testing
177213
test-integration-cfs:
214+
needs: package
178215
strategy:
179216
fail-fast: false
180217
matrix:
@@ -200,9 +237,15 @@ jobs:
200237
echo "BOOTC_base=${BASE}" >> $GITHUB_ENV
201238
echo "BOOTC_variant="${{ matrix.variant }} >> $GITHUB_ENV
202239
240+
- name: Download package artifacts
241+
uses: actions/download-artifact@v5
242+
with:
243+
name: packages-${{ matrix.test_os }}
244+
path: target/
245+
203246
- name: Build container
204247
run: |
205-
just build-integration-test-image
248+
just build-integration-test-image-from-package target
206249
207250
- name: Unit and container integration tests
208251
run: just test-container
@@ -235,12 +278,13 @@ jobs:
235278
# Sentinel job for required checks - configure this job name in repository settings
236279
required-checks:
237280
if: always()
238-
needs: [cargo-deny, validate, test-integration, test-integration-cfs]
281+
needs: [cargo-deny, validate, package, test-integration, test-integration-cfs]
239282
runs-on: ubuntu-latest
240283
steps:
241284
- run: exit 1
242285
if: >-
243286
needs.cargo-deny.result != 'success' ||
244287
needs.validate.result != 'success' ||
288+
needs.package.result != 'success' ||
245289
needs.test-integration.result != 'success' ||
246290
needs.test-integration-cfs.result != 'success'

Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ ARG rootfs=
6363
RUN --mount=type=bind,from=packaging,target=/run/packaging /run/packaging/configure-rootfs "${variant}" "${rootfs}"
6464
# Inject additional content
6565
COPY --from=packaging /usr-extras/ /usr/
66-
# Install the RPM built in the build stage
66+
# Install packages from bind-mounted directory
6767
# This replaces the manual file deletion hack and COPY, ensuring proper package management
68-
# Use rpm -Uvh with --oldpackage to allow replacing with dev version
69-
COPY --from=build /out/*.rpm /tmp/
70-
RUN --mount=type=bind,from=packaging,target=/run/packaging --network=none /run/packaging/install-rpm-and-setup /tmp
68+
# The target/ directory containing built packages should be bind-mounted at build time
69+
RUN --mount=type=bind,from=packaging,target=/run/packaging \
70+
--mount=type=bind,source=target,target=/build-packages \
71+
--network=none \
72+
/run/packaging/install-rpm-and-setup /build-packages
7173
# Finally, testour own linting
7274
RUN bootc container lint --fatal-warnings

Justfile

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ buildargs := "--build-arg=base=" + base + " --build-arg=variant=" + variant
3939
# Build the container image from current sources.
4040
# Note commonly you might want to override the base image via e.g.
4141
# `just build --build-arg=base=quay.io/fedora/fedora-bootc:42`
42-
build:
42+
build: package
43+
podman build {{base_buildargs}} -t {{base_img}}-bin {{buildargs}} .
44+
./tests/build-sealed {{variant}} {{base_img}}-bin {{base_img}}
45+
46+
# Build the container image using pre-existing packages from PATH
47+
build-from-package PATH:
48+
@just copy-packages-from {{PATH}}
4349
podman build {{base_buildargs}} -t {{base_img}}-bin {{buildargs}} .
4450
./tests/build-sealed {{variant}} {{base_img}}-bin {{base_img}}
4551

@@ -64,20 +70,41 @@ _packagecontainer:
6470
echo "Building RPM with version: ${VERSION}"
6571
podman build {{base_buildargs}} {{buildargs}} --build-arg=pkgversion=${VERSION} -t localhost/bootc-pkg --target=build .
6672

67-
# Build a packages (e.g. RPM) into target/
73+
# Build packages (e.g. RPM) into target/
6874
# Any old packages will be removed.
6975
package: _packagecontainer
7076
mkdir -p target
7177
rm -vf target/*.rpm
7278
podman run --rm localhost/bootc-pkg tar -C /out/ -cf - . | tar -C target/ -xvf -
7379

80+
# Copy pre-existing packages from PATH into target/
81+
# Used to prepare for building with pre-built packages
82+
copy-packages-from PATH:
83+
#!/bin/bash
84+
set -xeuo pipefail
85+
if ! compgen -G "{{PATH}}/*.rpm" > /dev/null; then
86+
echo "Error: No packages found in {{PATH}}" >&2
87+
exit 1
88+
fi
89+
mkdir -p target
90+
rm -vf target/*.rpm
91+
cp -v {{PATH}}/*.rpm target/
92+
7493
# This container image has additional testing content and utilities
7594
build-integration-test-image: build
7695
cd hack && podman build {{base_buildargs}} -t {{integration_img}}-bin -f Containerfile .
7796
./tests/build-sealed {{variant}} {{integration_img}}-bin {{integration_img}}
7897
# Keep these in sync with what's used in hack/lbi
7998
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
8099

100+
# Build integration test image using pre-existing packages from PATH
101+
build-integration-test-image-from-package PATH:
102+
@just build-from-package {{PATH}}
103+
cd hack && podman build {{base_buildargs}} -t {{integration_img}}-bin -f Containerfile .
104+
./tests/build-sealed {{variant}} {{integration_img}}-bin {{integration_img}}
105+
# Keep these in sync with what's used in hack/lbi
106+
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
107+
81108
# Build+test using the `composefs-sealeduki-sdboot` variant.
82109
test-composefs:
83110
# These first two are currently a distinct test suite from tmt that directly
3.45 MB
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)