Skip to content

Commit

Permalink
build: squash: let's try an action instead of a workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Mar 2, 2023
1 parent b158256 commit 096994d
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 71 deletions.
61 changes: 61 additions & 0 deletions .github/actions/shellcheck/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This is a reusable action for running ShellCheck,
# a linter for shell scripts (https://shellcheck.net).

# For more context, see:
# https://github.com/openedx/.github/blob/master/docs/decisions/0001-shellcheck.rst

name: ShellCheck

inputs:

root-dirs:
description: "Directories to search for .sh files, space-separated."
reqired: true

# We pin a reasonable default version here and will update it over time.
# However, repositories that are particuarly concerned about
# build stability should specify an override shellcheck-version
# and manage updates themselves.
shellcheck-version:
description: "ShellCheck version to install.Must be a tag or branch of https://github.com/koalaman/shellcheck."
required: false
default: "v0.9.0"

shellcheck-options:
description: "Command-line options to pass through to shellcheck."
required: false
default: ""

runs:

using: composite

# Note: Unfortunately, GitHub will not print the names of steps in
# composite actions, so we must rely on comments and echo'ing to
# make it clear to the user what's going on on.
steps:

- shell: bash
run: |
# Download, unpack & install ShellCheck ${{ inputs.shellcheck-version }}.
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${{ inputs.shellcheck-version }}/shellcheck-${{ inputs.shellcheck-version}}.linux.x86_64.tar.xz" | tar -xJ
sudo cp "shellcheck-${{ inputs.shellcheck-version }}/shellcheck" /usr/bin
echo "Successfully installed:"
shellcheck -V
echo
- shell: bash
run: |
# Ensure that at least one shell script will be checked
if [[ -z "$(find ${{ inputs.root-dirs }} -name '*.sh')" ]] ; then
echo "::error::Error: No .sh files found within any of the root-dirs: ${{ inputs.root-dirs }}" && exit 1
fi
echo "The following shell scripts will be checked:"
find ${{ inputs.root-dirs }} -name '*.sh'
echo
# This step is intentionally a big one-line command so that
# devs can easily copy it and run it on their own machine.
- shell: bash
run: find ${{ inputs.root-dirs }} -name '*.sh' -print0 | xargs -0 shellcheck ${{ inputs.shellcheck-options }}

61 changes: 0 additions & 61 deletions .github/workflows/shellcheck.yml

This file was deleted.

36 changes: 26 additions & 10 deletions workflow-templates/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Run ShellCheck on PRs and $default-branch.
# Run ShellCheck on PRs and $default-branch

# For more context, see:
# https://github.com/openedx/.github/blob/master/docs/decisions/0001-shellcheck.rst


name: ShellCheck

on:
Expand All @@ -12,13 +11,30 @@ on:
branches:
- $default-branch

permissions:
contents: read

jobs:
shellcheck:
# Call out to our predefined ShellCheck workflow.
uses: openedx/.github/.github/workflows/shellcheck.yml@master
env:
# The following environment variables can be used to configure
# the shared ShellCheck workflow:
#SHELLCHECK_VERSION: "v0.9.0"
#SHELLCHECK_ROOT_DIRS: "./scripts ./.github"
#SHELLCHECK_OPTIONS: ""
runs-on: ubuntu-latest
steps:

- name: Check out this repository
uses: actions/checkout@v3

- name: Check out shared actions
uses: actions/checkout@v3
with:
repository: openedx/.github
path: ./openedx-dot-github

- name: Run ShellCheck!
uses: ./openedx-dot-github/.github/actions/shellcheck
with:

# Required arguments for the ShellCheck action:
root-dirs: "./scripts ./.github"

# Optional arguments:
#shellcheck-version: "v0.9.0"
#shellcheck-options: ""

0 comments on commit 096994d

Please sign in to comment.