2019-11-14 19:27:22 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-01-03 17:15:25 +01:00
|
|
|
# Copyright (C) 2019-2020 Patryk Obara <patryk.obara@gmail.com>
|
2019-11-14 19:27:22 +01:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
# This script exists only to easily run shellcheck on all files in the repo.
|
|
|
|
# You can pass additional parameters to this script itself, e.g.:
|
|
|
|
#
|
|
|
|
# $ ./verify-bash.sh --format=json
|
|
|
|
|
2019-11-15 00:32:02 +01:00
|
|
|
list_bash_files () {
|
2019-11-14 19:27:22 +01:00
|
|
|
git ls-files \
|
|
|
|
| xargs file \
|
|
|
|
| grep "Bourne-Again shell script" \
|
2019-11-15 00:32:02 +01:00
|
|
|
| cut -d ':' -f 1
|
2019-11-14 19:27:22 +01:00
|
|
|
}
|
|
|
|
|
2019-11-15 00:32:02 +01:00
|
|
|
main () {
|
|
|
|
shellcheck --version >&2
|
|
|
|
echo "Checking files:" >&2
|
|
|
|
list_bash_files >&2
|
2019-11-16 01:31:37 +01:00
|
|
|
list_bash_files | xargs -L 1000 shellcheck --color "$@"
|
2019-11-15 00:32:02 +01:00
|
|
|
}
|
|
|
|
|
2020-12-18 12:04:29 +00:00
|
|
|
Anotate_github () {
|
|
|
|
jq -r -j \
|
|
|
|
'.comments[]
|
|
|
|
|"::error"
|
|
|
|
," file=",.file
|
|
|
|
,",line=",.line
|
|
|
|
,"::SC",.code,": ",.message
|
|
|
|
,"\n"
|
|
|
|
' | grep "" || return 0 && return 123
|
|
|
|
# return 123 same as xargs return code would be
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ -z $GITHUB_ACTOR ]]
|
|
|
|
then
|
|
|
|
main "$@"
|
|
|
|
else
|
|
|
|
Anotate_github < <( main --format=json1 "$@" )
|
|
|
|
fi
|