Skip to content
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

chore: configure pre-commit hooks for code formatting #103

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

muyihao
Copy link
Contributor

@muyihao muyihao commented Jul 28, 2024

Description

This PR introduces pre-commit hooks to ensure consistent code formatting for both Python and Rust codebases. The changes include:

  • Install pre-commit when using make setup.
  • Add pre-commit hooks for Python and Rust code formatting.

Related issues: #73

How are the changes test-covered

  • N/A
  • Automated tests (unit and/or integration tests)
  • Manual tests
    • Details are described below

@github-actions github-actions bot added dev-x Dev experience: code format, dev tooling, project management python Related to Python codebase labels Jul 28, 2024
@muyihao muyihao marked this pull request as ready for review July 28, 2024 12:04
@muyihao muyihao force-pushed the chore/add-pre-commit-hooks branch from 4a2919a to 9a95229 Compare July 28, 2024 13:22
- Install pre-commit when using make setup.
- Add pre-commit hooks for Python and Rust code formatting.
@muyihao muyihao force-pushed the chore/add-pre-commit-hooks branch from 9a95229 to 075a26e Compare July 28, 2024 14:16
@xushiyan xushiyan self-assigned this Aug 12, 2024
Comment on lines +33 to +34
pip install pre-commit
pre-commit install
Copy link
Member

Choose a reason for hiding this comment

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

this should be a devel dependency in pyproject.toml

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it!

entry: cargo fmt --all -- --check
language: system
types: [rust]
pass_filenames: false
Copy link
Member

Choose a reason for hiding this comment

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

can you add a section in the CONTRIBUTING.md to describe and explain what kind of pre-commit changes will be make once a developer configures this pre-commit hook.

- id: check-yaml
- id: check-json
- id: check-added-large-files
- id: check-merge-conflict
Copy link
Member

Choose a reason for hiding this comment

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

are these hooks fully compatible with what we are already formatting via github actions workflow and make check-python/check-rust commands? if not, we need to make them behave the same. And if possible, reuse the same make commands for reusability

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we remove the checks for YAML, JSON, and file validations compared to GitHub Actions? Alternatively, should we add corresponding configurations in GitHub Actions? And I attempted to utilize make check-python, but encountered an issue where mypy did not recognize the configuration from pyproject.toml, which block me reuse make commands。

Copy link

codecov bot commented Aug 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.42%. Comparing base (5bf117a) to head (576f04e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #103   +/-   ##
=======================================
  Coverage   87.42%   87.42%           
=======================================
  Files          14       14           
  Lines         700      700           
=======================================
  Hits          612      612           
  Misses         88       88           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xushiyan xushiyan added this to the release-0.3.0 milestone Sep 15, 2024
@xushiyan xushiyan linked an issue Nov 30, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-x Dev experience: code format, dev tooling, project management python Related to Python codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure pre commit hook to format code style
2 participants