mirror of
https://github.com/Imbad0202/academic-research-skills.git
synced 2026-09-14 13:51:17 +08:00
revert(v3.9.4.2): drop F4 — test-count-monotonic gate hardening
Codex F4 finding asked test-count-monotonic to fail on pytest collection errors instead of swallowing them via `pytest ... | grep -c '::' || true`. That fix is correct in principle but surfaces a pre-existing repo-level defect: 24 test modules use `from scripts._test_helpers import ...`, which requires `scripts/` to be an importable package. It is not. The old swallow-everything behaviour masked this; my F4 implementation made the gate red on every PR (verified: CI run 26074181289 exited 2 with "24 errors during collection"). Both the per-file fallback I tried and the whole-repo pytest call hit the same import error locally. spec-consistency.yml works around it by invoking pytest once per file, but reproducing that here would need an ordered list synced across two workflows + correct per-file collection semantics — bigger than the v3.9.4.2 patch scope intends. Reverting F4 to keep this PR focused on the safe wins (F1 + F2 + F3). Tracking the underlying `scripts/` package issue + F4 + manifest unification as follow-ups before re-attempting this gate. Net change vs. main after this commit: F1 + F2 + F3 only.
This commit is contained in:
@@ -50,23 +50,7 @@ jobs:
|
||||
id: head
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Run pytest collection separately so collection errors fail the gate.
|
||||
# Without this, `pytest ... | grep -c` would mask non-zero pytest exits
|
||||
# (e.g., import errors during collection) and let a broken PR pass.
|
||||
set +e
|
||||
pytest --collect-only -q > pytest-collect.txt 2> pytest-collect.err
|
||||
PYTEST_EXIT=$?
|
||||
set -e
|
||||
# Tolerate exit 5 (no tests collected — empty repo edge case);
|
||||
# any other non-zero exit is a real collection failure.
|
||||
if [ "$PYTEST_EXIT" -ne 0 ] && [ "$PYTEST_EXIT" -ne 5 ]; then
|
||||
echo "::error::pytest collection failed on head (exit $PYTEST_EXIT)"
|
||||
cat pytest-collect.err >&2 || true
|
||||
tail -20 pytest-collect.txt >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
# grep -c returns 1 when no matches — tolerate only that case.
|
||||
COUNT=$(grep -c '::' pytest-collect.txt || true)
|
||||
COUNT=$(pytest --collect-only -q 2>/dev/null | grep -c '::' || true)
|
||||
echo "Head test count: $COUNT"
|
||||
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
@@ -92,18 +76,7 @@ jobs:
|
||||
working-directory: ../base
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Same discipline as the head count: collection errors fail the gate.
|
||||
set +e
|
||||
pytest --collect-only -q > pytest-collect.txt 2> pytest-collect.err
|
||||
PYTEST_EXIT=$?
|
||||
set -e
|
||||
if [ "$PYTEST_EXIT" -ne 0 ] && [ "$PYTEST_EXIT" -ne 5 ]; then
|
||||
echo "::error::pytest collection failed on base (exit $PYTEST_EXIT)"
|
||||
cat pytest-collect.err >&2 || true
|
||||
tail -20 pytest-collect.txt >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
COUNT=$(grep -c '::' pytest-collect.txt || true)
|
||||
COUNT=$(pytest --collect-only -q 2>/dev/null | grep -c '::' || true)
|
||||
echo "Base test count: $COUNT"
|
||||
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user