#!/usr/bin/env bash # Build the reference daemon and CLI that mixed-version scenarios run beside # this checkout's (test/e2e/move_versions_test.py), then print the directory # holding them: `daemon/albedo-daemon` (a launcher for ALBEDO_DAEMON) and # `albedo` (the CLI for ALBEDO_TEST_CLI). # # REFERENCE is the commit those scenarios treat as the older daemon. Albedo has # no release tags yet, so it is pinned here, the only place it is recorded. # robot-docs/testing.md ("Mixed-version moves") says when and how to bump it. # # The build is cached under $ALBEDO_REFERENCE_CACHE (default # ~/.cache/albedo-reference), one directory per commit, so a repeat run only # prints the path. The sources come from `git archive`, outside the checkout, # and build with their own snapshot script and the current dev shell's tools. set -euo pipefail REFERENCE=5016e9802369aa430c182a3cdcae1cb61062aef2 root="$(cd "$(dirname "$0")/.." && pwd)" cache="${ALBEDO_REFERENCE_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/albedo-reference}" out="$cache/$REFERENCE" if [[ -e "$out/built" ]]; then echo "$out" exit 0 fi mkdir -p "$cache" # One build per commit, however many suites ask for it at once. exec 9>"$cache/$REFERENCE.lock" flock 9 if [[ -e "$out/built" ]]; then echo "$out" exit 0 fi # The launcher names its absolute paths, so the build happens in place and # `built` marks it complete; a half-finished one is started over. rm -rf "$out" mkdir -p "$out/src" if ! git -C "$root" cat-file -e "$REFERENCE^{commit}" 2>/dev/null; then # A shallow clone, as CI's may be, lacks the commit until it is fetched. git -C "$root" fetch --quiet --depth=1 origin "$REFERENCE" >&2 fi git -C "$root" archive "$REFERENCE" | tar -x -C "$out/src" "$out/src/test/snapshot-daemon.sh" "$out/daemon" >/dev/null go -C "$out/src/cli" build -o "$out/albedo" ./cmd/albedo >&2 # The sources stay: the launcher runs their priv/bin/albedo-daemon. Their # build tree is only an intermediate. rm -rf "$out/src/build" touch "$out/built" echo "$out"