|
| 1 | +# Justfile for bootc reverse dependency testing |
| 2 | +# Invoked via: just bootc/<target> |
| 3 | +# |
| 4 | +# This builds and tests bootc against the local containers-image-proxy-rs checkout |
| 5 | +# using bootc's auto-detection of path dependencies via `cargo xtask local-rust-deps`. |
| 6 | +# -------------------------------------------------------------------- |
| 7 | + |
| 8 | +# Configuration variables (override via environment or command line) |
| 9 | +# Example: IMAGE_PROXY_BOOTC_REF=v1.0.0 just bootc/build |
| 10 | + |
| 11 | +# Path to bootc checkout (will be cloned if it doesn't exist) |
| 12 | +# Note: Use source_directory() not justfile_directory() so paths resolve correctly |
| 13 | +# when invoked as a submodule (just bootc::test) vs directly (cd bootc && just test) |
| 14 | +export IMAGE_PROXY_BOOTC_PATH := env("IMAGE_PROXY_BOOTC_PATH", source_directory() + "/../target/bootc") |
| 15 | +# Git ref to checkout for bootc (branch, tag, or PR ref) |
| 16 | +export IMAGE_PROXY_BOOTC_REF := env("IMAGE_PROXY_BOOTC_REF", "main") |
| 17 | +# Remote repository for bootc |
| 18 | +export IMAGE_PROXY_BOOTC_REPO := env("IMAGE_PROXY_BOOTC_REPO", "https://github.com/bootc-dev/bootc") |
| 19 | + |
| 20 | +# Internal: absolute path to the containers-image-proxy-rs checkout (parent of this Justfile) |
| 21 | +export _PROXY_SRC := canonicalize(source_directory() + "/..") |
| 22 | + |
| 23 | +# Clone or update bootc repository |
| 24 | +clone: |
| 25 | + #!/bin/bash |
| 26 | + set -euo pipefail |
| 27 | + if [ -d "$IMAGE_PROXY_BOOTC_PATH/.git" ]; then |
| 28 | + echo "bootc already cloned at $IMAGE_PROXY_BOOTC_PATH" |
| 29 | + echo "To update: cd $IMAGE_PROXY_BOOTC_PATH && git fetch && git checkout <ref>" |
| 30 | + else |
| 31 | + echo "Cloning bootc from $IMAGE_PROXY_BOOTC_REPO (ref: $IMAGE_PROXY_BOOTC_REF) to $IMAGE_PROXY_BOOTC_PATH" |
| 32 | + mkdir -p "$(dirname "$IMAGE_PROXY_BOOTC_PATH")" |
| 33 | + # Use --no-checkout with --filter for efficient cloning, then fetch the specific ref |
| 34 | + # This handles PR refs (refs/pull/123/head) correctly |
| 35 | + git clone "$IMAGE_PROXY_BOOTC_REPO" "$IMAGE_PROXY_BOOTC_PATH" --no-checkout --filter=blob:none |
| 36 | + cd "$IMAGE_PROXY_BOOTC_PATH" |
| 37 | + git fetch --depth=1 origin "$IMAGE_PROXY_BOOTC_REF" |
| 38 | + git checkout FETCH_HEAD |
| 39 | + fi |
| 40 | + |
| 41 | +# Patch bootc's Cargo.toml to use the local containers-image-proxy-rs checkout |
| 42 | +# The path is auto-detected and bind-mounted by bootc's `cargo xtask local-rust-deps` |
| 43 | +patch: clone |
| 44 | + #!/bin/bash |
| 45 | + set -euo pipefail |
| 46 | + cd "$IMAGE_PROXY_BOOTC_PATH" |
| 47 | + |
| 48 | + # Check if already patched |
| 49 | + if grep -q 'Patched by containers-image-proxy-rs' Cargo.toml 2>/dev/null; then |
| 50 | + echo "bootc already patched for containers-image-proxy-rs" |
| 51 | + exit 0 |
| 52 | + fi |
| 53 | + |
| 54 | + echo "Patching bootc Cargo.toml to use $_PROXY_SRC" |
| 55 | + |
| 56 | + # Add [patch] section with the real local path |
| 57 | + # bootc's Justfile will auto-detect this via `cargo xtask local-rust-deps` |
| 58 | + # and bind-mount it into the container build (mapping /home -> /var/home as needed) |
| 59 | + { |
| 60 | + echo '' |
| 61 | + echo '# Patched by containers-image-proxy-rs CI to test against local checkout' |
| 62 | + echo '[patch.crates-io]' |
| 63 | + echo "containers-image-proxy = { path = \"$_PROXY_SRC\" }" |
| 64 | + } >> Cargo.toml |
| 65 | + |
| 66 | + # Patch the workspace lints to allow missing_docs for containers-image-proxy-rs |
| 67 | + # bootc has workspace.lints.rust.missing_docs = "deny" but this crate has undocumented items |
| 68 | + sed -i 's/missing_docs = "deny"/missing_docs = "allow"/' Cargo.toml |
| 69 | + |
| 70 | + # Update Cargo.lock so the patch is recognized by cargo xtask local-rust-deps |
| 71 | + cargo update containers-image-proxy |
| 72 | + |
| 73 | + echo "bootc patched successfully" |
| 74 | + |
| 75 | +# Build sealed bootc image using local containers-image-proxy-rs |
| 76 | +# The path dependency is auto-detected and bind-mounted by bootc's Justfile |
| 77 | +build: patch |
| 78 | + #!/bin/bash |
| 79 | + set -euo pipefail |
| 80 | + cd "$IMAGE_PROXY_BOOTC_PATH" |
| 81 | + echo "Building sealed bootc image with local containers-image-proxy-rs from $_PROXY_SRC" |
| 82 | + just build-sealed |
| 83 | + |
| 84 | +# Run bootc tests using local containers-image-proxy-rs |
| 85 | +# Since the patch uses real local paths, no symlinks or special env vars needed |
| 86 | +test: build |
| 87 | + #!/bin/bash |
| 88 | + set -euo pipefail |
| 89 | + cd "$IMAGE_PROXY_BOOTC_PATH" |
| 90 | + echo "Running bootc tests..." |
| 91 | + cargo test --workspace |
| 92 | + |
| 93 | +# Clean the bootc checkout and any patches |
| 94 | +clean: |
| 95 | + #!/bin/bash |
| 96 | + set -euo pipefail |
| 97 | + if [ -d "$IMAGE_PROXY_BOOTC_PATH" ]; then |
| 98 | + echo "Removing bootc checkout at $IMAGE_PROXY_BOOTC_PATH" |
| 99 | + rm -rf "$IMAGE_PROXY_BOOTC_PATH" |
| 100 | + else |
| 101 | + echo "No bootc checkout found at $IMAGE_PROXY_BOOTC_PATH" |
| 102 | + fi |
| 103 | + |
| 104 | +# Show current bootc integration configuration |
| 105 | +config: |
| 106 | + #!/bin/bash |
| 107 | + cat <<EOF |
| 108 | + Bootc Integration Configuration |
| 109 | + ================================ |
| 110 | + path: $IMAGE_PROXY_BOOTC_PATH |
| 111 | + ref: $IMAGE_PROXY_BOOTC_REF |
| 112 | + repo: $IMAGE_PROXY_BOOTC_REPO |
| 113 | + |
| 114 | + containers-image-proxy-rs source: $_PROXY_SRC |
| 115 | + |
| 116 | + Environment Variables: |
| 117 | + IMAGE_PROXY_BOOTC_PATH - Override bootc checkout path |
| 118 | + IMAGE_PROXY_BOOTC_REF - Override bootc git ref (branch/tag/PR) |
| 119 | + IMAGE_PROXY_BOOTC_REPO - Override bootc git repository |
| 120 | + |
| 121 | + Example Usage: |
| 122 | + just bootc/build # Clone main, patch, and build |
| 123 | + IMAGE_PROXY_BOOTC_REF=v1.2.0 just bootc/build # Use specific tag |
| 124 | + IMAGE_PROXY_BOOTC_REF=refs/pull/1791/head just bootc/build # Use PR |
| 125 | + EOF |
0 commit comments