#!/usr/bin/env bash
set -euo pipefail
scratch=/tmp/lead-32646-r2/evidence-capture-2
repo="$HOME/t3code"
before="$HOME/wt/pr-32646-cap-before"
after="$HOME/wt/pr-32646-cap-after"
# Existing pinned capture images were reused. These recipes rebuild the same shell package versions.
docker build -t t3-32646-capture-debian -f "$scratch/Dockerfile.debian" "$scratch"
docker build -t t3-32646-capture-alpine -f "$scratch/Dockerfile.alpine" "$scratch"
git -C "$repo" worktree add "$before" d313b2aff31991ab94c8ac80cdc38a54dd575604
git -C "$repo" worktree add "$after" 6f9adc64ff9538222af5d7f8d9683be52c5e0551
(cd "$before" && vp install)
(cd "$after" && vp install)
run=$(node "$scratch/extend-fixtures.mjs")
(cd "$before/apps/server" && CAPTURE_SCRATCH="$scratch" node --experimental-strip-types "$scratch/capture-driver.mjs" --checkout "$before" --side before --run "$run") > "$run/before-driver.log" 2>&1
(cd "$after/apps/server" && CAPTURE_SCRATCH="$scratch" node --experimental-strip-types "$scratch/capture-driver.mjs" --checkout "$after" --side after --run "$run") > "$run/after-driver.log" 2>&1
python3 "$scratch/package-evidence.py" "$run"
printf '%s\n' "$run"
# Upload and preserve evidence before removing the literal worktree/scratch paths.
