Skip to content
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

Make CI Clippy static analysis checks more robust #635

Merged
merged 3 commits into from
Jul 11, 2024

Conversation

AlexTMjugador
Copy link
Collaborator

I have identified two potential improvements for how we perform static analysis on our code in our CI pipeline:

  • The giraffate/clippy-action we currently use has not been updated to Node 20, and GitHub has repeatedly indicated that they will phase out actions that do not support the latest Node versions. Despite my efforts to help with the update by submitting a pull request upstream, it has been ignored for months despite its perceived ease of review, raising concerns about the ongoing maintenance of the action. This situation suggests we should explore alternative methods for integrating Clippy with GitHub's UI.
  • As evidenced by PR 632, thoroughly testing Rust crates for every possible feature combination is often overlooked due to the tedious nature of the task. Our current CI setup only checks two feature combinations, which is far from comprehensive.

To address the first improvement, these changes drop clippy-action entirely in favor of utilizing GitHub's native CodeQL SARIF (Static Analysis Results Interchange Format) file integration. Since Clippy cannot directly output lints in SARIF, clippy-sarif is used to convert Clippy's JSON output to SARIF. Additionally, sarif-fmt is added to turn SARIF into a human-friendly display format in the workflow run logs.

For the second improvement, let's use cargo hack with the --feature-powerset flag to run Clippy for every possible feature combination. This approach strikes a good balance between CI runtime and thoroughness, as the number of feature combinations grows superlinearly with the number of features: running cargo nextest for every powerset element would lead to excessively long CI times.

While at it, I have fixed the Clippy lints that were catched by the more exhaustive checks.

I have identified two potential improvements for how we perform static analysis
on our code in our CI pipeline:

- The `giraffate/clippy-action` we currently use has not been updated to Node
  20, and GitHub has repeatedly indicated that they will phase out actions that
  do not support the latest Node versions. Despite my efforts to help with the
  update by submitting a pull request upstream, it has been ignored for months
  despite its perceived ease of review, raising concerns about the ongoing
  maintenance of the action. This situation suggests we should explore
  alternative methods for integrating Clippy with GitHub's UI.
- As evidenced by PR 632, thoroughly testing Rust crates for every possible
  feature combination is often overlooked due to the tedious nature of the task.
  Our current CI setup only checks two feature combinations, which is far from
  comprehensive.

To address the first improvement, these changes drop `clippy-action` entirely in
favor of utilizing GitHub's native CodeQL SARIF (Static Analysis Results
Interchange Format) file integration. Since Clippy cannot directly output lints
in SARIF, `clippy-sarif` is used to convert Clippy's JSON output to SARIF.
Additionally, `sarif-fmt` is added to turn SARIF into a human-friendly display
format in the workflow run logs.

For the second improvement, let's use `cargo hack` with the `--feature-powerset`
flag to run Clippy for every possible feature combination. This approach strikes
a good balance between CI runtime and thoroughness, as the number of feature
combinations grows superlinearly with the number of features: running `cargo
nextest` for every powerset element would lead to excessively long CI times.
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@AlexTMjugador
Copy link
Collaborator Author

The bot comment above is expected due to the usage of GitHub's CodeQL SARIF integration. Please heed it accordingly before this PR is merged.

When Clippy finds lints, it already aborts the workflow. No double
failure is needed.
Copy link
Collaborator

@andrews05 andrews05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @AlexTMjugador! Running all feature combos should be a big help.

I was also thinking it might be good to use the GitHub arm runners for the arm linux builds now that they're generally available, is that something you would want to do?
[edit] Actually I may be wrong about this, it might only be available for teams and enterprises...

@AlexTMjugador
Copy link
Collaborator Author

[edit] Actually I may be wrong about this, it might only be available for teams and enterprises...

Indeed, that's sadly the case at the moment. However, in the blog post I link to GitHub said that it expects to "begin offering Arm runners for open source and personal accounts by the end of the year", so if all goes according to plan we can get rid of QEMU soon enough 😄

@andrews05
Copy link
Collaborator

Yeah, sounds good! Let's go ahead and merge this.
We've had a few bug fixes, do you think we should do a 9.1.2 release?

@andrews05 andrews05 merged commit 664b27c into master Jul 11, 2024
13 checks passed
@AlexTMjugador AlexTMjugador deleted the ci/better-static-analysis branch July 11, 2024 08:41
@AlexTMjugador
Copy link
Collaborator Author

We've had a few bug fixes, do you think we should do a 9.1.2 release?

Yeah, I deem the current mainline stable enough and those bugfixes may indeed come in handy. Let's do it!

@AlexTMjugador AlexTMjugador added the github_actions Pull requests that update GitHub Actions code label Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update GitHub Actions code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants