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

build: run ShellCheck in CI #31809

Merged
merged 10 commits into from
Mar 10, 2023
Merged

build: run ShellCheck in CI #31809

merged 10 commits into from
Mar 10, 2023

Conversation

kdmccormick
Copy link
Member

@kdmccormick kdmccormick commented Feb 22, 2023

Description

build: run ShellCheck

Adds a ShellCheck check to edx-platform PRs and master,
using the shared workflow & template from the .github repo.
This will become a "required" check once it passes for 2 straight weeks on master.

Brings all existing shell scripts into compliance with ShellCheck.

Supporting information

This implements an ADR:

and uses a new workflow template & action:

This required removing some old, unused shell scripts which had a lot of violations:

Other Information

See openedx/.github#64 for screenshots of the build.

Commits will be squashed before merging.

Test instructions

  • Make a branch off of this one.
  • Edit a shell script. Add something incorrect, like ls $whoops.
  • Push the branch, and observe that the shellcheck PR check fails. (Unfortunately, due to GHA security restrictions, you may need to push an openedx/edx-platform upstream branch for this to work, which is only available to edx-platform CCs and 2U. After this PR merges, I expect that the check will also run on forks, which I will confirm).
  • Look at the check output. Ensure that is easy to find and helpful.
  • See if you can recreate the build failure on your local machine given the info in the output.

@brian-smith-tcril
Copy link
Contributor

so it seems one of the reasons this is failing because https://github.com/openedx/edx-platform/blob/master/common/test/data/static/contains.sh is shebanging zsh, so we're getting this error:

./common/test/data/static/contains.sh:1:1: error: ShellCheck only supports sh/bash/dash/ksh scripts. Sorry! [SC1071]

is the lack of zsh support in shellcheck going to be a dealbreaker?

@kdmccormick
Copy link
Member Author

That's a really old script, so I think we can just tell shellcheck ignore it. I don't think we should be committing zsh to repos for the same reason we wouldn't commit Ruby or Go: they're not Python, JS, or standard *nix tooling.

@kdmccormick kdmccormick force-pushed the kdmccormick/shellcheck branch 18 times, most recently from bbd4516 to 95e7690 Compare March 2, 2023 00:00
@kdmccormick kdmccormick requested a review from a team as a code owner March 9, 2023 16:32
@kdmccormick kdmccormick requested review from feanil and removed request for a team March 9, 2023 16:43
matrix:
os: ["ubuntu", "macos"]
#uses: openedx/.github/.github/workflows/shellcheck.yml@master
uses: kdmccormick/openedx.github/.github/workflows/shellcheck.yml@kdmccormick/shellcheck-impl
Copy link
Contributor

Choose a reason for hiding this comment

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

Just making a note that this needs to be updated before we merge this, I see that you have the comment ready to swap, when the .github PR has merged.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the reminder 👍🏻

.github/workflows/shellcheck.yml Outdated Show resolved Hide resolved
@kdmccormick kdmccormick force-pushed the kdmccormick/shellcheck branch 2 times, most recently from 285140c to c2c7803 Compare March 9, 2023 20:54
@kdmccormick
Copy link
Member Author

This and openedx/.github#64 are both ready for another round of review.

Copy link
Contributor

@feanil feanil 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 once the upstream .github PR merges and we do the final update to the job URL.

@kdmccormick kdmccormick enabled auto-merge (squash) March 10, 2023 15:59
@kdmccormick kdmccormick changed the title build: run ShellCheck build: run ShellCheck in CI Mar 10, 2023
@kdmccormick kdmccormick merged commit cd24534 into master Mar 10, 2023
@kdmccormick kdmccormick deleted the kdmccormick/shellcheck branch March 10, 2023 16:10
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

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.

4 participants