mirror of
https://github.com/ludeeus/action-shellcheck.git
synced 2025-09-16 21:26:27 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c489c81f79 | ||
![]() |
73cbb64041 | ||
![]() |
c7d4e499f1 | ||
![]() |
7ee62c0418 | ||
![]() |
2394c9008b |
4
.github/workflows/ShellCheck.yml
vendored
4
.github/workflows/ShellCheck.yml
vendored
@@ -5,8 +5,10 @@ jobs:
|
|||||||
name: ShellCheck
|
name: ShellCheck
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Run ShellCheck
|
- name: Run ShellCheck
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
@@ -3,4 +3,6 @@ FROM alpine:3.12.0
|
|||||||
RUN apk add --no-cache shellcheck bash
|
RUN apk add --no-cache shellcheck bash
|
||||||
|
|
||||||
COPY runaction /action/runaction
|
COPY runaction /action/runaction
|
||||||
|
COPY .github/problem-matcher.json /problem-matcher.json
|
||||||
|
|
||||||
ENTRYPOINT ["bash", "/action/runaction"]
|
ENTRYPOINT ["bash", "/action/runaction"]
|
@@ -17,7 +17,7 @@ jobs:
|
|||||||
name: Shellcheck
|
name: Shellcheck
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v2
|
||||||
- name: Run ShellCheck
|
- name: Run ShellCheck
|
||||||
uses: ludeeus/action-shellcheck@master
|
uses: ludeeus/action-shellcheck@master
|
||||||
```
|
```
|
||||||
|
46
runaction
46
runaction
@@ -1,8 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
## Enable problem matcher
|
## Enable problem matcher
|
||||||
echo "::add-matcher::.github/problem-matcher.json"
|
cp /problem-matcher.json ./problem-matcher.json
|
||||||
|
|
||||||
|
echo "::add-matcher::problem-matcher.json"
|
||||||
|
|
||||||
|
## Run action
|
||||||
cd "$GITHUB_WORKSPACE" || exit 1
|
cd "$GITHUB_WORKSPACE" || exit 1
|
||||||
|
|
||||||
declare statuscode
|
declare statuscode
|
||||||
@@ -11,6 +14,7 @@ declare -a excludes
|
|||||||
declare -a tmp
|
declare -a tmp
|
||||||
|
|
||||||
statuscode=0
|
statuscode=0
|
||||||
|
shebangregex="^#! */[^ ]*/(env *)?[abkz]*sh"
|
||||||
|
|
||||||
excludes+=( ! -path *./.git/* )
|
excludes+=( ! -path *./.git/* )
|
||||||
excludes+=( ! -path *.go )
|
excludes+=( ! -path *.go )
|
||||||
@@ -26,34 +30,38 @@ readarray -d '' filepaths < <(find . -type f "${excludes[@]}" \
|
|||||||
'(' \
|
'(' \
|
||||||
\
|
\
|
||||||
-name '*.bash' \
|
-name '*.bash' \
|
||||||
-o -path '*/.bash*' \
|
-o -name '.bashrc' \
|
||||||
-o -path '*/bash*' \
|
-o -name 'bashrc' \
|
||||||
|
-o -name '.bash_aliases' \
|
||||||
|
-o -name '.bash_completion' \
|
||||||
|
-o -name '.bash_login' \
|
||||||
|
-o -name '.bash_logout' \
|
||||||
|
-o -name '.bash_profile' \
|
||||||
|
-o -name 'bash_profile' \
|
||||||
-o -name '*.ksh' \
|
-o -name '*.ksh' \
|
||||||
-o -name 'ksh*' \
|
|
||||||
-o -path '*/.ksh*' \
|
|
||||||
-o -path '*/ksh*' \
|
|
||||||
-o -name 'suid_profile' \
|
-o -name 'suid_profile' \
|
||||||
-o -name '*.zsh' \
|
-o -name '*.zsh' \
|
||||||
-o -name '.zlogin*' \
|
-o -name '.zlogin' \
|
||||||
-o -name 'zlogin*' \
|
-o -name 'zlogin' \
|
||||||
-o -name '.zlogout*' \
|
-o -name '.zlogout' \
|
||||||
-o -name 'zlogout*' \
|
-o -name 'zlogout' \
|
||||||
-o -name '.zprofile*' \
|
-o -name '.zprofile' \
|
||||||
-o -name 'zprofile*' \
|
-o -name 'zprofile' \
|
||||||
-o -path '*/.zsh*' \
|
-o -name '.zsenv' \
|
||||||
-o -path '*/zsh*' \
|
-o -name 'zsenv' \
|
||||||
|
-o -name '.zshrc' \
|
||||||
|
-o -name 'zshrc' \
|
||||||
-o -name '*.sh' \
|
-o -name '*.sh' \
|
||||||
-o -path '*/.profile*' \
|
-o -path '*/.profile' \
|
||||||
-o -path '*/.shlib*' \
|
-o -path '*/profile' \
|
||||||
-o -path '*/shlib*' \
|
-o -name '*.shlib' \
|
||||||
')'\
|
')'\
|
||||||
\
|
\
|
||||||
-print0)
|
-print0)
|
||||||
|
|
||||||
|
|
||||||
readarray -d '' tmp < <(find . "${excludes[@]}" -type f ! -name '*.*' -perm /111 -print0)
|
readarray -d '' tmp < <(find . "${excludes[@]}" -type f ! -name '*.*' -perm /111 -print0)
|
||||||
for file in "${tmp[@]}"; do
|
for file in "${tmp[@]}"; do
|
||||||
head -n1 "$file" | grep -Eqs "^#! */[^ ]*/[abkz]*sh" || continue
|
head -n1 "$file" | grep -Eqs "$shebangregex" || continue
|
||||||
filepaths+=("$file")
|
filepaths+=("$file")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
6
testfiles/bashfile.c
Normal file
6
testfiles/bashfile.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/* C code test file
|
||||||
|
* file that should not be matched for shellcheck runs
|
||||||
|
*/
|
||||||
|
int main(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user