kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

pull_test_images.sh (1793B)


      1 #!/usr/bin/env bash
      2 # Provision the pinned per-arch alpine rootfs images that exec_target.sh runs
      3 # kit-emitted binaries inside.
      4 #
      5 # THIS is the only test step that touches the network. The test harnesses
      6 # themselves always run with `podman run --pull=never`, so the images must be
      7 # present locally first. Run once (and again only after the pin in
      8 # test/lib/test_images.sh changes):
      9 #
     10 #   make test-images          # or: bash test/lib/pull_test_images.sh
     11 #
     12 # Each arch is pulled by its own content digest, so the three images coexist in
     13 # local storage and can never be confused for one another. Set FORCE=1 to
     14 # re-pull even when an image is already present.
     15 set -euo pipefail
     16 
     17 ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
     18 # shellcheck source=test/lib/test_images.sh
     19 . "$ROOT/test/lib/test_images.sh"
     20 
     21 if ! command -v podman >/dev/null 2>&1; then
     22     echo "pull-test-images: podman not found; nothing to provision" >&2
     23     exit 1
     24 fi
     25 
     26 rc=0
     27 for arch in $KIT_TEST_ARCHES; do
     28     ref="$(kit_test_image_for_arch "$arch")"
     29     if [ -z "$ref" ]; then
     30         echo "pull-test-images: no image pinned for arch '$arch'" >&2
     31         rc=1
     32         continue
     33     fi
     34     if [ -z "${FORCE:-}" ] && podman image exists "$ref"; then
     35         echo "pull-test-images: $arch already present ($ref)"
     36         continue
     37     fi
     38     # Digest references are single-arch and content-addressed, so no --platform
     39     # is needed and pulling one arch cannot affect another's local image.
     40     echo "pull-test-images: pulling $arch <- $ref"
     41     if id="$(podman pull -q "$ref")"; then
     42         echo "pull-test-images: $arch ready ($id)"
     43     else
     44         echo "pull-test-images: FAILED to pull $arch ($ref)" >&2
     45         rc=1
     46     fi
     47 done
     48 
     49 if [ "$rc" -eq 0 ]; then
     50     echo "pull-test-images: all arches provisioned"
     51 fi
     52 exit "$rc"