From 33f15e8d85b3366b1a09bca914f61d5caa4a2fb5 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Oct 2023 14:59:44 -0700 Subject: [PATCH] Separate out shell script linting --- .github/workflows/lint.yml | 7 ++----- .github/workflows/shellCheck.yml | 19 +++++++++++++++++++ scripts/shellCheck.sh | 8 +++++++- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/shellCheck.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 360631920cf1..9d7efc7d4c29 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,7 +5,7 @@ on: pull_request: types: [opened, synchronize] branches-ignore: [staging, production] - paths: ['**.js', '**.ts', '**.tsx', '**.sh'] + paths: ['**.js', '**.ts', '**.tsx'] jobs: lint: @@ -13,7 +13,7 @@ jobs: 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 @@ -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 diff --git a/.github/workflows/shellCheck.yml b/.github/workflows/shellCheck.yml new file mode 100644 index 000000000000..609541e9a660 --- /dev/null +++ b/.github/workflows/shellCheck.yml @@ -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 diff --git a/scripts/shellCheck.sh b/scripts/shellCheck.sh index 14424b4d9b30..d148958900d4 100755 --- a/scripts/shellCheck.sh +++ b/scripts/shellCheck.sh @@ -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