-
Notifications
You must be signed in to change notification settings - Fork 34
Use Pre-Commit in CI #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Pre-Commit in CI #159
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughReplaces matrix/concurrency CI lint workflow with a single ubuntu-latest job running pre-commit; pins Changes
Sequence Diagram(s)sequenceDiagram
actor Developer
participant GHA as GitHub Actions
participant Runner as CI Runner
participant PC as Pre-commit
participant Hooks as Hook Tools
Developer->>GHA: Push / Open PR
GHA->>Runner: Start job (ubuntu-latest)
Runner->>Runner: Checkout code
Runner->>Runner: Setup Python 3.11
Runner->>Runner: pip install --upgrade pip pre-commit
Runner->>PC: Run pre-commit --all-files --show-diff-on-failure
activate PC
PC->>Hooks: Invoke configured hooks (reuse, formatters, linters)
activate Hooks
Hooks-->>PC: Return results (pass/fail, diffs)
deactivate Hooks
PC-->>Runner: Exit status and diffs
deactivate PC
Runner->>Runner: git status (debug)
alt All hooks pass
Runner-->>GHA: Job succeeds
GHA-->>Developer: CI success
else Hooks found issues
Runner-->>GHA: Job fails with diff output
GHA-->>Developer: CI failed (diff)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
diaconuccalin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The branch needs to be rebased to the newest devel. Otherwise, LGTM, useful little feature, thanks!
2cfc54f to
a89d008
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/ci-lint.yml:
- Around line 28-30: Replace the workflow step referencing "uses:
actions/setup-python@v4" with the v5 version: update the action invocation to
"actions/setup-python@v5" so the workflow uses Node.js 20; locate the step that
currently says uses: actions/setup-python@v4 in the CI workflow and change it to
`@v5`, then run or validate the workflow lint to ensure no other inputs need
adjustment for the newer action.
🧹 Nitpick comments (2)
.github/workflows/ci-lint.yml (2)
25-25:fetch-depth: 0is unnecessary forpre-commit run --all-files.Pre-commit with
--all-filesoperates on the working tree, not git history. A shallow clone (the defaultfetch-depth: 1) is sufficient and faster. Full history cloning adds CI time for no benefit here.Proposed fix
- name: Checkout Repo uses: actions/checkout@v4 - with: - fetch-depth: 0
32-35: Consider pinningpre-commitversion and caching hook environments.Neither the
pre-commitCLI version nor the hook virtual environments are pinned or cached. This can cause non-reproducible CI runs and slower execution.Example: pin version and add caching
- name: Install dependencies run: | python -m pip install --upgrade pip - pip install pre-commit + pip install pre-commit==4.1.0 + - name: Cache pre-commit hooks + uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
Victor-Jung
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just one small question for you.
- Switch CI to use pre-commit for linting - Add missing dependency in pre-commit-config - Update contributing guide - Adjust Make targets
a89d008 to
4f84f8f
Compare
4f84f8f to
0dee58a
Compare
This PR unifies the linting and formatting with
pre-commit. Before, we used a mixture ofpre-commitand custom-installed tools. However, this could lead to version inconsistencies between different users and the CI.I suggest to only look at 563138b. The other commit just reformatted all the files.
Changed
Fixed
PR Merge Checklist
develcommit and pointing todevel.CHANGELOG.mdfile has been updated.