fix(pre-commit): stop full-suite runaway + python-not-found; refine skip detector - #823
Conversation
…kip detector The pytest-check hook used 'pytest --lf', which runs the ENTIRE suite when there is no last-failed cache (a fresh checkout) - a ~2h18m run that made commits impractical. Add --lfnf none so it re-runs only previously-failed tests and no-ops when there are none (matching its 'fast feedback' name; full validation stays CI's job), invoke via 'uv run', and map pytest's exit 5 (no tests collected - the deselect-all no-op) to success. The skip-detector hook shelled out to 'python', absent from PATH here, so it errored on every run - silently unenforced. Use python3. With it actually running, it flagged 3 legitimate platform skipif guards (Windows POSIX perms, node availability). Refine the detector to flag only UNCONDITIONAL skips (@Skip / @pytest.mark.skip) and constant-true skipif(True) - its actual purpose (stop hiding failures) - while allowing conditional skipif gating.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 14 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Reviewed the diff (no prior substantive reviews on this PR to reconcile with — CodeRabbit's comment is just a rate-limit notice with no content). SummaryBoth fixes address real, well-documented problems (2h18m runaway full-suite hook, Findings1. 2. No test coverage for the refactored detector — the repo has no test file for 3. 4. Minor consistency nit — 5. Minor edge case — 6. Not introduced by this PR, flagging for awareness only — Nothing here blocks the stated purpose of the PR (unblocking commits), but #1 is a genuine gap in the security property the tool claims to enforce and I'd suggest closing it before relying on the refined detector going forward. |
run_tests preferred 'uv run pytest' whenever uv was installed, but uv errors
on a pyproject.toml with no [project] table ('No project table found'). So
run_tests failed in any workspace that isn't a uv-managed project - including
the test's bare tmp project, making test_pytest_success_summary fail locally
(it passed in CI only because CI's checkout is a real uv project). Gate the
'uv run' path on _is_uv_project (has [project] table or uv.lock); otherwise
use plain pytest.
|
Follow-up to my earlier review (this comment covers only what changed since then — commit New commit:
|
Problem
Two pre-commit hooks were effectively broken (surfaced while committing the #741 fix):
pytest-checkranpytest --lf, which runs the entire suite when there's no last-failed cache (a fresh checkout). That's a ~2h18m run — commits were impractical, so people bypassed hooks.skip-detectorshelled out topython, which isn't on PATH in this environment → it errored on every run and was silently unenforced.Fix
pytest-check: add--lfnf none(re-run only previously-failed tests; no-op when there are none — matching its "fast feedback" name), invoke viauv run(drop the fragile venv-activate/bare-pytestdance), and map pytest's exit 5 ("no tests collected" — the deselect-all no-op) to success so the no-op doesn't fail the commit. 3s no-op instead of a 2h18m suite; full validation stays CI's job.skip-detector:python→python3. Once it actually ran, it flagged 3 legitimate platformskipifguards (Windows POSIX perms, node availability). Refineddetect-skip-abuse.pyto flag only unconditional skips (@skip/@pytest.mark.skip) and constant-trueskipif(True)— its actual purpose (stop hiding failures) — while allowing conditionalskipifportability gating.Verification
pytest --lf --lfnf none -xon a clean cache → exit 5 → wrapper → exit 0 (3s no-op).tests/; flags@pytest.mark.skipandskipif(True); allowsskipif(sys.platform==...)and string conditions.Known limitation (separate, pre-existing)
tests/core/test_tools.py::TestRunTests::test_pytest_success_summaryfails locally only (green in CI):run_testsprefersuv run pytest, which can't build a bare tmp-dir project. Not a hook issue — filed separately if desired.