From a4c3c0d0d3526358f8c14557622fb813e3804c9a Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 12 Apr 2024 14:14:33 -0400 Subject: [PATCH 1/4] Add pre-commit definition for shellcheck --- .pre-commit-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fcf475045e..b45705e1aa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,3 +64,7 @@ repos: - types-tabulate args: ["tools/schemacode/bidsschematools"] pass_filenames: false + - repo: https://github.com/koalaman/shellcheck-precommit + rev: v0.9.0 + hooks: + - id: shellcheck From a89b1bf3acd19f866c4875f5fe871762e8e8dd98 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 12 Apr 2024 14:15:51 -0400 Subject: [PATCH 2/4] Add "" for a variable use in a test_tag script --- scripts/test_tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test_tag b/scripts/test_tag index f11ef697dd..64e0ddd20f 100755 --- a/scripts/test_tag +++ b/scripts/test_tag @@ -9,7 +9,7 @@ EPOCH="$(date +%s)" GIT_DIR=$( git rev-parse --git-dir ) -REPO_ROOT=$( ls -d ${GIT_DIR%.git} ) +REPO_ROOT=$( ls -d "${GIT_DIR%.git}" ) VERSION_FILE="$REPO_ROOT/src/schema/SCHEMA_VERSION" From 51274f2c526ec146f866a1775258e06953e0335c Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 12 Apr 2024 14:14:33 -0400 Subject: [PATCH 3/4] Add github action to shellcheck master on push and PRs --- .github/workflows/shellcheck.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000000..c4e38c1d1d --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,26 @@ +--- +name: Shellcheck + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + shellcheck: + name: Check shell scripts + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install dependencies + run: | + sudo apt update && sudo apt install -y shellcheck + - name: shellcheck + run: | + git grep -l '^#\( *shellcheck \|!\(/bin/\|/usr/bin/env \)\(sh\|bash\|dash\|ksh\)\)' | xargs shellcheck From a8a891cc1a2b15dea9427eb53d150b8f0931b550 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 15 Apr 2024 09:43:21 -0400 Subject: [PATCH 4/4] Skip shellcheck on ci for pre-commit -- needs docker --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b45705e1aa..6bea922995 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,7 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks +ci: + skip: [shellcheck] exclude: 'tools/schemacode/bidsschematools/tests/data/broken_dataset_description.json' repos: - repo: https://github.com/pre-commit/pre-commit-hooks