Skip to content

Commit cdb79e8

Browse files
committed
ci: Build as user and copy images to root's podman storage
The install-tests CI job was failing because running `cargo xtask` as root (via sudojust) modified ~/.cargo files with root ownership, causing later cargo commands to fail with permission errors. This change builds container images as the regular user and copies them to root's podman storage using `podman save | sudo podman load`. This avoids cargo cache permission issues while still making images available for privileged tests. Add two new Justfile recipes: - copy-to-rootful: Copy a single image from user to root storage - copy-lbi-to-rootful: Copy all bound images (LBI) to root storage Assisted-by: OpenCode (Opus 4.5) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent e499b77 commit cdb79e8

2 files changed

Lines changed: 52 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ jobs:
6565
- name: Integration tests
6666
run: |
6767
set -xeu
68-
# Build images to test; TODO investigate doing single container builds
69-
# via GHA and pushing to a temporary registry to share among workflows?
70-
# Preserve rustup/cargo environment for sudo (rustup needs RUSTUP_HOME to find toolchains)
71-
sudojust() { sudo env PATH="$PATH" CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}" RUSTUP_HOME="${RUSTUP_HOME:-$HOME/.rustup}" just "$@"; }
72-
sudojust build
73-
sudojust build-install-test-image
68+
# Build images as regular user, then copy to root's podman storage
69+
# This avoids cargo cache permission issues when running cargo as root
70+
just build
71+
just build-install-test-image
72+
just copy-to-rootful localhost/bootc
73+
just copy-to-rootful localhost/bootc-install
74+
# Copy bound images (LBI) to root's storage for tests that need them
75+
just copy-lbi-to-rootful
7476
sudo podman build -t localhost/bootc-fsverity -f ci/Containerfile.install-fsverity
7577
76-
# Grant permission
77-
sudo chown -R "$(id -u):$(id -g)" /home/runner/work/bootc/bootc
7878
# TODO move into a container, and then have this tool run other containers
7979
cargo build --release -p tests-integration
8080

Justfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,47 @@ _keygen:
282282

283283
_build-upgrade-image:
284284
cat tmt/tests/Dockerfile.upgrade | podman build -t {{upgrade_img}} --from={{base_img}} -
285+
286+
# Copy an image from user podman storage to root's podman storage
287+
# This allows building as regular user then running privileged tests
288+
[group('testing')]
289+
copy-to-rootful $image:
290+
#!/bin/bash
291+
set -euxo pipefail
292+
293+
# If already running as root, nothing to do
294+
if [[ "${UID}" -eq "0" ]]; then
295+
echo "Already root, no need to copy image"
296+
exit 0
297+
fi
298+
299+
# Check if the image exists in user storage
300+
if ! podman image exists "${image}"; then
301+
echo "Image ${image} not found in user podman storage" >&2
302+
exit 1
303+
fi
304+
305+
# Get the image ID from user storage
306+
USER_IMG_ID=$(podman images --filter reference="${image}" --format '{{{{.ID}}')
307+
308+
# Check if the same image ID exists in root storage
309+
ROOT_IMG_ID=$(sudo podman images --filter reference="${image}" --format '{{{{.ID}}' 2>/dev/null || true)
310+
311+
if [[ "${USER_IMG_ID}" == "${ROOT_IMG_ID}" ]] && [[ -n "${ROOT_IMG_ID}" ]]; then
312+
echo "Image ${image} already exists in root storage with same ID"
313+
exit 0
314+
fi
315+
316+
# Copy the image from user to root storage
317+
# Use podman save/load via pipe (works on systems without machinectl)
318+
podman save "${image}" | sudo podman load
319+
echo "Copied ${image} to root podman storage"
320+
321+
# Copy all LBI (bound) images to root's podman storage
322+
[group('testing')]
323+
copy-lbi-to-rootful:
324+
#!/bin/bash
325+
set -euxo pipefail
326+
for img in {{lbi_images}}; do
327+
just copy-to-rootful "$img"
328+
done

0 commit comments

Comments
 (0)