Skip to content

Commit

Permalink
build: squash: drop 3rd party action in favor of home-rolled workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Mar 2, 2023
1 parent e0da1a6 commit b158256
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 54 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This is a reusable workflow 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

on:
- workflow_call

defaults:
run:
shell: bash

permissions:
contents: read

# Repositories can provide overrides to these environment variables.
env:

# ShellCheck version to install.
# Must be a tag or branch of https://github.com/koalaman/shellcheck.
# We pin a reasonable 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: "v0.9.0"

# List of directories to check for .sh files, space-separated.
SHELLCHECK_ROOT_DIRS: "./scripts ./.github"

# Options to pass to the shellcheck command.
SHELLCHECK_OPTIONS: ""

jobs:

shellcheck:
name: Run ShellCheck
runs-on: ubuntu-latest

steps:

- name: Download & unpack ShellCheck
run: wget -qO- "https://github.com/koalaman/shellcheck/releases/download/$SHELLCHECK_VERSION/shellcheck-$SHELLCHECK_VERSION.linux.x86_64.tar.xz" | tar -xJv

- name: Install ShellCheck
run: sudo cp "shellcheck-$SHELLCHECK_VERSION/shellcheck" /usr/bin

- name: Show ShellCheck version
run: shellcheck -V

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

- name: Show shell scripts that will be checked
run: find $SHELLCHECK_ROOT_DIRS -name '*.sh'

- name: Check shell scripts
run: find $SHELLCHECK_ROOT_DIRS -name '*.sh' -print0 | xargs -0 shellcheck $SHELLCHECK_OPTIONS

67 changes: 13 additions & 54 deletions workflow-templates/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# ShellCheck is a linter for your shell scripts:
# https://www.shellcheck.net/
# This workflow runs it on PRs and pushes to $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

Expand All @@ -10,56 +12,13 @@ on:
branches:
- $default-branch

permissions:
contents: read

jobs:

shellcheck:
name: Run ShellCheck
runs-on: ubuntu-latest

steps:

- name: Check out branch
uses: actions/checkout@v3

# Run ShellCheck using a predefine action:
# https://github.com/marketplace/actions/shellcheck
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:

# We pin to a specific version of ShellCheck so that your build doesn't
# break as newer versions with more warnings are released.
# Maintainers: Keep an eye out for newer ShellCheck versions and consider
# upgrading to them when they are released:
# https://github.com/koalaman/shellcheck/tags
version: v0.9.0

# Severity levels, in increasing order of strictness:
# error
# warning
# info
# style
# We recommend `style` for maximum coverage, but adjust as you see fit.
severity: style

# Add any custom shellcheck CLI options here.
# For example, use `-e SC2059` to ignore a certain warning.
# (However, it's usually to ignore individual warnings inline: `# shellcheck: disable=SC2059`)
SHELLCHECK_OPTS:

# Ignore filepaths or filenames.
# Each is a single string, space-separated.
ignore_paths:
ignore_names:

# By default, your whole repo is scanned for shell scripts.
# Uncomment the next line if you want to limit to a certain directory.
#scandir: './scripts'

# This ensures that all .sh files are passed to shellcheck in one go, making
# ShellCheck aware of "include" logic (`source ./constants.sh`) between scripts.
check_together: 'yes'

# 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: ""

0 comments on commit b158256

Please sign in to comment.