Skip to content

Commit

Permalink
[MISC] Add shellcheck checks to ensure that those few shell scripts w…
Browse files Browse the repository at this point in the history
…e have are "robust" (#1774)

* Add pre-commit definition for shellcheck

* Add "" for a variable use in a test_tag script

* Add github action to shellcheck master on push and PRs

* Skip shellcheck on ci for pre-commit -- needs docker
  • Loading branch information
yarikoptic authored May 16, 2024
1 parent 0950f6d commit 3fd21ff
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -71,3 +73,7 @@ repos:
- types-jsonschema
args: ["tools/schemacode/bidsschematools"]
pass_filenames: false
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
- id: shellcheck
2 changes: 1 addition & 1 deletion scripts/test_tag
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 3fd21ff

Please sign in to comment.