chore: Add pre-push hook to run clippy #1400
No reviewers
Labels
No labels
Blocked
Bug
Cherry-picking
Database
Dependencies
Dependencies/Renovate
Difficulty
Easy
Difficulty
Hard
Difficulty
Medium
Documentation
Enhancement
Good first issue
Help wanted
Inherited
Matrix/Administration
Matrix/Appservices
Matrix/Auth
Matrix/Client
Matrix/Core
Matrix/E2EE
Matrix/Federation
Matrix/Hydra
Matrix/MSC
Matrix/Media
Matrix/T&S
Meta
Meta/CI
Meta/Packaging
Priority
Blocking
Priority
High
Priority
Low
Security
Status
Confirmed
Status
Duplicate
Status
Invalid
Status
Needs Investigation
Support
To-Merge
Wont fix
old/ci/cd
old/rust
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
continuwuation/continuwuity!1400
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "trashpanda/continuwuity:trashpanda/commit-clippy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This pull request forces clippy to run on every push and deny any warnings that are emitted, ensuring the author fixes any lints before pushing.
Pull request checklist:
mainbranch, and the branch is named something other thanmain.myself, if applicable. This includes ensuring code compiles.
While this seems worthwhile for contributors getting into the Rust code, and would technically help save a bit of CI resources if the corresponding CI workflow were removed at the same time, this would seem to imply a required clippy run even for docs-only changes (as well as any other change not directly impacting the Rust source). Is that interpretation correct?
Yes, this would run clippy even for docs-only changes. It seems that prefligit isn't able to detect changed files from unpushed commits, or I could not find any feature that would allow that, and it would skip the clippy run.
could you also add
pkgs.clippyto the shell.nix, so people who use the devshell can run this too <3@ -48,0 +57,4 @@thencargo +nightly clippy -- -D warnings;fi'This could (and probably should?) just be a separate file, but this also does work.
My one concern is this slows down a traditionally light-weight commit hook that was more geared toward formatting and light-weight checks than heavy-duty rust compilation and related linting/test execution.
If this made it in, I would probably disable it then tell git to ignore index changes to that file so I wouldn't have to re-commit my light-weight version, since I typically want to run them separately, in isolation, not monolithically.
@gamesguru wrote in #1400 (comment):
This hook is only run before pushing to the server, and afaict is the only hook that will run in that stage anyways.
@ -48,0 +52,4 @@- id: cargo-clippyname: cargo clippyentry: >sh -c 'Doesn't pre-commit have a built in way to say 'only run this on
rsfiles?Yes, but it didn't appear to be working during the pre-push hook in my testing with prefligit.
a proof of concept of the pre-push hook not running:
I'm not sure what's up with that then - mayve always_run shoudn't be set?
triggers correctly at least?
I'll have a check when I have time
I'm thinking it has to do with the stage it runs in. The clippy hook I added is run in the pre-push stage, after all files have been committed. The hook was working when it was a pre-commit hook.
Ah, that would make a lot of sense.
I can't reproduce this with prek or pre-commit:
(on macos)
Likely a bug upstream?
I'll dig into this tonight. I haven't tried the original pre-commit, it may just be that prefligit has some obscure bug on Linux or even something to do with my system configuration.
@trashpanda wrote in #1400 (comment):
fair then, apologies for the misunderstanding.
just wanted to make sure anything "heavy" pre-commit had a clear way to opt-out of or disable if needed. Carry on
Anything I can clear up to help this get merged?
The only thing would be that we use the default clippy toolchain to avoid cache thrashing, but it's not merged yet becaues we haven't done a merge run yet. Don't sweat 😅
8f6070df1fe061abc431