Skip to content

Configure pre-commit CI#16866

Merged
seanbudd merged 16 commits intomasterfrom
applyPreCommit
Aug 1, 2024
Merged

Configure pre-commit CI#16866
seanbudd merged 16 commits intomasterfrom
applyPreCommit

Conversation

@seanbudd
Copy link
Copy Markdown
Member

@seanbudd seanbudd commented Jul 16, 2024

Link to issue number:

Part of #10516

Summary of the issue:

As a developer, I would like automation tools to fix the lint of my code when I open a PR.
After #16936, we have applied pre-commit on all files. However, there are no automation checks for some of these checks (like whitespaces changes). Which means without running pre-commit automatically, the repository may have pre-commit regressions.

Description of user facing changes

Improved documentation for pre-commit hooks and the PR contribution process.

Description of development approach

Setup Pre-commit CI. This is a CI/CD tool to automatically apply pre-commit to PRs.

Testing strategy:

Confirm build succeeds.
Ensure failures from AppVeyor (e.g lint failures) are caught by pre-commit.

Known issues with pull request:

None

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Summary by CodeRabbit

  • New Features

    • Introduced a Continuous Integration (CI) configuration for pre-commit hooks, allowing for task skipping and submodule support.
    • Added a new section on "Status checks" in the README to display real-time build status badges.
  • Documentation

    • Restructured contributing guidelines for pull requests, clarifying the submission process and CI/CD testing.
    • Enhanced instructions for setting up pre-commit hooks, including a new section on manually running hooks.

@seanbudd seanbudd changed the title Apply pre commit Apply pre commit automatically to PRs Jul 16, 2024
@LeonarddeR
Copy link
Copy Markdown
Collaborator

Ugh, I now realize that having #16868 run scons source will do bad things to this. What do you think? May be we can exclude that hook?

@seanbudd
Copy link
Copy Markdown
Member Author

@LeonarddeR - I think we will have the same problem for scons checkPot too, I imagine we need to set up visual studio build tools before we can run these checks. I think we will have to exclude checkPot, and scons source for now. Perhaps also unit tests.

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Jul 30, 2024
@seanbudd seanbudd changed the title Apply pre commit automatically to PRs Configure pre-commit CI Aug 1, 2024
@seanbudd seanbudd marked this pull request as ready for review August 1, 2024 01:22
@seanbudd seanbudd requested review from a team as code owners August 1, 2024 01:22
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 1, 2024

Walkthrough

The recent updates enhance the NVDA project's development workflow by introducing a Continuous Integration (CI) configuration in the .pre-commit-config.yaml file, restructuring the contributing documentation, and improving guidance on using pre-commit hooks. Additionally, a new "Status checks" section in the readme.md provides real-time build status badges, improving visibility of the project's health and aiding contributors in monitoring code quality and security.

Changes

Files Change Summary
.pre-commit-config.yaml Added a new CI configuration section, including parameters to skip specific tasks, enable submodules, and set commit messages for auto-updates and autofixes.
projectDocs/dev/contributing.md Restructured guide for creating pull requests, breaking down the process into clear sections and providing detailed instructions, including CI/CD testing guidance.
projectDocs/testing/automated.md Enhanced pre-commit hook setup instructions, including a hyperlink for setup and a new section on manually running hooks with specific commands.
readme.md Introduced a "Status checks" section with badges displaying real-time build statuses for better project monitoring.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
projectDocs/dev/contributing.md (1)

47-47: Consider adding a comma for clarity.

A comma would improve the readability of the sentence.

		- [Template guide](./githubPullRequestTemplateExplanationAndExamples.md),
Tools
LanguageTool

[typographical] ~47-~47: Consider adding a comma here.
Context: ...ng out the template: - Template guide - Please fill out the Pull Request template, inc...

(PLEASE_COMMA)

Comment thread .pre-commit-config.yaml
Comment thread readme.md Outdated
Comment thread readme.md Outdated
@seanbudd seanbudd merged commit 47695ac into master Aug 1, 2024
@seanbudd seanbudd deleted the applyPreCommit branch August 1, 2024 06:24
Comment thread .pre-commit-config.yaml
Comment on lines +10 to +11
autoupdate_commit_msg: "Pre-commit autoupdate"
autofix_commit_msg: "Pre-commit autofix"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
autoupdate_commit_msg: "Pre-commit autoupdate"
autofix_commit_msg: "Pre-commit autofix"
autoupdate_commit_msg: "Pre-commit automatic update"
autofix_commit_msg: "Pre-commit automatic fix"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Could you open a small PR to fix this up. Maybe auto-fix and auto-update instead?

Comment thread .pre-commit-config.yaml
hooks:
# Checks python syntax
- id: check-ast
# File uses encoding not supported in Linux
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ugh, I actually believe that comtypes should consider to fix this, enforcing UTF-8 for their generated modules. I filed enthought/comtypes#592

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks agreed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Perhaps we should also consider adding encoding checks to pre-commit?

@LeonarddeR
Copy link
Copy Markdown
Collaborator

Oops, too late 😉

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

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants