Files
guide-board/scripts/container_smoke.sh

57 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env sh
set -eu
ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
IMAGE="${GUIDE_BOARD_SMOKE_IMAGE:-guide-board-core:smoke}"
RUNS_DIR="${GUIDE_BOARD_SMOKE_RUNS_DIR:-${TMPDIR:-/tmp}/guide-board-container-smoke-$$}"
RUNTIME="${CONTAINER_RUNTIME:-}"
if [ -z "$RUNTIME" ]; then
if command -v podman >/dev/null 2>&1; then
RUNTIME=podman
elif command -v docker >/dev/null 2>&1; then
RUNTIME=docker
else
echo "ERROR: podman or docker is required for the container smoke check." >&2
exit 127
fi
fi
mkdir -p "$RUNS_DIR"
echo "==> Building $IMAGE with $RUNTIME"
"$RUNTIME" build -t "$IMAGE" -f "$ROOT_DIR/Containerfile" "$ROOT_DIR"
echo "==> Running bundled sample assessment"
"$RUNTIME" run --rm \
-v "$RUNS_DIR:/runs" \
"$IMAGE" \
--root /opt/guide-board run \
--target /opt/guide-board/profiles/targets/sample-repository.json \
--assessment /opt/guide-board/profiles/assessments/sample-noop.json \
--output-dir /runs/sample-noop
echo "==> Verifying mounted run artifacts"
for path in \
"$RUNS_DIR/sample-noop/run.json" \
"$RUNS_DIR/sample-noop/plan.json" \
"$RUNS_DIR/sample-noop/sources.lock.json" \
"$RUNS_DIR/sample-noop/retention-summary.json" \
"$RUNS_DIR/sample-noop/normalized/evidence.json" \
"$RUNS_DIR/sample-noop/normalized/findings.json" \
"$RUNS_DIR/sample-noop/normalized/mappings.json" \
"$RUNS_DIR/sample-noop/reports/assessment-package.json" \
"$RUNS_DIR/sample-noop/reports/report.md" \
"$RUNS_DIR/sample-noop/reports/fragments.json" \
"$RUNS_DIR/sample-noop/reports/submission-package.json" \
"$RUNS_DIR/sample-noop/exports/export-manifest.json"
do
if [ ! -f "$path" ]; then
echo "ERROR: expected artifact missing: $path" >&2
exit 1
fi
done
echo "Container smoke check passed."
echo "Run artifacts: $RUNS_DIR/sample-noop"