mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-01-06 14:21:55 +03:00
ci: Add shellcheck
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
@@ -110,6 +110,8 @@ review:
|
||||
codespell --ignore-words-list=keypair,sorce,ned,nd,ue || ERROR=1;
|
||||
./.gitlab-ci/clang-format-check.sh || ERROR=1;
|
||||
./.gitlab-ci/git-check-signoff-trailer.sh ${CI_MERGE_REQUEST_DIFF_BASE_SHA} || ERROR=1;
|
||||
./.gitlab-ci/git-check-signoff-trailer.sh ${CI_MERGE_REQUEST_DIFF_BASE_SHA} || ERROR=1;
|
||||
./.gitlab-ci/shellcheck.sh || ERROR=1;
|
||||
exit $ERROR
|
||||
# the format is not always matching our intentions
|
||||
allow_failure: true
|
||||
|
||||
56
.gitlab-ci/shellcheck.sh
Executable file
56
.gitlab-ci/shellcheck.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
# Simplified and de-github-ed version of
|
||||
# https://github.com/ludeeus/action-shellcheck/blob/master/action.yaml
|
||||
|
||||
statuscode=0
|
||||
|
||||
declare -a filepaths
|
||||
shebangregex="^#! */[^ ]*/(env *)?[abk]*sh"
|
||||
set -f # temporarily disable globbing so that globs in inputs aren't expanded
|
||||
|
||||
while IFS= read -r -d '' file; do
|
||||
filepaths+=("$file")
|
||||
done < <(find . \
|
||||
-type f \
|
||||
'(' \
|
||||
-name '*.bash' \
|
||||
-o -name '.bashrc' \
|
||||
-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 'suid_profile' \
|
||||
-o -name '*.zsh' \
|
||||
-o -name '.zlogin' \
|
||||
-o -name 'zlogin' \
|
||||
-o -name '.zlogout' \
|
||||
-o -name 'zlogout' \
|
||||
-o -name '.zprofile' \
|
||||
-o -name 'zprofile' \
|
||||
-o -name '.zsenv' \
|
||||
-o -name 'zsenv' \
|
||||
-o -name '.zshrc' \
|
||||
-o -name 'zshrc' \
|
||||
-o -name '*.sh' \
|
||||
-o -path '*/.profile' \
|
||||
-o -path '*/profile' \
|
||||
-o -name '*.shlib' \
|
||||
')' \
|
||||
-print0)
|
||||
|
||||
while IFS= read -r -d '' file; do
|
||||
head -n1 "$file" | grep -Eqs "$shebangregex" || continue
|
||||
filepaths+=("$file")
|
||||
done < <(find . \
|
||||
-type f ! -name '*.*' -perm /111 \
|
||||
-print0)
|
||||
|
||||
shellcheck "${filepaths[@]}" || statuscode=$?
|
||||
|
||||
set +f # re-enable globbing
|
||||
|
||||
exit "$statuscode"
|
||||
Reference in New Issue
Block a user