-
Notifications
You must be signed in to change notification settings - Fork 967
pre-commit hooks demo
#8193
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
base: master
Are you sure you want to change the base?
pre-commit hooks demo
#8193
Conversation
55bb20c to
532d4a9
Compare
|
@s373nZ hi! noting your recent reference to this PR.... do you plan on returning to this PR anytime soon? I'm doing some spring cleaning of our open PRs |
532d4a9 to
69c9df7
Compare
|
Hi @madelinevibes! 👋 Updated this by rebasing against Marking this ready for review and removing the |
|
Hey! Thank you for this awesome PR! I had been running this heavily vibecoded (and very verbose) precommit hook to fix up my nits but this looks very neat and tidy! The repos used for the most part also seem reliable and maintained. I would also add whitespace fixing and flake8 fixing in this PR as well, I find that most of the time my prebuild checks fail because of whitespace and flake8 errors :( |
| connectd | ||
| crate | ||
| mut |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a comprehensive list based on what's triggered by codespell? Does this also run on all files, or all C files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a comprehensive list based on what's triggered by codespell?
Not by any means. This is just demo of how to add words to the ignore list. Attached is recent output for pre-commit run --all-files codespell > codespell.txt
I suggest going through these items to decide which typos to fix versus which to add to the ignore list is worth a separate PR?
Does this also run on all files, or all C files?
This runs on all files submitted with the changeset (during a commit) and all files in total when using pre-commit run --all-files. The mut in the ignore list is actually for Rust code.
.pre-commit-config.yaml
Outdated
| - refactor | ||
| - perf | ||
| - test | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You maybe able to use https://github.com/hhatto/autopep8 and https://github.com/PyCQA/flake8 for python style fixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intentionally didn't include flake8 due to this discussion: #7884 (comment)
I can add it and/or autopep8 in if you require in order to accept this work. Just LMK! :)
|
Also, have you checked how long it takes to run this? Just wondering because we're making a fair few external requests. |
69c9df7 to
1929a12
Compare
|
Rebased against
First run ALL FILES (fresh install): Regular run ALL FILES: Regular run on Regular run on During a commit, |
|
It's always good to have an opinionated list. The downside is, we might all disagree with that list! In particular, the conventionalcommits.org is crap. I hate "chore:" as a prefix. It's non-informative. Prefixes should refer to subsystems, e.g:
If there's no logical subsystem, I sometimes omit it, and sometimes use "global". But usually I talk about what system, or subdaemon, or plugin is hit (even if, as a side effect, other code needs to be adapted!). |
|
Will this be integrated into the CI, or is it intended only for local testing? My local run is currently failing on almost all steps :(. |
Reimplements `make check-amount-access` for Python regex.
Reimplements `make check-discouraged-functions` for Python regex.
Includes default config file and an initial word list to ignore.
A helper tool to fix code style errors using `ruff` and `clang-format` and correct spelling.
1929a12 to
2a39948
Compare
@rustyrussell this list was a best-guess demo derived by scanning a few pages of the commit history in April and configuring based on observed conventions.
Noted, and removed it as a commit linter. The prior configuration should have required
If the team wanted to formalize conventions for commit messages and add them to the developer documentation, it may be possible to leverage the Conventional Commit hook to enforce it. Although, it might not make sense to bend that tool too far and consider a customized implementation.
@ShahanaFarooqui Definitely not ready for CI yet, IMO. An idea for a "mini road map" toward this might be something like:
I would be interested / curious to help out with the follow ups in |
This PR expands upon #7884 to demo some potential DX improvements through adding pre-commit hooks. It contains the following features:
shellcheck.make check-amount-accessas a local pygrep hook.Implements a clang-format hook to fail on suggestion warnings with additional configuration to sort includes.make check-discouraged-functionsas a local pygrep hook.codespellto check for common spelling errors.doc/directory.JSONschemasChecks Git commit message conforms to Conventional Commits standard, using a best-guess prototype for the list of application scopes.Many of these experiments output a lot of errors/warnings against the existing code. Generally,
pre-commitshould be only checking the current changeset and provoking the developer to address issues incrementally. Interested parties can run specific hooks on the entire codebase withpre-commit run --all-files [hook-id]Particular checks and standards may not be applicable or aligned with the workflow of the maintainers. I'd be happy and interested to break this work into separate PRs for specific hooks where there is interest, or explore adding more.
Relates to #7765.
Checklist
Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:
Changelog-None