fix(ci): run pre-commit pytest-unit on staged files only - #224
Conversation
Stop always-running the unit catalog on every commit. Infer tests from changed Python; leave make test and CI pytest as the full suite. Co-authored-by: Cursor <cursoragent@cursor.com>
|
✅ PR reviewable size is within recommended limits |
L9 Audit Harness Report
Step Results
Architecture Audit Findings
See Spec Coverage
See Next StepsAll checks passed. Safe to merge. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c3723bd13
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| entry: python3 tools/run_precommit_pytest_unit.py | ||
| language: system | ||
| pass_filenames: false | ||
| always_run: true | ||
| types: [python] | ||
| pass_filenames: true | ||
| stages: [pre-commit] |
There was a problem hiding this comment.
Serialize the threshold-based all-files hook
When pre-commit run --all-files is used, this hook may be invoked in multiple parallel filename batches because require_serial is not enabled; pre-commit defines that option as executing the hook using a single process. Each process therefore evaluates the 40-file threshold independently: with the repository's 366 Python files, sufficiently large batches each launch the same historical pytest subset, while smaller batches take the selective path instead. This can run the suite repeatedly, exceed the CI job's 15-minute limit, or fail to preserve the promised historical subset; add require_serial: true or detect all-files mode independently of per-invocation arguments.
Useful? React with 👍 / 👎.
| candidates = [ | ||
| f"tests/unit/test_{stem}.py", | ||
| f"tests/unit/test_{parent}_{stem}.py", | ||
| f"tests/unit/test_{parent}.py", | ||
| ] |
There was a problem hiding this comment.
Include unit tests whose names extend the implementation stem
For a commit changing only engine/graph/driver.py, these candidates and the later suffix search return no tests, so main() exits successfully without running pytest even though tests/unit/test_graph_driver_database_binding.py, test_outcomes.py, and test_wave4_state_resilience.py import and exercise GraphDriver. The same mismatch occurs for several feature-grouped modules, so common engine changes silently bypass the intended pre-commit unit coverage; use a reverse-import/declarative mapping or a safe fallback when exact filename inference finds nothing.
AGENTS.md reference: AGENTS.md:L34-L42
Useful? React with 👍 / 👎.



Summary
pytest-unithook from always running the unit catalog on every commit.tests/unit/coverage from staged Python; skip when nothing maps.make testand CI pytest stay the full suite.pre-commit run --all-files(≥40.pyfiles) keeps the previous unit subset so CI does not lose that check.Test plan
pytest tests/unit/test_precommit_pytest_unit.py(5 passed)python3 tools/run_precommit_pytest_unit.py engine/gates/compiler.pyruns onlytests/unit/test_gate_compiler.pypytest-unitis skippedengine/change and confirm only inferred unit files runMade with Cursor