Files
komorebi/e2e/platforms/qemu_windows/build-ref.sh
T
LGUG2Z 5840f36e1c feat(e2e): build the golden image in two layers
build-base.sh does the unattended install (about 18 minutes) and
build-golden.sh puts policies, Defender and the display driver on top of
it in about 2.5 minutes through the guest agent (provision.ps1). A qcow2
chain with a relative backing path keeps the two together.

build-ref.sh builds komorebi and komorebic of any commit, and
KOMOREBI_E2E_BINS makes nix run .#e2e-windows test those binaries.
2026-10-30 18:22:44 -07:00

42 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Builds the binaries of another komorebi commit, to run the e2e scenarios
# against them: `KOMOREBI_E2E_BINS=OUTDIR nix run .#e2e-windows -- ...`.
#
# usage: build-ref.sh REF OUTDIR
# REF is anything git knows (a commit, a branch, a tag); it is fetched from
# origin if it is not here yet. The checkout of REF is built with this
# tree's flake.nix and flake.lock, because the nix build of an older commit
# may not work any more; the test window is this tree's. OUTDIR gets
# komorebi.exe, komorebic.exe, komorebi-testwin.exe and `commit`, the full
# hash, which the runner writes into every result.json.
# needs on PATH: git nix
set -euo pipefail
ref=$1 out=$2
here=$(cd "$(dirname "$0")" && pwd)
root=$(git -C "$here" rev-parse --show-toplevel)
if ! git -C "$root" cat-file -e "$ref^{commit}" 2>/dev/null; then
git -C "$root" fetch origin "+refs/heads/*:refs/remotes/origin/*"
fi
commit=$(git -C "$root" rev-parse "$ref^{commit}")
tree=$(mktemp -d)
cleanup() {
git -C "$root" worktree remove --force "$tree" 2>/dev/null || rm -rf "$tree"
}
trap cleanup EXIT
git -C "$root" worktree add --detach "$tree" "$commit"
cp "$root/flake.nix" "$root/flake.lock" "$tree/"
mkdir -p "$out"
for package in komorebi komorebic; do
path=$(nix build "$tree#$package" --no-link --print-out-paths)
cp "$path/bin/$package.exe" "$out/"
done
path=$(nix build "$root#komorebi-testwin" --no-link --print-out-paths)
cp "$path/bin/komorebi-testwin.exe" "$out/"
chmod u+w "$out"/*.exe
echo "$commit" > "$out/commit"
echo "built $commit into $out"