Reproducible Python 3.12-slim container that installs the project editable with dev deps. Adds pytest-asyncio to dev deps so async tests run cleanly inside the container (host had it installed out-of-band). scripts/docker-test.sh provides build, test, ask, replay, and shell subcommands. The ask/replay/shell commands mount ~/secrets read-only and ~/.marchwarden read-write so end-to-end runs persist traces back to the host. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
62 lines
1.5 KiB
Bash
Executable file
62 lines
1.5 KiB
Bash
Executable file
#!/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"
|
|
docker run --rm -it \
|
|
-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
|