Skip to content

Commit

Permalink
Separate out shell script linting
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Oct 26, 2023
1 parent 2e3037d commit 33f15e8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ on:
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]
paths: ['**.js', '**.ts', '**.tsx', '**.sh']
paths: ['**.js', '**.ts', '**.tsx']

jobs:
lint:
if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
uses: actions/checkout@v3

- name: Setup Node
uses: Expensify/App/.github/actions/composite/setupNode@main
Expand All @@ -23,9 +23,6 @@ jobs:
env:
CI: true

- name: Lint shell scripts with ShellCheck
run: npm run shellcheck

- name: Verify there's no Prettier diff
run: |
npm run prettier -- --loglevel silent
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/shellCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint shell code

on:
workflow_call:
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]
paths: ['**.sh']

jobs:
lint:
if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Lint shell scripts with ShellCheck
run: npm run shellcheck
8 changes: 7 additions & 1 deletion scripts/shellCheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ info

ASYNC_PROCESSES=()
for SHELL_SCRIPT in $SHELL_SCRIPTS; do
npx shellcheck -e SC1091 "$SHELL_SCRIPT" &
if [[ "$CI" == 'true' ]]; then
# ShellCheck is installed by default on GitHub Actions ubuntu runners
shellcheck -e SC1091 "$SHELL_SCRIPT" &
else
# Otherwise shellcheck is used via npx
npx shellcheck -e SC1091 "$SHELL_SCRIPT" &
fi
ASYNC_PROCESSES+=($!)
done

Expand Down

0 comments on commit 33f15e8

Please sign in to comment.