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: provide ShellCheck shared workflow & template #64

Merged
merged 12 commits into from
Mar 10, 2023

Conversation

kdmccormick
Copy link
Member

@kdmccormick kdmccormick commented Feb 27, 2023

Description

build: provide ShellCheck shared workflow & template

We add a central shared ShellCheck workflow that can
be used from any openedx repository. It takes a small set
of parameters, which could be expanded later if needed.

We also add a workflow template for invoking the ShellCheck
workflow, which repositories can copy and use.

Supporting information

Implements the ShellCheck ADR which was introduced in:

Here's the template in-use in edx-platform:

Other Information

(from edx-platform)

output from a successful build

image

output of a build with a shellcheck violation

image

output of a build that failed because no scripts were checked

image

workflow-templates/shellcheck.yml Outdated Show resolved Hide resolved
workflow-templates/shellcheck.yml Outdated Show resolved Hide resolved
@kdmccormick kdmccormick force-pushed the kdmccormick/shellcheck-impl branch 12 times, most recently from 33a7096 to 6c3f604 Compare March 2, 2023 01:50
@kdmccormick kdmccormick force-pushed the kdmccormick/shellcheck-impl branch 2 times, most recently from e976575 to 0aa862e Compare March 2, 2023 02:17
Copy link
Member Author

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

Alright, I reorganized this based on the discussions above, and this seems to be working. Some notes for reviewers.

workflow-templates/shellcheck.yml Outdated Show resolved Hide resolved
@kdmccormick kdmccormick changed the title build: add workflow template for ShellCheck build: add workflow template & central action for ShellCheck Mar 2, 2023
@kdmccormick kdmccormick force-pushed the kdmccormick/shellcheck-impl branch from 0aa862e to 096994d Compare March 2, 2023 16:33
@kdmccormick kdmccormick changed the title build: add workflow template & central action for ShellCheck build: provide ShellCheck template Mar 2, 2023
@kdmccormick kdmccormick marked this pull request as ready for review March 2, 2023 19:14

jobs:
shellcheck:
runs-on: ubuntu-latest
Copy link
Member Author

Choose a reason for hiding this comment

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

This check only runs on Ubuntu.

I was tempted to generalize it to MacOS. It would be easy enough to use a build matrix here so that this runs on both ubuntu-latest and macos-latest. What would be a little more difficult is ensuring that we download the correct binary in action.yml.

I decided against that because I've already been at this for a few days, and I feel like I could spend another week tweaking and perfecting everything, but it's not clear to me that it'd be time well spent. If you disagree, let me know.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just kidding, I thought of a way to do this that wasn't too bad.

@kdmccormick
Copy link
Member Author

Alright @timmc-edx @feanil, both this and the edx-platform PR are ready for review!

@kdmccormick kdmccormick force-pushed the kdmccormick/shellcheck-impl branch 4 times, most recently from de309aa to baa8e06 Compare March 9, 2023 04:15
@kdmccormick
Copy link
Member Author

Alright @timmc-edx @feanil , I changed it back from an action to a shared workflow. Fortunately, the code seems much simpler and the output is much nicer. This and the edx-platform PR are both ready for review again.

@kdmccormick kdmccormick changed the title build: provide ShellCheck template build: provide ShellCheck shared workflow & template Mar 9, 2023
.github/workflows/shellcheck.yml Outdated Show resolved Hide resolved
.github/workflows/shellcheck.yml Outdated Show resolved Hide resolved
workflow-templates/shellcheck.yml Outdated Show resolved Hide resolved
@kdmccormick kdmccormick force-pushed the kdmccormick/shellcheck-impl branch 6 times, most recently from 92e96ee to b287219 Compare March 9, 2023 20:49
@kdmccormick
Copy link
Member Author

@feanil @timmc-edx Latest changes are:

  • Rather than an include-list of directories, we check the entire repo, but allow an exclude-list to be passed in. The template excludes node_modules by default. The shared workflow excludes nothing by default. (I like that any exclude pattern must be explicitly passed into the shared workflow).
  • If a bad OS argument provided, we print out the valid OS argument options.
  • I'd originally had a step that checked whether the list of input files is empty, and errored if it was empty. Turns out shellcheck provides that behavior already. In order to keep the implementation as simple as possible, I removed the custom step, and will let shellcheck report that error itself.

Screenshots have also been updated.

@kdmccormick kdmccormick requested review from feanil and timmc-edx and removed request for timmc-edx March 9, 2023 21:13
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.

Two small changes that I think are worth making for clarity but otherwise this looks good to me. I don't need to review again before you merge.

.github/workflows/shellcheck.yml Outdated Show resolved Hide resolved
workflow-templates/shellcheck.yml Show resolved Hide resolved
@kdmccormick kdmccormick force-pushed the kdmccormick/shellcheck-impl branch from 180a09a to aad1e21 Compare March 10, 2023 15:36
@kdmccormick kdmccormick merged commit 5f7cd28 into openedx:master Mar 10, 2023
@kdmccormick kdmccormick deleted the kdmccormick/shellcheck-impl branch March 10, 2023 15:48
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.

3 participants