#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")/.." export PATH="$HOME/.local/go/bin:$PATH" features=(basic stages needs retry services cache hooks docker-options variables-expand artifacts tags reports) if (($#)); then features=("$@"); fi work_dir=$(mktemp -d) volumes_before="$work_dir/volumes.before" docker volume ls -q | sort >"$volumes_before" cleanup(){ status=$? docker ps -aq --filter label=shuttle.spike=runlocal | xargs -r docker rm -f >/dev/null 2>&1 || true docker volume ls -q | sort >"$work_dir/volumes.after" || true comm -13 "$volumes_before" "$work_dir/volumes.after" >"$work_dir/volumes.new" || true while IFS= read -r volume; do [[ -n "$volume" ]] || continue if [[ "$(docker volume inspect -f '{{ index .Labels "com.gitlab.gitlab-runner.type" }}' "$volume" 2>/dev/null || true)" == cache ]]; then docker volume rm "$volume" >/dev/null || true; fi done <"$work_dir/volumes.new" find "$work_dir" -depth -delete exit "$status" } trap cleanup EXIT INT TERM go build -o "$work_dir/shuttle" ./cmd/shuttle for feature in "${features[@]}"; do repo="$work_dir/repo-$feature"; out="$work_dir/out-$feature" git init -q -b main "$repo"; git -C "$repo" config user.name 'Shuttle Run Local'; git -C "$repo" config user.email shuttle@example.invalid cp "e2e/$feature/.gitlab-ci.yml" "$repo/.gitlab-ci.yml" [[ ! -d "e2e/$feature/files-1" ]] || cp -R "e2e/$feature/files-1/." "$repo/" git -C "$repo" add -A; git -C "$repo" commit -q -m "$feature" set +e; "$work_dir/shuttle" run-local --runner docker --out "$out" "$repo"; command_status=$?; set -e if [[ $command_status -gt 1 ]]; then echo "infrastructure failure: $feature" >&2; exit "$command_status"; fi SHUTTLE_RUN_LOCAL_OUT="$out" SHUTTLE_RUN_LOCAL_EXPECT="$PWD/e2e/$feature/expect.yml" go test -count=1 -tags runlocal -run TestRunLocalExpect ./cmd/shuttle echo "PASS $feature" done