Repository navigation
feat: extend pre-commit check with file-type coverage - #81
Conversation
check-precommit-sync now runs two checks: 1. Coverage: scans repo files with identify, finds which baseline hooks are needed based on file types, fails if any are missing from .pre-commit-config.yaml 2. Sync: existing check — configured hooks must match CI linters setup-runtimes installs pyyaml + identify when pre-commit is in linters. Also adds ruff back to baseline own config/lint since hooks/ now contains Python scripts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 077517fa6b
ℹ️ 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".
| print("::error::.pre-commit-config.yaml not found — required when pre-commit is in linters.") | ||
| sys.exit(1) | ||
| import yaml | ||
| from identify.identify import tags_from_path |
There was a problem hiding this comment.
Install check dependencies before running the sync action
🤖 [rubykatzen/baseline]: When pre-commit is in inputs.linters, .github/workflows/lint-shared.yml invokes check-precommit-sync before setup-runtimes, so this new top-level identify import runs before the pyyaml identify install added to setup-runtimes. On a clean runner without these Python packages, the action exits with ModuleNotFoundError before any sync check can run; install the dependencies in the check action itself or move runtime setup ahead of the check.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR extends the repository’s check-precommit-sync enforcement so it can validate not only that CI linters match .pre-commit-config.yaml (sync), but also that .pre-commit-config.yaml includes all baseline hooks relevant to file types present in the repo (coverage). It also updates baseline’s own linting inputs/config to account for Python hooks.
Changes:
- Add a “coverage” check to
hooks/check-precommit-sync.pyby scanning tracked files (git ls-files) and mapping them toidentifytags to determine which baseline hooks are required. - Update baseline’s
.pre-commit-config.yamland CIlint.ymlto includeruff. - Extend
setup-runtimesto treatpre-commitas a supported value and install Python deps (pyyaml,identify) whenpre-commitis enabled.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| hooks/check-precommit-sync.py | Adds coverage detection via identify + git ls-files, and reports missing/extra hooks plus sync mismatches. |
| .pre-commit-config.yaml | Enables the ruff baseline hook in baseline’s own pre-commit config. |
| .github/workflows/lint.yml | Adds ruff to baseline’s self-lint linters input list. |
| .github/actions/setup-runtimes/action.yml | Installs Python deps needed for the new coverage logic when pre-commit is included. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if: > | ||
| contains(inputs.linters, 'yamllint') || | ||
| contains(inputs.linters, 'pymarkdown') || | ||
| contains(inputs.linters, 'ruff') | ||
| contains(inputs.linters, 'ruff') || | ||
| contains(inputs.linters, 'pre-commit') |
| import yaml | ||
| from identify.identify import tags_from_path |
pyyaml and identify must be installed before the sync script runs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@copilot перепроверь коменты, зарезольвь исправленное |
🧠 [rubykatzen/baseline]: Both comments are now addressed:
|
7ce778c to
9dce051
Compare
Summary
Extends
check-precommit-syncwith a second check: coverage.Previously the script only verified that
.pre-commit-config.yamlhooks match CI linters (sync check). Now it also scans the repo's files using theidentifylibrary and verifies that every hook whose file type is present in the repo is actually configured.Two checks, one script:
git ls-files→identify.tags_from_path()→ needed hooks → must all be in.pre-commit-config.yaml.pre-commit-config.yamlhooks must matchinputs.lintersOther changes:
setup-runtimes: installspyyaml+identifywhenpre-commitis in linters.pre-commit-config.yaml/lint.yml: ruff added back —hooks/now contains Python scriptsNote
Same bootstrap caveat as #79: CI for this PR runs against
check-precommit-sync@v0.7(old version, sync-only). Will need to update thev0.7tag and cut a patch release after merge.