1
0
Fork 0
mirror of https://github.com/ludeeus/action-shellcheck.git synced 2024-08-16 10:09:53 +02:00
shellcheck/runaction

85 lines
2.1 KiB
Text
Raw Normal View History

2020-05-30 00:06:39 +02:00
#!/bin/bash
2019-03-09 11:25:14 +01:00
## Enable problem matcher
2020-05-03 22:11:15 +02:00
cd "$GITHUB_WORKSPACE" || exit 1
2020-05-30 11:44:01 +02:00
declare statuscode
2020-05-30 00:06:39 +02:00
declare -a filepaths
2020-05-30 11:44:01 +02:00
declare -a excludes
2020-05-30 00:06:39 +02:00
declare -a tmp
2020-05-30 11:44:01 +02:00
statuscode=0
2020-05-30 11:44:01 +02:00
excludes+=( ! -path *./.git/* )
2020-06-07 16:53:52 +02:00
excludes+=( ! -path *.go )
2020-06-10 11:56:06 +02:00
excludes+=( ! -path */mvnw )
2020-06-07 16:53:52 +02:00
2020-05-30 11:44:01 +02:00
for path in ${INPUT_IGNORE}; do
2020-05-30 12:01:39 +02:00
echo "::debug:: Adding '${path}' to excludes"
2020-05-30 12:00:24 +02:00
excludes+=(! -path "*./${path}/*" )
2020-05-30 12:01:39 +02:00
excludes+=(! -path "*/${path}/*" )
2020-05-30 11:44:01 +02:00
done
readarray -d '' filepaths < <(find . -type f "${excludes[@]}" \
2020-05-30 11:44:01 +02:00
'(' \
2020-05-30 00:06:39 +02:00
\
-name '*.bash' \
-o -path '*/.bash*' \
-o -path '*/bash*' \
-o -name '*.ksh' \
-o -name 'ksh*' \
-o -path '*/.ksh*' \
-o -path '*/ksh*' \
-o -name 'suid_profile' \
-o -name '*.zsh' \
-o -name '.zlogin*' \
-o -name 'zlogin*' \
-o -name '.zlogout*' \
-o -name 'zlogout*' \
-o -name '.zprofile*' \
-o -name 'zprofile*' \
-o -path '*/.zsh*' \
-o -path '*/zsh*' \
-o -name '*.sh' \
-o -path '*/.profile*' \
-o -path '*/.shlib*' \
-o -path '*/shlib*' \
')'\
\
-print0)
2020-05-30 11:44:01 +02:00
readarray -d '' tmp < <(find . "${excludes[@]}" -type f ! -name '*.*' -perm /111 -print0)
2020-05-30 00:06:39 +02:00
for file in "${tmp[@]}"; do
head -n1 "$file" | grep -Eqs "^#! */[^ ]*/[abkz]*sh" || continue
filepaths+=("$file")
done
2020-05-30 11:44:01 +02:00
if find . "${excludes[@]}" -path '*bin/*/*' -type f -perm /111 -print |
grep .
then
2020-05-30 00:06:39 +02:00
echo >&2 "::warning:: subdirectories of bin directories are not usable via PATH"
fi
2020-05-30 11:44:01 +02:00
if find . "${excludes[@]}" -path '*bin/*' -name '*.*' -type f -perm /111 -perm /444 -print |
grep .
then
2020-05-30 00:06:39 +02:00
echo >&2 "::warning:: programs in PATH should not have a filename suffix"
fi
2020-05-03 22:11:15 +02:00
[[ -n "${INPUT_SEVERITY}" ]] && options+=(-S "${INPUT_SEVERITY}")
if [[ -n "$INPUT_CHECK_TOGETHER" ]]; then
echo "::debug:: shellcheck ${options[*]} ${filepaths[*]}"
shellcheck "${options[@]}" "${filepaths[@]}" || statuscode=$?
else
echo "::debug:: Shellcheck options: ${options[*]}"
for file in "${filepaths[@]}"; do
echo "::debug:: Checking $file"
shellcheck "${options[@]}" "$file" || statuscode=$?
done
fi
2020-05-30 00:06:39 +02:00
2020-06-10 11:56:06 +02:00
exit "$statuscode"