-
Notifications
You must be signed in to change notification settings - Fork 4
227 lines (201 loc) · 6.43 KB
/
shellcheck.yml
File metadata and controls
227 lines (201 loc) · 6.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
---
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
find ./explorer -type f \
-exec awk 'FNR==1{exit !/^#!\/bin\/sh/}' {} \; \
-exec shellcheck ${SHELLCHECKOPTS-} {} + \
|| steprc=1
# Check types
for type in ./type/*/.
do
rc=0
type=${type%/.}
for c in \
"${type}"/manifest \
"${type}"/gencode-local \
"${type}"/gencode-remote
do
set --
if test -d "${c}"
then
if test -f "${c}/init"
then
set -- "$@" "${c}/init"
else
for f in "${c}"/*
do
test -f "${f}" || continue
set -- "$@" "${f}"
done
fi
elif test -f "${c}"
then
set -- "$@" "${c}"
fi
test $# -gt 0 || continue
shellcheck ${SHELLCHECKOPTS-} "$@" || 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
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
set --
if test -d "${c}"
then
if test -f "${c}/init"
then
set -- "$@" "${c}/init"
else
for f in "${c}"/*
do
test -f "${f}" || continue
set -- "$@" "${f}"
done
fi
elif test -f "${c}"
then
set -- "$@" "${c}"
fi
test $# -gt 0 || continue
shellcheck -f gcc ${SHELLCHECKOPTS-} "$@" \
| 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))