Skip to content

Create pre-commit.yml action#7

Merged
Timik232 merged 6 commits into
mainfrom
Timik232-patch-1
Jun 30, 2025
Merged

Create pre-commit.yml action#7
Timik232 merged 6 commits into
mainfrom
Timik232-patch-1

Conversation

@Timik232

@Timik232 Timik232 commented Jun 26, 2025

Copy link
Copy Markdown
Owner

Github action for pre-commit

Summary by CodeRabbit

  • Chores
    • Introduced automated code linting and formatting checks on every push or pull request to the main branch.
    • Updated pre-commit configuration to check for accidentally added large files.

Github action for pre-commit
@Timik232
Timik232 requested a review from Copilot June 26, 2025 12:25
@Timik232 Timik232 self-assigned this Jun 26, 2025
@coderabbitai

coderabbitai Bot commented Jun 26, 2025

Copy link
Copy Markdown
Contributor

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 479c77c and 20a567f.

📒 Files selected for processing (1)
  • .github/workflows/pre-commit.yml (1 hunks)

Walkthrough

A 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

File(s) Change Summary
.github/workflows/pre-commit.yml Added a GitHub Actions workflow to automate pre-commit linting checks.
.pre-commit-config.yaml Added the check-added-large-files hook to the pre-commit configuration.

Poem

In the warren, code hops neat and tight,
Pre-commit checks keep it just right.
Large files beware, you shan't sneak through,
Linting on pushes and PRs too!
With every commit, we leap ahead—
Clean code, happy tails, enough said.
🐇✨


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.yml workflow
  • Sets up Python, installs pre-commit, and runs all hooks against every file
  • Triggers on both push and pull_request events for the main branch
Comments suppressed due to low confidence (3)

.github/workflows/pre-commit.yml:15

  • Consider adding fetch-depth: 0 to 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-files ensures existing files are linted in addition to those changed in this run.
          extra_args: --all-files

Comment thread .github/workflows/pre-commit.yml Outdated
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit

Copilot AI Jun 26, 2025

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
.github/workflows/pre-commit.yml (1)

13-14: Add caching for pip & pre-commit virtualenvs

A 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-files defaults to 500 KB.
In a repo that contains model checkpoints, datasets, or other legitimately large binary artifacts you may want either:

  1. Exclude specific patterns:
- id: check-added-large-files
  exclude: '^models/|\.bin$'
  1. Or raise the limit:
- id: check-added-large-files
  args: [--maxkb, 2048]   # 2 MB

Without 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 PRs

Running pre-commit with --all-files can 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

📥 Commits

Reviewing files that changed from the base of the PR and between dbd74c3 and 81bef95.

📒 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)

Comment thread .github/workflows/pre-commit.yml Outdated
Comment thread .github/workflows/pre-commit.yml Outdated
Timik232 and others added 4 commits June 30, 2025 16:21
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Remove checking all files
@Timik232
Timik232 merged commit 2df708b into main Jun 30, 2025
1 of 2 checks passed
@Timik232
Timik232 deleted the Timik232-patch-1 branch June 30, 2025 13:33
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.

2 participants