Skip to content

fix(ci): run pre-commit pytest-unit on staged files only - #224

Merged
cryptoxdog merged 1 commit into
mainfrom
feat/precommit-scoped-pytest-unit
Aug 22, 2026
Merged

fix(ci): run pre-commit pytest-unit on staged files only#224
cryptoxdog merged 1 commit into
mainfrom
feat/precommit-scoped-pytest-unit

Conversation

@cryptoxdog

Copy link
Copy Markdown
Collaborator

Summary

  • Stop the local pytest-unit hook from always running the unit catalog on every commit.
  • Infer tests/unit/ coverage from staged Python; skip when nothing maps. make test and CI pytest stay the full suite.
  • pre-commit run --all-files (≥40 .py files) 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.py runs only tests/unit/test_gate_compiler.py
  • Commit a docs-only change and confirm pytest-unit is skipped
  • Commit an engine/ change and confirm only inferred unit files run

Made with Cursor

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>
@github-actions

Copy link
Copy Markdown

PR reviewable size is within recommended limits

@github-actions

Copy link
Copy Markdown

L9 Audit Harness Report

  • Generated: 2026-08-21T20:10:46.046963+00:00
  • Repo root: /home/runner/work/Cognitive.Engine.Graphs/Cognitive.Engine.Graphs
  • Overall result: ✅ PASSED
  • Exit code: 0

Step Results

Step Status Exit Code Notes
Architecture Audit ✅ Passed 0
Spec Coverage ✅ Passed 0
Contract Wiring ✅ Passed 0

Architecture Audit Findings

Severity Count
🔴 CRITICAL 0
🟠 HIGH 0
🟡 MEDIUM 25
🔵 LOW 0

See artifacts/audit_report.md for full details.

Spec Coverage

  • ✅ Implemented: 37
  • ⚠️ Partial: 9
  • ❌ Missing: 0
  • Total features: 46
Category Implemented Partial Missing Total
gates 10 0 0 10
scoring 7 0 0 7
v1.1_node 2 0 0 2
v1.1_edge 2 0 0 2
v1.1_action 0 2 0 2
v1.1_scoring 1 1 0 2
action_handler 0 6 0 6
gds_algorithm 5 0 0 5
research_pattern 10 0 0 10

See artifacts/coverage_report.md for full details.

Next Steps

All checks passed. Safe to merge.

@sonarqubecloud

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread .pre-commit-config.yaml
Comment on lines +46 to 50
entry: python3 tools/run_precommit_pytest_unit.py
language: system
pass_filenames: false
always_run: true
types: [python]
pass_filenames: true
stages: [pre-commit]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +67 to +71
candidates = [
f"tests/unit/test_{stem}.py",
f"tests/unit/test_{parent}_{stem}.py",
f"tests/unit/test_{parent}.py",
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@cryptoxdog
cryptoxdog merged commit d42f81d into main Aug 22, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant