From a94eb507600beb129fe1389e76a5952582c87059 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 2 Oct 2026 18:21:40 +0000 Subject: [PATCH] fix(db-gate): stop the unit test from killing other worktrees' gates db-gate.test.ts runs the real .superset/db-gate.sh with HOME pointed at a temp directory, which skips the shared stack lock. The script's cleanup then ran the real `docker rm -f debatelab-fake-openrouter`, so any `npm test` on the VPS killed a gate or verify stack running in another worktree. The cleanup now removes the fake provider only when this run started it, the same guard verify.sh uses. The test also stubs docker and keeps mktemp output inside its temp root, so it fails if the cleanup ever calls docker again. Co-Authored-By: Claude Opus 5.5 (1M context) --- .superset/db-gate.sh | 7 ++++++- src/test/scripts/db-gate.test.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.superset/db-gate.sh b/.superset/db-gate.sh index 9be7c0a30..4b49c30dc 100755 --- a/.superset/db-gate.sh +++ b/.superset/db-gate.sh @@ -26,6 +26,7 @@ if [ "$LIVE_PROVIDERS" = 1 ] && { [ -z "${LIVE_OPENROUTER_API_KEY:-}" ] || [ -z exit 1 fi stack_started=false +provider_started=false runtime_dir="" owned_pids=() @@ -44,7 +45,10 @@ cleanup() { trap - EXIT stop_owned_processes - docker rm -f "$FAKE_PROVIDER" >/dev/null 2>&1 || true + # The container name is shared by every worktree, so only remove our own. + if [ "$provider_started" = true ]; then + docker rm -f "$FAKE_PROVIDER" >/dev/null 2>&1 || true + fi if [ -n "$runtime_dir" ] && [ -f "$runtime_dir/function.env" ]; then rm -- "$runtime_dir/function.env" @@ -114,6 +118,7 @@ fi # Edge Functions reach the fake provider by container name on the stack network. docker rm -f "$FAKE_PROVIDER" >/dev/null 2>&1 || true +provider_started=true docker run -d --rm --name "$FAKE_PROVIDER" --network "supabase_network_$project_id" \ "${provider_mode[@]}" -p 127.0.0.1:18090:8787 -v "$(pwd)/e2e/full-stack/fake-openrouter.mjs:/fake.mjs:ro" \ node:22-alpine node /fake.mjs >/dev/null diff --git a/src/test/scripts/db-gate.test.ts b/src/test/scripts/db-gate.test.ts index 527a82c4f..ed4c2547d 100644 --- a/src/test/scripts/db-gate.test.ts +++ b/src/test/scripts/db-gate.test.ts @@ -21,6 +21,12 @@ it("stops local Supabase when database tests fail", async () => { const bin = join(root, "bin"); const log = join(root, "calls.log"); await mkdir(bin); + // The gate's cleanup can remove the shared fake-provider container. A real + // docker here would kill a gate running in any other worktree, so log it instead. + await executable( + join(bin, "docker"), + '#!/usr/bin/env bash\nprintf "docker %s\\n" "$*" >> "$CALL_LOG"\n', + ); await executable( join(bin, "supabase"), '#!/usr/bin/env bash\nprintf "supabase %s\\n" "$*" >> "$CALL_LOG"\n', @@ -37,6 +43,8 @@ it("stops local Supabase when database tests fail", async () => { CALL_LOG: log, HOME: root, PATH: `${bin}:${process.env.PATH ?? ""}`, + TMPDIR: root, + WORKSPACE_GATE_ARTIFACT_ROOT: "", }, });