-
Notifications
You must be signed in to change notification settings - Fork 240
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
Add pre-commit
for Linting
#207
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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 have no objection to adding this, but should confirm with @slumber
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.
This workflow runs in parallel with the rest, so it doesn't serve as a shortcut to failure because there's no jobs dependencies, unlike in the main workflow.
which saves headaches
From my experience, precommit hooks are headaches. Any project I worked on stopped using it eventually. This one is implemented as a workflow, not as a githook, so setting it up with pip
is required because of non-trivial checks like protobuf files linter which will fail ci on your PR.
Obviously, I can follow this routine, it won't take more than couple minutes in total. But this is something I don't want to think about everytime I'm writing code.
- id: protolint | ||
- repo: local | ||
hooks: | ||
- id: cargo fmt |
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.
this job is present in the main workflow
- means it's done twice
- in fact, the main job can fail while this one succeeds, because they're not in sync.
- repo: https://github.com/yoheimuta/protolint | ||
rev: v0.50.2 # Select a release here like v0.44.0 | ||
hooks: | ||
- id: protolint |
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.
The workflow says there're no files to check.
Closing because this seems unwanted. Can be easily re-opened in the future if we want |
pre-commit
is a useful tool that automatically and universally enforces linting standards before each commit. It also lets us use the exact same automation for linting locally as in CI, which saves headaches.As a rule,
pre-commit
hooks should avoid compiling code or doing anything that risks a serious slowdown, which is why I omittedcargo check
andcargo clippy
from these checks; they make most sense left as-is, as separate CI jobs.I applied the lints I configured to the existing repo, which has unfortunately mostly generated small edits adding or removing spaces. Fortunately, this type of thing only has to happen once.
To set this up locally, you can run