Skip to content

add shellcheck action to lint bash scripts #3710

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

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

Conversation

doc-sheet
Copy link
Contributor

@doc-sheet doc-sheet commented May 24, 2025

Hello.
I would like to add shellcheck linter for install scripts.

To avoid messing with #3673 podman PR (and to not edit all scripts at once) this action only checks install/_lib.sh

I'm willing to slowly add all other *.sh scripts too.

Some trade-offs I made:

  1. checks restricted to install/_lib.sh but action runs on any **.sh change.
  2. SC1090 and SC1091 disabled because I don't have full context on how env-sources are used
  3. ensure_file_from_example() excluded as kinda false-positive, pure bash solution won't be more readable I suppose
  4. direct shellcheck run is used because tool is preinstalled and it's output could easily be converted to action annotations

Warnings from unmodified lib.sh are available in this PR

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Copy link
Collaborator

@aminvakil aminvakil left a comment

Choose a reason for hiding this comment

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

Thank you for providing this PR.

Honestly I'm not a fan of shellcheck on big projects myself, running shellcheck locally on self-hosted shows many errors and warnings which many are not a big deal.

I'd suggest running shellcheck locally and fix any issue which you may see and provide a PR for them, but I do not see a benefit of adding shellcheck in case we want to ignore it everywhere.

--shell=bash \
--exclude=SC1090,SC1091 \
--format=json1 \
| jq -r '
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the necessity of piping output of shellcheck to jq?

Copy link
Contributor Author

@doc-sheet doc-sheet May 31, 2025

Choose a reason for hiding this comment

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

just to replace some keys like column and values like info and style with github action command.
col and notice in this case.

And to format shellcheck's json as one-line command like ::error file=file.sh,col=123::message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And the trick with grep is just to negate exit code :)

@doc-sheet
Copy link
Contributor Author

in case want to ignore it everywhere

My point is to fix warnings first (which I plan to do anyway iteratively) and then don't ignore it anymore. I just don't want to break other people PRs with minor changes of quotes and exports here and there.

I just hope code without warnings would help with adding new features and refactoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants