#!/usr/bin/env bash # Helper for the dockerized test/run environment. # # Usage: # scripts/docker-test.sh build Build the image # scripts/docker-test.sh test Run pytest in the container # scripts/docker-test.sh ask "..." Run `marchwarden ask` end-to-end # (mounts ~/secrets ro and ~/.marchwarden rw) # scripts/docker-test.sh shell Drop into a bash shell in the container set -euo pipefail IMAGE="marchwarden-test" ROOT="$(cd "$(dirname "$0")/.." && pwd)" cmd="${1:-test}" shift || true case "$cmd" in build) docker build -t "$IMAGE" "$ROOT" ;; test) docker run --rm -v "$ROOT:/app" "$IMAGE" pytest -q "$@" ;; ask) if [ ! -f "$HOME/secrets" ]; then echo "error: ~/secrets not found on host" >&2 exit 1 fi mkdir -p "$HOME/.marchwarden/traces" tty_flag="" if [ -t 0 ] && [ -t 1 ]; then tty_flag="-it"; fi env_flag="" if [ -n "${MARCHWARDEN_MODEL:-}" ]; then env_flag="-e MARCHWARDEN_MODEL=$MARCHWARDEN_MODEL" fi docker run --rm $tty_flag $env_flag \ -v "$ROOT:/app" \ -v "$HOME/secrets:/root/secrets:ro" \ -v "$HOME/.marchwarden:/root/.marchwarden" \ "$IMAGE" marchwarden ask "$@" ;; replay) mkdir -p "$HOME/.marchwarden/traces" docker run --rm \ -v "$ROOT:/app" \ -v "$HOME/.marchwarden:/root/.marchwarden" \ "$IMAGE" marchwarden replay "$@" ;; shell) docker run --rm -it \ -v "$ROOT:/app" \ -v "$HOME/secrets:/root/secrets:ro" \ -v "$HOME/.marchwarden:/root/.marchwarden" \ "$IMAGE" bash ;; *) echo "unknown command: $cmd" >&2 echo "usage: $0 {build|test|ask|replay|shell}" >&2 exit 1 ;; esac