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

Lint shell scripts #91

Merged
merged 4 commits into from Oct 7, 2022
Merged

Lint shell scripts #91

merged 4 commits into from Oct 7, 2022

Conversation

sondrelg
Copy link
Member

@sondrelg sondrelg commented Sep 29, 2022

Adds shfmt and shellcheck to our linter setup. Only the ${INSTALLATION_ARGUMENTS} call in main.sh:20 looks like it cannot be formatted according to shellcheck, so I've added ignore statements for those. This mainly re-formats the old script files.

Also sets set -eo pipefail to make the action error properly. The "command poetry does not exist" output for when the installation failed is not very user friendly.

@miigotu
Copy link
Collaborator

miigotu commented Sep 29, 2022

Was using tabs instead of spaces intentional?

I use shellcheck in my ci (and locally)

In the ci use format=diff and locally let it use the gcc format for output.

https://github.com/SickChill/sickchill/blob/master/.github/workflows/pythonpackage.yml#L60

@sondrelg sondrelg marked this pull request as draft October 2, 2022 08:00
@sondrelg
Copy link
Member Author

sondrelg commented Oct 6, 2022

No it wasn't 😅 Seems that's the default shfmt configuration. Added an .editorconfig file to revert to spaces.

@sondrelg sondrelg force-pushed the lint branch 18 times, most recently from 2daf449 to 4d67864 Compare October 6, 2022 05:18
@sondrelg sondrelg marked this pull request as ready for review October 6, 2022 06:41
@sondrelg
Copy link
Member Author

sondrelg commented Oct 6, 2022

Want to take another look at this @miigotu? 🙂 In particular, do you agree with the set -eo pipefail addition? I think having the action fail when there's an issue in the shell script seems appropriate.

@sondrelg sondrelg requested a review from miigotu October 6, 2022 06:42
@sondrelg sondrelg changed the title Lint shell code Lint shell scripts Oct 6, 2022
@miigotu
Copy link
Collaborator

miigotu commented Oct 6, 2022

I'll go over the whole thing when I get home, but absolutely -eo pipefail is necessary. If you set the indent spaces to 2 it will keep the spacing with the 2 convention commonly used for bash which helps with reading when you have deeper nesting down the road.

It would also make the changes in this PR more apparent.

Copy link
Collaborator

@miigotu miigotu 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 now. You later can make an action that automatically fixes shell scripts in PRs if someone doesn't have an IDE that supports editorconfig and also don't have pre-commit installed.
👍

@sondrelg sondrelg merged commit e3dbfd3 into main Oct 7, 2022
@sondrelg sondrelg deleted the lint branch October 7, 2022 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants