-
Notifications
You must be signed in to change notification settings - Fork 430
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
Improve pre-commit UX #5320
Improve pre-commit UX #5320
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5320 +/- ##
=======================================
Coverage 52.52% 52.52%
=======================================
Files 272 272
Lines 29422 29422
=======================================
Hits 15455 15455
Misses 13168 13168
Partials 799 799 ☔ View full report in Codecov by Sentry. |
This commit adds default stages and default install hook types to the pre-commit configuration. In addition, it adds the stages in which certain hooks should be run. Signed-off-by: Bryan Cox <[email protected]>
.pre-commit-config.yaml
Outdated
- repo: local | ||
hooks: | ||
- id: make-verify | ||
name: Run make verify | ||
entry: make verify | ||
language: system | ||
stages: [pre-push] |
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.
Do you think we can add a reference to Makefile's verify
target in here or put up a comment?
A disclaimer saying that make verify is going to invoke a bunch of targets like
verify-boilerplate verify-modules verify-gen verify-shellcheck verify-conversions verify-tiltfile verify-codespell
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.
Yeah we could use https://pre-commit.com/#hooks-description
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.
Great! Let's add some text in here, as a disclaimer, make verify will run verify-boilerplate verify-modules verify-gen verify-shellcheck verify-conversions verify-tiltfile verify-codespell
all these targets.
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.
Sorry for the churn.
I see that boilerplate
check is already run as a separate hook up above.
Do you think it would be beneficial to run these verify
targets individually as separate hooks and drop redundant hooks like boilerplate and spellcheck ?
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 see merit in either approach. Though I would lean to running the targets individually because then you can see them running one by one in a terminal rather than just one block you're waiting to finish on. Which option would you prefer?
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.
Running them individually as separate hooks at pre-push stage sounds great to me.
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.
PR is updated. I think it looks better with each one -
% git push -f
Run make verify-modules..................................................Passed
Run make verify-gen......................................................Passed
Run make verify-shellcheck...............................................Passed
Run make verify-conversions..............................................Passed
Run make verify-tiltfile.................................................Passed
Run make test............................................................Passed
Enumerating objects: 5, done.
...
FWIW, the verify-gen
took a similar amount of time as test
so maybe test
doesn't need broken up? 🤷🏻♂️
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.
Thank you for pointing this out.
Both verify-gen
and test
seem to be running generate
as a pre-req.
So maybe we don't break test
target for backwards compatibility in CI and replace make test
in pre-commit config with make go-test-race
.
We can follow this up in another PR, non blocking comment.
.pre-commit-config.yaml
Outdated
- repo: local | ||
hooks: | ||
- id: make-test | ||
name: Run make test | ||
entry: make test | ||
language: system | ||
stages: [pre-push] |
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.
Same thought here. make test
atm seems to be running generate
as well. Ref:
cluster-api-provider-azure/Makefile
Line 701 in 1275143
test: generate go-test-race ## Run "generate" and "go-test-race" rules. |
In my experience, make generate
takes a lot of time to finish.
- I wonder if we can drop
generate
as a dependency? Or - Maybe come up with a new make target that runs UT exclusively ? i.e. runs
make go-test-race
. So essentially we runmake go-test-race
in this hook. Although I have not tested the side affects of runningmake go-test-race
by itself.
However, this comment can be a followed up another issue-PR.
This commit adds the same checks run in `make verify` without duplicating any previous hook runs in pre-commit to the pre-commit configuration. In addition, this commit adds `make test` to the pre-push stage of the pre-commit configuration. This will ensure `verify` and `test` are successfully passing before the commit is pushed. This will help reduce time and test resources by preventing `verify` and `test` from failing on the pull request in GitHub. Signed-off-by: Bryan Cox <[email protected]>
name: Run make verify-shellcheck | ||
entry: make verify-shellcheck | ||
language: system | ||
stages: [ pre-push ] |
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 am not sure if [ pre-push ]
is any different to [pre-push]
(extra space padding being added to pre-push
string).
Could please paste sample output of using this .pre-commit.config
in the PR description or as a comment?
This looks great to me btw!
/lgtm
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 added some example output to the PR description
LGTM label has been added. Git tree hash: df5e05410858492f9c3645ae91eeb71eb67d9e8b
|
You might wanna see this too, Matt :) |
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.
/lgtm
/approve
Thanks!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mboersma The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR improves the user experience of pre-commit by:
make verify
andmake test
to the pre-push stageExample output:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #5318
Special notes for your reviewer:
TODOs:
Release note:
/assign @nawazkh