fix(pre-push): keep fast two-pass advisory scoped

This commit is contained in:
Boden Fuller
2026-05-07 19:53:18 -04:00
parent 4cf012b16e
commit ce9d42f852
2 changed files with 36 additions and 1 deletions
+5 -1
View File
@@ -309,6 +309,10 @@ fi
# --- Two-pass mode: re-invoke as pass 1 (blocking) + pass 2 (advisory) ---
if [[ "$TWO_PASS" == "true" ]]; then
SELF="$SCRIPT_DIR/pre-push-gate.sh"
pass2_args=(--scope upstream --accumulate)
if [[ "$FAST_MODE" == "true" ]]; then
pass2_args=(--fast "${pass2_args[@]}")
fi
echo "=== Two-pass mode ==="
echo ""
echo "--- Pass 1: HEAD commit (blocking) ---"
@@ -324,7 +328,7 @@ if [[ "$TWO_PASS" == "true" ]]; then
echo -e "${GREEN}--- Pass 1: PASSED ---${NC}"
echo ""
echo "--- Pass 2: upstream range (advisory) ---"
_PRE_PUSH_ADVISORY=1 PRE_PUSH_TWO_PASS=0 "$SELF" --scope upstream --accumulate || true
_PRE_PUSH_ADVISORY=1 PRE_PUSH_TWO_PASS=0 "$SELF" "${pass2_args[@]}" || true
exit 0
fi
+31
View File
@@ -1222,6 +1222,37 @@ GO
[[ "$output" == *"advisory"* ]]
}
@test "pre-push-gate.sh --fast two-pass keeps pass 2 fast and skips evals for non-eval changes" {
cat > "$MOCK_BIN/git" <<'GIT'
#!/usr/bin/env bash
if [[ "$*" == *"show --name-only"* ]]; then echo ""; exit 0; fi
if [[ "$*" == *"diff --name-only"* && "$*" == *"upstream"* ]]; then echo "docs/README.md"; exit 0; fi
if [[ "$*" == *"diff --name-only"* ]]; then echo ""; fi
if [[ "$*" == *"rev-parse"* ]]; then echo "/tmp"; fi
exit 0
GIT
chmod +x "$MOCK_BIN/git"
cat > "$FAKE_REPO/scripts/eval-agentops.sh" <<'EVAL'
#!/usr/bin/env bash
mkdir -p .agents/evals
touch .agents/evals/should-not-exist
echo "eval should not run" > "$BATS_TEST_TMPDIR/eval-called"
exit 1
EVAL
chmod +x "$FAKE_REPO/scripts/eval-agentops.sh"
cd "$FAKE_REPO"
export PATH="$MOCK_BIN:$PATH"
run env -u CI -u GITHUB_ACTIONS BATS_TEST_TMPDIR="$BATS_TEST_TMPDIR" bash "$GATE" --fast --two-pass
[ "$status" -eq 0 ]
[[ "$output" == *"Pass 1: PASSED"* ]]
[[ "$output" == *"AgentOps eval canaries"*"skipped"* ]]
[ ! -e "$BATS_TEST_TMPDIR/eval-called" ]
[ ! -e "$FAKE_REPO/.agents/evals/should-not-exist" ]
}
@test "pre-push-gate.sh --two-pass exits 1 when pass 1 fails" {
# Pass 1 (head scope) sees a go build failure → blocking, exit 1.
cat > "$MOCK_BIN/git" <<'GIT'