Skip to content

Add GitHub Action to run pre-commit #114

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

Merged
merged 3 commits into from
Oct 3, 2024
Merged

Add GitHub Action to run pre-commit #114

merged 3 commits into from
Oct 3, 2024

Conversation

yu-iskw
Copy link
Owner

@yu-iskw yu-iskw commented Oct 3, 2024

PR Type

enhancement, configuration changes


Description

  • Added a new GitHub Action workflow to run pre-commit checks on pull requests and pushes to the main branch.
  • Configured the new workflow to use the latest versions of actions for checkout, setup-python, and pre-commit.
  • Removed the linting step from the existing test workflow to streamline the testing process.

Changes walkthrough 📝

Relevant files
Enhancement
lint.yml
Add GitHub Action for pre-commit checks                                   

.github/workflows/lint.yml

  • Added a new GitHub Action workflow named Run pre-commit.
  • Configured the workflow to trigger on pull requests and pushes to the
    main branch.
  • Set up jobs to run on ubuntu-latest with steps to checkout code, set
    up Python, and use pre-commit.
  • +15/-0   
    Configuration changes
    test.yml
    Remove linting step from test workflow                                     

    .github/workflows/test.yml

  • Removed the linting step from the test workflow.
  • Simplified the workflow by focusing on testing steps.
  • +0/-3     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    coderabbitai bot commented Oct 3, 2024

    Important

    Review skipped

    Review was skipped due to path filters

    ⛔ Files ignored due to path filters (2)
    • .github/workflows/lint.yml is excluded by !**/*.yml
    • .github/workflows/test.yml is excluded by !**/*.yml

    CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


    Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

    ❤️ 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.
      • Generate unit testing code for this file.
      • 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 generate unit testing code for this file.
      • @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 generate unit testing code.
      • @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.

    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 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.

    Copy link

    qodo-merge-pro bot commented Oct 3, 2024

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    CI Failure Feedback 🧐

    Action: test (3.8)

    Failed stage: Install Flit [❌]

    Failure summary:

    The action failed due to a dependency resolution issue:

  • The required package pre-commit with version constraints <4.0.0,>=3.8.0 could not be found for the current
    Python version.
  • The available versions of pre-commit require Python version >=3.9, but the action is using Python
    3.8.18.
  • This mismatch led to a subprocess.CalledProcessError when attempting to install the dependencies,
    causing the process to exit with a non-zero status.

  • Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    198:  Installing build dependencies: started
    199:  Installing build dependencies: finished with status 'done'
    200:  Getting requirements to build wheel: started
    201:  Getting requirements to build wheel: finished with status 'done'
    202:  Installing backend dependencies: started
    203:  Installing backend dependencies: finished with status 'done'
    204:  Preparing metadata (pyproject.toml): started
    205:  Preparing metadata (pyproject.toml): finished with status 'done'
    206:  ERROR: Ignored the following versions that require a different python version: 0.11.1 Requires-Python >=3.9; 3.6.0 Requires-Python >=3.9; 3.6.1 Requires-Python >=3.9; 3.6.2 Requires-Python >=3.9; 3.7.0 Requires-Python >=3.9; 3.7.1 Requires-Python >=3.9; 3.8.0 Requires-Python >=3.9
    207:  ERROR: Could not find a version that satisfies the requirement pre-commit<4.0.0,>=3.8.0 (from versions: 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.6, 0.2.7, 0.2.8, 0.2.9, 0.2.10, 0.2.11, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.6.6, 0.6.7, 0.6.8, 0.7.0, 0.7.1, 0.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ERROR: No matching distribution found for pre-commit<4.0.0,>=3.8.0
    ...
    
    213:  installer.install()
    214:  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/flit/install.py", line 430, in install
    215:  self.install_directly()
    216:  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/flit/install.py", line 310, in install_directly
    217:  self.install_requirements()
    218:  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/flit/install.py", line 263, in install_requirements
    219:  check_call(cmd)
    220:  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/subprocess.py", line 364, in check_call
    221:  raise CalledProcessError(retcode, cmd)
    222:  subprocess.CalledProcessError: Command '['/opt/hostedtoolcache/Python/3.8.18/x64/bin/python', '-m', 'pip', 'install', '-r', '/tmp/tmpvv6fbo__requirements.txt']' returned non-zero exit status 1.
    223:  ##[error]Process completed with exit code 1.
    

    ✨ CI feedback usage guide:

    The CI feedback tool (/checks) automatically triggers when a PR has a failed check.
    The tool analyzes the failed checks and provides several feedbacks:

    • Failed stage
    • Failed test name
    • Failure summary
    • Relevant error logs

    In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:

    /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"
    

    where {repo_name} is the name of the repository, {run_number} is the run number of the failed check, and {job_number} is the job number of the failed check.

    Configuration options

    • enable_auto_checks_feedback - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
    • excluded_checks_list - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
    • enable_help_text - if set to true, the tool will provide a help message with the feedback. Default is true.
    • persistent_comment - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.
    • final_update_message - if persistent_comment is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true.

    See more information about the checks tool in the docs.

    @yu-iskw yu-iskw marked this pull request as ready for review October 3, 2024 23:50
    @yu-iskw yu-iskw merged commit c264201 into main Oct 3, 2024
    6 checks passed
    @yu-iskw yu-iskw deleted the modify-actions branch October 3, 2024 23:50
    Copy link

    qodo-merge-pro bot commented Oct 3, 2024

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Version Pinning
    The GitHub Actions used in the workflow are not pinned to specific versions, which may lead to unexpected behavior if the actions are updated.

    Removed Linting
    The linting step has been removed from the test workflow. This might lead to code quality issues if linting is not performed elsewhere.

    Copy link

    qodo-merge-pro bot commented Oct 3, 2024

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Performance
    Add caching for pre-commit dependencies to improve workflow execution time

    Consider adding a step to cache the pre-commit dependencies. This can significantly
    speed up subsequent runs of the workflow. You can use the actions/cache action to
    cache the pre-commit environment.

    .github/workflows/lint.yml [9-15]

     jobs:
       pre-commit:
         runs-on: ubuntu-latest
         steps:
         - uses: actions/checkout@v4
         - uses: actions/setup-python@v5
    +    - uses: actions/cache@v3
    +      with:
    +        path: ~/.cache/pre-commit
    +        key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
         - uses: pre-commit/[email protected]
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Caching pre-commit dependencies can significantly reduce workflow execution time, making this a valuable performance enhancement. The suggestion is accurate and directly applicable to the PR.

    8
    Best practice
    Specify a Python version when setting up the Python environment

    It's a good practice to specify a Python version when setting up Python in a GitHub
    Actions workflow. This ensures consistency across different environments and makes
    the workflow more reproducible.

    .github/workflows/lint.yml [14]

     - uses: actions/setup-python@v5
    +  with:
    +    python-version: '3.x'
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Specifying a Python version ensures consistency and reproducibility across environments, which is a best practice. This suggestion improves the robustness of the workflow.

    7
    Enhancement
    Add a step to display the pre-commit version for improved debugging and transparency

    Consider adding a step to display the pre-commit version being used. This can be
    helpful for debugging and ensuring the correct version is being used across
    different environments.

    .github/workflows/lint.yml [15]

    +- name: Display pre-commit version
    +  run: pre-commit --version
     - uses: pre-commit/[email protected]
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: Displaying the pre-commit version can aid in debugging and ensure transparency. While not critical, it enhances the workflow's clarity and maintainability.

    6

    💡 Need additional feedback ? start a PR chat

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant