Create pre-commit.yml action#7
Conversation
Github action for pre-commit
|
Warning Rate limit exceeded@Timik232 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 52 seconds before requesting another review. ⌛ 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. 📒 Files selected for processing (1)
WalkthroughA new GitHub Actions workflow was added to run pre-commit hooks on pushes and pull requests to the main branch. The pre-commit configuration was updated by adding a hook to check for large added files. No source code or exported entities were changed. Changes
Poem
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a GitHub Actions workflow to run pre-commit hooks on pushes and pull requests to the main branch.
- Adds a new
.github/workflows/pre-commit.ymlworkflow - Sets up Python, installs
pre-commit, and runs all hooks against every file - Triggers on both
pushandpull_requestevents for themainbranch
Comments suppressed due to low confidence (3)
.github/workflows/pre-commit.yml:15
- Consider adding
fetch-depth: 0to the checkout step so pre-commit hooks that rely on full Git history (e.g., detecting moved or renamed code) work correctly.
uses: actions/checkout@v3
.github/workflows/pre-commit.yml:28
- [nitpick] Consider pinning the action to a major version (e.g.,
pre-commit/action@v4) instead of a patch release to automatically get non-breaking updates.
uses: pre-commit/action@v4.3.0
.github/workflows/pre-commit.yml:30
- [nitpick] It may be helpful to add a comment explaining that
--all-filesensures existing files are linted in addition to those changed in this run.
extra_args: --all-files
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install pre-commit |
There was a problem hiding this comment.
Add a cache step using actions/cache@v3 for the pip cache (e.g., ~/.cache/pip) to speed up the dependency installation on subsequent runs.
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
.github/workflows/pre-commit.yml (1)
13-14: Add caching for pip & pre-commit virtualenvsA cache step cuts CI time by ~60 %. Example:
- name: Cache pip & pre-commit uses: actions/cache@v3 with: path: | ~/.cache/pip ~/.cache/pre-commit key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt', '.pre-commit-config.yaml') }}This mirrors the suggestion already raised in an earlier review.
🧹 Nitpick comments (2)
.pre-commit-config.yaml (1)
14-14: Consider tuning the large-file check
check-added-large-filesdefaults to500 KB.
In a repo that contains model checkpoints, datasets, or other legitimately large binary artifacts you may want either:
- Exclude specific patterns:
- id: check-added-large-files exclude: '^models/|\.bin$'
- Or raise the limit:
- id: check-added-large-files args: [--maxkb, 2048] # 2 MBWithout an exception the hook will block any commit that exceeds the default threshold.
Please verify the expected behaviour for your workflow..github/workflows/pre-commit.yml (1)
27-30: Minor: surface only staged changes on PRsRunning
pre-commitwith--all-filescan take noticeably longer on large repos.
Switching to the default behaviour (changed files only) keeps the feedback loop tight while still protecting main via branch protection.- with: - extra_args: --all-files + # omit extra_args to run on the diff only
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/pre-commit.yml(1 hunks).pre-commit-config.yaml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/pre-commit.yml
15-15: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
18-18: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Remove checking all files
Github action for pre-commit
Summary by CodeRabbit