mirror of
https://github.com/boshu2/agentops.git
synced 2026-09-14 15:08:13 +08:00
fix(pre-push): keep fast two-pass advisory scoped
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user