fix: add pre-commit.ci configuration for automated linting#16
fix: add pre-commit.ci configuration for automated linting#16abhizipstack merged 2 commits intomainfrom
Conversation
Add ci section to .pre-commit-config.yaml: - Skip hooks that don't work in CI: no-commit-to-branch, mypy (system), protolint-docker, hadolint-docker - Enable autofix PRs - Set monthly autoupdate schedule After merging, enable pre-commit.ci at https://pre-commit.ci/ for this repo and add "pre-commit.ci - pr" as a required status check. Jira: OR-1356 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
| Filename | Overview |
|---|---|
| .pre-commit-config.yaml | Adds a ci: section for pre-commit.ci integration; skips three hooks with environment constraints (mypy, protolint-docker, hadolint-docker), but no-commit-to-branch is mentioned in the PR description as a skip candidate yet is absent from the list. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Developer pushes commit to PR branch] --> B[pre-commit.ci triggered]
B --> C{Run configured hooks}
C --> D[Skipped: mypy\nlanguage: system]
C --> E[Skipped: protolint-docker\nneeds Docker]
C --> F[Skipped: hadolint-docker\nneeds Docker]
C --> G[Run: all other hooks\nblack, isort, flake8, etc.]
G --> H{Hooks pass?}
H -- Yes --> I[CI check passes]
H -- No --> J[pre-commit.ci creates\nautofix commit to PR branch]
J --> K[no-commit-to-branch runs\nagainst PR branch, NOT main\nso it does NOT block]
K --> I
B2[autoupdate job - monthly] --> L[pre-commit.ci opens\nautoupdate PR against repo]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: .pre-commit-config.yaml
Line: 5-11
Comment:
**`no-commit-to-branch` omitted from skip list despite PR description**
The PR description explicitly lists `no-commit-to-branch` as a hook to skip (explaining that "CI auto-fix pushes to PR branches"), but it is absent from the `ci.skip` list.
In practice this may be harmless — pre-commit.ci's auto-fix commits target the PR branch, not `main`, so the hook (configured with `--branch main`) won't fire for those commits. However, if pre-commit.ci ever runs against a push directly to `main` (e.g. during the `autoupdate` workflow or admin pushes), it will fail. Whether that's intentional enforcement or an oversight is worth confirming, given the description says it should be skipped.
If the intent is to keep it active in CI (to catch direct pushes to `main`), update the PR description to remove it from the listed skips. If it should be skipped for consistency with the description, add it:
```suggestion
ci:
skip:
- no-commit-to-branch # Blocks CI auto-fix commits; auto-fix pushes to PR branches anyway
- mypy # Uses language: system, not available in pre-commit.ci sandbox
- protolint-docker # Needs Docker, not available in pre-commit.ci
- hadolint-docker # Needs Docker, not available in pre-commit.ci
autofix_prs: true
autoupdate_schedule: monthly
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "fix: remove no-commit-to-branch from ci ..." | Re-trigger Greptile
no-commit-to-branch only blocks commits to main — pre-commit.ci runs on PR branches so it passes naturally. Keep skip for hooks that genuinely need Docker or system Python. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
What
ciconfiguration section to.pre-commit-config.yamlto support pre-commit.ci integrationmypy,protolint-docker,hadolint-docker)Why
mypyuseslanguage: system(not available in CI sandbox), Docker-based hooks need Docker (unavailable in CI)How
ci:block to.pre-commit-config.yamlwithskip,autofix_prs: true, andautoupdate_schedule: monthlyCan this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
pre-commit.ci - pras a required status check in branch protectionScreenshots
N/A
Checklist