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

ci(lint): add shell linter - Differential ShellCheck #2243

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jamacku
Copy link

@jamacku jamacku commented Mar 6, 2024

Description

Addition of a new job in CI workflow that will Scan all shell scripts in the repo using ShellCheck and report only newly added defects.

Motivation and Context

Differential ShellCheck is a GitHub action that performs differential ShellCheck scans on shell scripts changed via PR and reports results directly in PR.

It's great for projects with a greater number of ShellCheck defects where it's not feasible to fix or mask all of them. I see that you have an allow-list of files that can be scanned because they are free of ShellCheck defects. But from what I can see when someone changes a script that is not on the list, CI won't check the changes. But when running ShellCheck scans differentially, you can scan all shell scripts, and only new defects will be reported.

It is able to produce reports in SARIF format. GitHub understands this format and is able to display it nicely as a PR comment, and on the Files Changed tab, please see below.

Documentation is available at @redhat-plumbers-in-action/differential-shellcheck. Let me know If you are missing some feature or option. I'm always happy to extend functionality.

Screenshots (if appropriate):

image

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • If my change requires a change to the documentation, I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • If I have added a new file, I also added it to clean_files.txt and formatted it using lint_clean_files.sh.
  • I have added tests to cover my changes, and all the new and existing tests pass.

It performs differential ShellCheck scans and reports results directly on GitHub.

documentation: https://github.com/redhat-plumbers-in-action/differential-shellcheck

Signed-off-by: Jan Macku <[email protected]>
@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.

@jamacku
Copy link
Author

jamacku commented Mar 6, 2024

Here you can see the summary for PR: https://github.com/Bash-it/bash-it/actions/runs/8174624870#summary-22349834100

Screenshot from 2024-03-06 16-40-41

If merged, you will see all existing ShellCheck defects under the Security tab in GitHub UI, but they won't be reported in PRs; only newly introduced defects will be reported.

Copy link
Contributor

@seefood seefood left a comment

Choose a reason for hiding this comment

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

Looks good!

@seefood seefood self-assigned this Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants