kit

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

run.sh (4108B)


      1 #!/bin/sh
      2 # Full release artifact smoke for the runnable arm64 macOS target.
      3 #
      4 # This deliberately drives scripts/release.sh rather than reimplementing the
      5 # staging/package steps. It uses the in-tree non-release key and a private output
      6 # directory, then validates both shipped formats:
      7 #   - .kpkg installs through kit update under an isolated KIT_HOME
      8 #   - .tar.gz unpacks through kit pkg unpack under a separate isolated KIT_HOME
      9 #
     10 # Run by: make test-release-macos-aa64
     11 
     12 set -u
     13 
     14 script_dir=$(cd "$(dirname "$0")" && pwd)
     15 repo_root=$(cd "$script_dir/../.." && pwd)
     16 
     17 KIT="${KIT:-$repo_root/build/kit}"
     18 if [ ! -x "$KIT" ]; then
     19     echo "release: kit binary not found at $KIT" >&2
     20     exit 2
     21 fi
     22 
     23 work=$(mktemp -d "${TMPDIR:-/tmp}/kit-release-test.XXXXXX")
     24 trap 'rm -rf "$work"' EXIT
     25 
     26 HOME="$work/home"
     27 SOURCE_DATE_EPOCH=1
     28 export HOME SOURCE_DATE_EPOCH
     29 mkdir -p "$HOME"
     30 
     31 KIT_KIT_DIR="$repo_root/test/lib"
     32 . "$repo_root/test/lib/kit_sh_kit.sh"
     33 kit_report_init
     34 
     35 SECKEY="$repo_root/test/dist/keys/nonrelease.key"
     36 PUBKEY="$repo_root/test/dist/keys/nonrelease.pub"
     37 OUT_DIR="$work/release-dist"
     38 VERSION=$(tr -d ' \t\r\n' < "$repo_root/VERSION")
     39 TARGET=macos-aa64
     40 TRIPLE=aarch64-apple-darwin
     41 HOST_TRIPLE=aarch64-macos
     42 BASE="$OUT_DIR/kit-$VERSION-$TRIPLE"
     43 
     44 host_os=$(uname -s 2>/dev/null || echo unknown)
     45 host_arch=$(uname -m 2>/dev/null || echo unknown)
     46 case "$host_os:$host_arch" in
     47     Darwin:arm64|Darwin:aarch64) ;;
     48     *)
     49         skip_test "release-macos-aa64-host" \
     50             "requires arm64 macOS host, got $host_os/$host_arch"
     51         kit_summary release-macos-aa64
     52         kit_exit
     53         ;;
     54 esac
     55 
     56 if ! command -v xcrun >/dev/null 2>&1; then
     57     skip_test "release-macos-aa64-xcrun" "xcrun not available"
     58     kit_summary release-macos-aa64
     59     kit_exit
     60 fi
     61 
     62 runs_version() {
     63     name=$1
     64     exe=$2
     65     home=$3
     66     if KIT_HOME="$home" "$exe" --version > "$work/$name.out" 2> "$work/$name.err" &&
     67        grep -F "kit $VERSION " "$work/$name.out" >/dev/null 2>&1 &&
     68        grep -F "$HOST_TRIPLE" "$work/$name.out" >/dev/null 2>&1; then
     69         ok "$name"
     70     else
     71         { cat "$work/$name.err"; cat "$work/$name.out"; } > "$work/$name.diag"
     72         not_ok "$name" "$work/$name.diag"
     73     fi
     74 }
     75 
     76 if env KIT= \
     77        KIT_SIGN_KEY="$SECKEY" \
     78        KIT_RELEASE_ALLOW_TEST_KEY=1 \
     79        KIT_RELEASE_PUBKEYS="$PUBKEY" \
     80        KIT_UPDATE_INDEX_URL="https://example.invalid/stable.index" \
     81        KIT_RELEASE_ALLOW_DIRTY=1 \
     82        KIT_RELEASE_TARGETS="$TARGET" \
     83        KIT_RELEASE_OUT_DIR="$OUT_DIR" \
     84        KIT_VM=0 \
     85        "$repo_root/scripts/release.sh" \
     86        > "$work/release-build-$TARGET.out" \
     87        2> "$work/release-build-$TARGET.err"; then
     88     ok "release-build-$TARGET"
     89 else
     90     not_ok "release-build-$TARGET" "$work/release-build-$TARGET.err"
     91     kit_summary release-macos-aa64
     92     kit_exit
     93 fi
     94 
     95 assert_file_exists "release-kpkg-exists" "$BASE.kpkg"
     96 assert_file_exists "release-targz-exists" "$BASE.tar.gz"
     97 assert_file_exists "release-targz-minisig-exists" "$BASE.tar.gz.minisig"
     98 assert_file_exists "release-index-exists" "$OUT_DIR/stable.index"
     99 assert_file_exists "release-index-minisig-exists" "$OUT_DIR/stable.index.minisig"
    100 
    101 KP_HOME="$work/kit-home-kpkg"
    102 run_ok "kpkg-update-installs" env KIT_HOME="$KP_HOME" \
    103     "$KIT" update --key "$PUBKEY" "$BASE.kpkg"
    104 contains "kpkg-update-message" "$work/kpkg-update-installs.out" \
    105     "installed kit $VERSION (now current)"
    106 assert_file_exists "kpkg-current-bin-exists" "$KP_HOME/versions/$VERSION/bin/kit"
    107 is_executable "kpkg-current-bin-exec" "$KP_HOME/bin/kit"
    108 runs_version "kpkg-installed-kit-runs" "$KP_HOME/bin/kit" "$KP_HOME"
    109 
    110 TG_HOME="$work/kit-home-targz"
    111 TG_ROOT="$work/targz-root"
    112 mkdir -p "$TG_ROOT"
    113 run_ok "targz-unpacks" env KIT_HOME="$TG_HOME" \
    114     "$KIT" pkg unpack --verify -p "$PUBKEY" "$BASE.tar.gz" -C "$TG_ROOT"
    115 contains "targz-unpack-message" "$work/targz-unpacks.out" \
    116     "unpacked kit $VERSION to $TG_ROOT"
    117 assert_file_exists "targz-bin-exists" "$TG_ROOT/bin/kit"
    118 is_executable "targz-bin-exec" "$TG_ROOT/bin/kit"
    119 runs_version "targz-kit-runs" "$TG_ROOT/bin/kit" "$TG_HOME"
    120 
    121 kit_summary release-macos-aa64
    122 kit_exit