zerocopy icon indicating copy to clipboard operation
zerocopy copied to clipboard

[ci.yml] Add clippy_check job

Open frazar opened this issue 3 years ago • 9 comments

Add a CI job to run the clippy linting software.

Fixes #49

frazar avatar Oct 11 '22 20:10 frazar

To test how this works when a clippy lint is triggered, I tried creating a dummy PR here that should trigger a clippy warning.

frazar avatar Oct 11 '22 20:10 frazar

Sure! I didn't realize that clippy warning could differ based on toolchain/target.

frazar avatar Oct 11 '22 21:10 frazar

Yeah, any code that is conditionally compiled, and possibly even code that isn't but whose behavior differs by platform (e.g., some clippy lints (like this one) make use of the word size on the platform).

joshlf avatar Oct 11 '22 21:10 joshlf

I think you can fix the current CI failures by invoking Clippy directly from the command line. It comes default with Rust installations now, so you don't need a separate action for it. All I did here was copy-paste the "Check" action and edit it to invoke clippy instead:

    - name: Check
      run: cargo +${{ matrix.channel }} clippy --target ${{ matrix.target }} --features "${{ matrix.features }}" --verbose

joshlf avatar Oct 14 '22 16:10 joshlf

Unfortunately, I didn't have much time to experiment with this. Surely your solution would be easier. I thought the GitHub Action could be more convenient since it can also show inline error messages like this:

Would that be desirable for you?

I think I'll have more time to work on this next week. If instead it's a priority for you, feel free to close this PR!

frazar avatar Oct 15 '22 06:10 frazar

Ah that looks really nice! Unfortunately, it looks like it won't work for people submitting PRs from forked repositories (which is basically everyone other than me). Also, since we're enforcing this (rather than just using Clippy lints as suggestions), hopefully most PRs won't have many if any lints, and so a nice UI isn't that important. I opened #69 to track making it easier to run all of our tests (including Clippy) locally.

Given those considerations, I think https://github.com/google/zerocopy/pull/51#issuecomment-1279193054 makes the most sense.

joshlf avatar Oct 16 '22 20:10 joshlf

Oh, I see! I didn't understand this limitation existed.. Trying now the changes you suggested.

frazar avatar Oct 17 '22 07:10 frazar

So, it seems like some clippy errors are triggered when the "alloc" features is enabled!

Can reproduce locally with:

$ cargo clippy --features "alloc"

frazar avatar Oct 17 '22 07:10 frazar

Ooops! I think I fixed the rest in #71 .

joshlf avatar Oct 17 '22 18:10 joshlf

Looks like you'll need to push again (and maybe even rebase on main?) to get the tests to run against #71. I am able to trigger the tests to re-run from the UI, but it looks like it's not including #71.

joshlf avatar Oct 17 '22 18:10 joshlf

Rebased and pushed. Looks good now!

frazar avatar Oct 17 '22 19:10 frazar