[type/__start_on_boot] Add support for NetBSD #321
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: shellcheck | |
on: [push, pull_request] | |
jobs: | |
shellcheck: | |
runs-on: ubuntu-latest | |
env: | |
SHELLCHECKOPTS: -a -x -s sh -P SCRIPTDIR -o require-variable-braces -o deprecate-which -o avoid-nullary-conditions | |
# -o check-set-e-suppressed -o check-extra-masked-returns | |
steps: | |
- name: Install shellcheck | |
shell: sh | |
run: | | |
case ${{ runner.os }} | |
in | |
(macOS) osvariant=darwin ;; | |
(Linux) osvariant=linux ;; | |
(Windows) | |
echo 'Windows runners are not supported.' >&2 | |
exit 1 | |
;; | |
(*) | |
printf 'unknown runner.os: %s\n' '${{ runner.os }}' >&2 | |
exit 1 | |
;; | |
esac | |
case ${{ runner.arch }} | |
in | |
(X86) | |
echo 'x86 runners not supported.' >&2 | |
exit 1 | |
;; | |
(X64) arch=x86_64 ;; | |
(ARM) arch=armv6hf ;; | |
(ARM64) arch=aarch64 ;; | |
(*) | |
printf 'unknown runner.arch: %s\n' '${{ runner.arch }}' >&2 | |
exit 1 | |
;; | |
esac | |
scversion=stable # stable, latest (nightly), or tag (v0.8.0) | |
baseurl=https://github.com/koalaman/shellcheck/releases/download | |
filename=shellcheck-${scversion}.${osvariant}.${arch}.tar.xz | |
mkdir -p /usr/local/bin | |
curl -s -L "${baseurl}/${scversion}/${filename}" \ | |
| tar -x -J -O "shellcheck-${scversion}/shellcheck" \ | |
>/usr/local/bin/shellcheck | |
chmod +x /usr/local/bin/shellcheck | |
- name: Display shellcheck version | |
shell: sh | |
run: | | |
command -v shellcheck | |
shellcheck --version | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Run shellcheck | |
shell: sh | |
run: | | |
# shellcheck | |
# check explorers | |
echo '::group::explorer/*' | |
find ./explorer -type f \ | |
-exec awk 'FNR==1{exit !/^#!\/bin\/sh/}' {} \; \ | |
-exec shellcheck ${SHELLCHECKOPTS-} {} + \ | |
|| steprc=1 | |
echo '::endgroup::' | |
# Check types | |
for type in ./type/*/. | |
do | |
rc=0 | |
type=${type%/.} | |
printf '::group::type/%s\n' "${type##*/}" | |
for c in \ | |
"${type}"/manifest \ | |
"${type}"/gencode-local \ | |
"${type}"/gencode-remote | |
do | |
test -e "${c}" || continue | |
shellcheck ${SHELLCHECKOPTS-} "${c}" || rc=1 | |
done | |
if test -d "${type}/explorer" | |
then | |
find "${type}/explorer" -type f \ | |
-exec awk 'FNR==1{exit !/^#!\/bin\/sh/}' {} \; \ | |
-exec shellcheck ${SHELLCHECKOPTS-} {} + \ | |
|| rc=1 | |
fi | |
if test -d "${type}/files" | |
then | |
find "${type}/files" -type f \ | |
\( -name '*.sh' -o -exec awk 'FNR==1{exit !/^#!\/bin\/sh/}' {} \; \) \ | |
-exec shellcheck ${SHELLCHECKOPTS-} {} + \ | |
|| rc=1 | |
fi | |
echo '::endgroup::' | |
if test $((rc)) -ne 0 | |
then | |
steprc=1 | |
fi | |
done | |
#exit $((steprc)) | |
- name: Scan for shellcheck errors | |
shell: sh | |
run: | | |
# shellcheck | |
proc_shellcheck_output() { | |
_rc=0 | |
OLDIFS=$IFS | |
IFS=: | |
while read -r _file _line _col _type _msg | |
do | |
printf '%s:%s:%s:%s:%s\n' \ | |
"${_file}" "${_line}" "${_col}" "${_type}" "${_msg}" | |
_type=${_type#* } | |
_msg=${_msg#* } | |
case ${_type} | |
in | |
(error) _type=error ;; | |
(warning) _type=warning ;; | |
(note) _type=notice ;; | |
(*) _type=notice ;; # ??? | |
esac | |
_sccode=$(expr "${_msg}" : '.*\[\(.*\)]$') | |
printf '::%s file=%s,line=%u,endLine=%u,title=%s::%s\n' \ | |
"${_type}" "${_file}" $((_line)) $((_line)) \ | |
"shellcheck${_sccode:+": ${_sccode}"}" "${_msg}" | |
_rc=1 | |
done | |
IFS=${OLDIFS} | |
return $((_rc)) | |
} | |
# check explorers | |
find ./explorer -type f \ | |
-exec awk 'FNR==1{exit !/^#!\/bin\/sh/}' {} \; \ | |
-exec shellcheck -f gcc ${SHELLCHECKOPTS-} {} + \ | |
| proc_shellcheck_output \ | |
|| rc=1 | |
# Check types | |
for type in ./type/*/. | |
do | |
type=${type%/.} | |
for c in \ | |
"${type}"/manifest \ | |
"${type}"/gencode-local \ | |
"${type}"/gencode-remote | |
do | |
test -e "${c}" || continue | |
shellcheck -f gcc ${SHELLCHECKOPTS-} "${c}" \ | |
| proc_shellcheck_output \ | |
|| rc=1 | |
done | |
if test -d "${type}/explorer" | |
then | |
find "${type}/explorer" -type f \ | |
-exec awk 'FNR==1{exit !/^#!\/bin\/sh/}' {} \; \ | |
-exec shellcheck -f gcc ${SHELLCHECKOPTS-} {} + \ | |
| proc_shellcheck_output \ | |
|| rc=1 | |
fi | |
if test -d "${type}/files" | |
then | |
find "${type}/files" -type f \ | |
\( -name '*.sh' -o -exec awk 'FNR==1{exit !/^#!\/bin\/sh/}' {} \; \) \ | |
-exec shellcheck -f gcc ${SHELLCHECKOPTS-} {} + \ | |
| proc_shellcheck_output \ | |
|| rc=1 | |
fi | |
done | |
exit $((rc)) |