Repository navigation
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
56 lines (52 loc) · 2.57 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
56 lines (52 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
repos:
# Note: black removed from pre-commit to avoid conflicts with ruff --fix
# Run `uv run black .` manually before committing if needed
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
types: [python]
- repo: local
hooks:
- id: pytest-check
name: Run last failed tests (fast feedback)
# Re-runs only what you previously broke; full validation is CI's job.
#
# NOT `pytest --lf --lfnf none` (#984): --lfnf none guards only the
# EMPTY cache. With a non-empty lastfailed whose node IDs no longer
# resolve — you renamed a test — pytest runs the WHOLE SUITE, carrying
# -x. Renaming a test therefore hung the next commit. The script prunes
# unresolvable node IDs first, so a stale cache selects nothing.
#
# uv run: the project's canonical invocation (no fragile venv-activate
# guessing / bare `pytest` that may not be on PATH).
# timeout: a pre-commit hook needs a wall-clock ceiling whatever it
# decides to run. 124 = timed out → warn and pass; never block a commit
# on a hook that hung.
# exit 5 = "no tests collected" (the deselect-all no-op) → treat as pass.
entry: >-
bash -c 'timeout 300 uv run python scripts/pretest_lastfailed.py;
code=$?; [ "$code" -eq 5 ] && code=0;
if [ "$code" -eq 124 ]; then
echo "pytest-check timed out after 300s, skipping (see #984)";
code=0; fi; exit $code'
language: system
pass_filenames: false
files: \.py$
types: [python]
- id: coverage-check
name: Enforce 65% coverage (manual - use scripts/verify-ai-claims.sh for full check)
entry: bash -c 'if [ -f venv/bin/activate ]; then source venv/bin/activate && pytest --cov --cov-report=term-missing --cov-fail-under=65; elif [ -f .venv/bin/activate ]; then source .venv/bin/activate && pytest --cov --cov-report=term-missing --cov-fail-under=65; else pytest --cov --cov-report=term-missing --cov-fail-under=65; fi || (echo "❌❌❌ COVERAGE BELOW 65% ❌❌❌" && exit 1)'
language: system
pass_filenames: false
files: \.py$
types: [python]
stages: [manual]
- id: skip-detector
name: Detect skip decorator abuse
# python3, not python: this environment has no `python` on PATH.
entry: python3 scripts/detect-skip-abuse.py
language: system
files: ^tests/.*\.py$
pass_filenames: false