-
Notifications
You must be signed in to change notification settings - Fork 183
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 CI job for linting using cargo clippy #161
Conversation
Pull Request Test Coverage Report for Build 3021ee7358159a3922b9b60b455243201b9ffbb8-PR-161
💛 - Coveralls |
Clippy found some problems. The check should fail, but it's still green. What are the HTML annotations? Is there a way to make those visible?
|
I added new changes to address Shane's comment about making the job fail on clippy warnings too (not just on errors). The changes made this PR now make the CI tests fail as expected until Shane's fix in #162 is merged. FYI: Sorry for force-pushing, I was trying to test changes to address Shane's comment on my personal fork and forgot that the branch is also connected to a PR. Afterwards, I still needed to add a workaround within the fix, and remembered to keep that a separate commit. |
I'm not sure what you meant by HTML annotations -- are you referring to the links within each of the warning messages? I don't know how to make those links' text clickable. The best I could do was to add a workaround in the latest commit so that you could have the warnings inserted into Github UI (via the Rust community-supported action) while still having the PR checks fail on warnings. |
.github/workflows/build-test.yml
Outdated
path: ~/.cargo/git | ||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }} | ||
|
||
- name: Cache cargo build |
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.
If you don't cache the cargo build, does that avoid the need for the cargo clean?
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.
Good catch -- without the caching step (which is restoring the cache at the beginning), cargo clippy doesn't need the cargo clean step in order to still fail on warnings. I updated accordingly. This holds true, at least on CI, because each Github Actions job is run on a fresh VM image. (Hence, the need to start off each job with actions/checkout@v2
to clone the repo in the job's VM.)
Rather than making a workaround to a deficiency in actions-rs (the lack of ability to make the check fail on warnings), should we consider fixing the problem upstream? It would help simplify our code, and then the whole ecosystem can benefit. I filed an issue: actions-rs/clippy-check#82 |
Gah, after doing some poking around, I discovered that the desired fix was already made in v1.0.2, and I was just using v1 like in the example docs. I set the version to v1.0.7 to get the latest, FWIW. The change seems to work in my test. I'll update the new upstream issue accordingly. |
Nice! I think the order of operations should be:
|
Now that #162 is merged, the clippy linter action passes. I rebased the branch locally against the latest from master and then did a push-force, so need another stamp on the PR. |
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.
Approved!
Nit: For the future, IMHO, if you're going to change history (rebase), you might as well squash while you're at it, if the intermediate commits aren't meaningful.
According to the landing page for this Github Action for Clippy, it will insert clippy warnings inline into your PR. In my test case, it appended a separate pseudo-job called "clippy" into the Github Actions UI page for the workflow run that also lists the warning.
Closes #98