File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -108,3 +108,25 @@ jobs:
108108 with :
109109 options : " --check --diff"
110110 src : ${{ env.FILES }}
111+
112+ shellcheck :
113+ runs-on : ubuntu-latest
114+ steps :
115+ - uses : actions/checkout@v4
116+ with :
117+ fetch-depth : 0
118+
119+ - name : Get changed shell files
120+ uses : tj-actions/changed-files@v45
121+ id : changed-files
122+ with :
123+ files : " **/*.{sh,bash}"
124+ separator : " "
125+
126+ - name : shellcheck
127+ 128+ with :
129+ version : v0.10.0
130+ severity : warning
131+ ignore_paths : " ." # Ignore all files
132+ additional_files : ${{ steps.changed-files.outputs.all_changed_files }} # Only check changed files
Original file line number Diff line number Diff line change @@ -40,8 +40,8 @@ clean: stop_bash
4040cleanall : clean
4141 -docker inspect --type=image $(IMAGE_NAME ) > /dev/null 2>&1 && docker image rm $(IMAGE_NAME )
4242
43- .PHONY : lint markdownlint cpplint black
44- lint : markdownlint cpplint black
43+ .PHONY : lint markdownlint cpplint black shellcheck
44+ lint : markdownlint cpplint black shellcheck
4545
4646CHANGED_MD_FILES = $(call get_changed_files,\.md$$)
4747markdownlint :
@@ -68,6 +68,14 @@ black:
6868 black --check --diff $(CHANGED_PY_FILES ) ; \
6969 fi
7070
71+ CHANGED_SHELL_FILES = $(call get_changed_files,\.\(sh\|bash\) $$)
72+ shellcheck :
73+ @echo " Checking shell scripts ..."
74+ @if [ " $( CHANGED_SHELL_FILES) " ]; then \
75+ docker run --rm -v $(PWD ) :/data --workdir=/data koalaman/shellcheck-alpine:v0.10.0 \
76+ shellcheck --severity=warning $(CHANGED_SHELL_FILES ) ; \
77+ fi
78+
7179# Get a list of files that changed in the current branch and match the given pattern
7280define get_changed_files # $(1 ) : pattern
7381$(shell git diff --name-only HEAD $(shell git merge-base HEAD main) | grep "$(1)" | tr '\n' ' ')
You can’t perform that action at this time.
0 commit comments