Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

workflows: Run clippy during CI #40

Merged
merged 8 commits into from
Oct 13, 2020
Merged

workflows: Run clippy during CI #40

merged 8 commits into from
Oct 13, 2020

Conversation

yuriks
Copy link
Contributor

@yuriks yuriks commented Oct 6, 2020

I recommend reviewing commits individually.

This PR fixes or silences all the outstanding clippy lints in the default configuration, and enable clippy to run as a GitHub action. This also includes a few other unrelated cleanups I spotted along the way.

One trade-off here is that I configured clippy to run as part of our existing "build" job (just like the cargo fmt check currently does). This is nice in that is re-uses the compilation cache that clippy generates (since it needs to actually do full type-checking with the compiler to work, it just doesn't do any codegen), but it also means that a clippy failure will abort the job before it attempts to do an actual compile. While clippy does report most error that the compiler itself does, it does miss a few things checked by the compiler in later stages. In this case the PR author would need to a edit-push-wait for CI cycle before the other errors will be surfaced by CI.

To fix this we could either:

  • Move clippy (and probably also fmt) to its own dedicated job, which would run in parallel with the build job. This uses more CI resources since it's essentially compiling things twice, but makes the two jobs fail independently.
  • Modify the workflows definition file so that it continues executing later steps even if the clippy step fails. This however complicates the workflow definition since GitHub doesn't seem to support this use case well. (You need to insert explicit if: conditions on every single later build step.)

If anyone thinks it would be worth it, I can implement either of these options and update the PR.

@yuriks yuriks requested a review from tgeoghegan October 6, 2020 21:46
@yuriks yuriks marked this pull request as draft October 6, 2020 21:53
@yuriks yuriks force-pushed the yuriks/ci-clippy branch 2 times, most recently from db12042 to 569633a Compare October 6, 2020 22:40
This is already done for some imports but not all. Run rustfmt with the
`merge_imports`[1] option to uniformize them. Unfortunately this option
is only available in nightly right now so it can't be added to
`rustfmt.toml` yet.

[1]: https://rust-lang.github.io/rustfmt/?version=master&search=nest#merge_imports
This is a grab-bag of minor fixes to address various different clippy
lints.
This trait was only used to add helper methods to BatchReader and
BatchWriter, however, it's clearer to just inline them into callers such
that there is only one constructor for BatchReader and BatchWriter.
Maybe this struct should be restructured to not have the `H` and `P`
parameters, but in the meantime this avoids restricting variance and
tying them to the (unrelated) `'a` lifetime.

`PhantomData<*const T>` is used which doesn't imply any ownership of
data (unlike `T`) but also has no lifetimes associated with it (unlike
`&'a T`).
These are warnings that are annoying to fix without re-structuring the
existing code. Silence them so that we get a clean clippy output from
now on.
@yuriks yuriks marked this pull request as ready for review October 13, 2020 00:16
@yuriks yuriks requested review from tgeoghegan and removed request for tgeoghegan October 13, 2020 00:16
@yuriks yuriks merged commit 9a7ec3e into main Oct 13, 2020
@yuriks yuriks deleted the yuriks/ci-clippy branch October 13, 2020 01:42
@yuriks
Copy link
Contributor Author

yuriks commented Oct 13, 2020

Filed #48 to track future improvements to the GitHub Actions fail-fast behavior which I mentioned in the PR description.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants