Skip to content

Commit 034d69e

Browse files
committed
ci: add shellcheck gh action; fix fatal shellcheck errors
This commit made with the assistance of github copilot Signed-off-by: Morgan Rockett <[email protected]>
1 parent f6e5401 commit 034d69e

8 files changed

+358
-21
lines changed

.github/workflows/ci.yml

+21-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@v4
2626
with:
2727
submodules: recursive
28-
- name: Setup Build Env
28+
- name: Install Build Tools
2929
run: sudo ./scripts/install-build-tools.sh
3030
- name: Setup Local Dependencies
3131
run: ./scripts/setup-dependencies.sh
@@ -38,7 +38,7 @@ jobs:
3838
- uses: actions/checkout@v4
3939
with:
4040
submodules: recursive
41-
- name: Setup Build Env
41+
- name: Install Build Tools
4242
run: sudo ./scripts/install-build-tools.sh
4343
- name: Setup Local Dependencies
4444
run: ./scripts/setup-dependencies.sh
@@ -50,7 +50,7 @@ jobs:
5050
name: Pylint
5151
runs-on: ubuntu-22.04
5252
continue-on-error: true
53-
timeout-minutes: 10
53+
timeout-minutes: 5
5454
strategy:
5555
matrix:
5656
python-version: ["3.10"]
@@ -62,10 +62,25 @@ jobs:
6262
uses: actions/setup-python@v5
6363
with:
6464
python-version: ${{ matrix.python-version }}
65-
- name: Setup Build Env
65+
- name: Install Build Tools
6666
run: sudo ./scripts/install-build-tools.sh
6767
- name: Lint with Pylint
6868
run: ./scripts/pylint.sh
69+
shellcheck:
70+
name: Shellcheck
71+
runs-on: ubuntu-22.04
72+
continue-on-error: true
73+
timeout-minutes: 5
74+
steps:
75+
- uses: actions/checkout@v4
76+
with:
77+
submodules: recursive
78+
- name: Install shellcheck
79+
run: |
80+
sudo apt-get update
81+
sudo apt-get install -y shellcheck
82+
- name: Lint with Shellcheck
83+
run: ./scripts/shellcheck.sh -S error --color=auto
6984
unit-and-integration-test:
7085
name: Unit and Integration Tests
7186
runs-on: ubuntu-22.04
@@ -74,7 +89,7 @@ jobs:
7489
- uses: actions/checkout@v4
7590
with:
7691
submodules: recursive
77-
- name: Setup Build Env
92+
- name: Install Build Tools
7893
run: sudo ./scripts/install-build-tools.sh
7994
- name: Setup Local Dependencies
8095
run: ./scripts/setup-dependencies.sh
@@ -84,7 +99,7 @@ jobs:
8499
run: ./scripts/test.sh
85100
- name: Shorten SHA
86101
id: vars
87-
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
102+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
88103
- uses: actions/upload-artifact@v4
89104
if: ${{ !env.ACT }}
90105
name: Archive Test Results
@@ -114,4 +129,3 @@ jobs:
114129
name: OpenCBDC Transaction Processor docs for ${{ steps.vars.outputs.sha_short }}
115130
path: ./doxygen_generated/html/*
116131
retention-days: 7
117-

scripts/create-e2e-report.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ function readAndFormatLogs() {
1111
return
1212
fi
1313

14-
for logfile in $(ls $logdir); do
14+
for logfile in "$logdir"/*; do
1515
logfile_path="$logdir/$logfile"
16-
logfile_content=$(cat $logfile_path)
16+
logfile_content=$(<"$logfile_path")
1717
message+="\n<details>\n<summary>$logfile</summary>\n\n\`\`\`\n$logfile_content\n\`\`\`\n</details>\n"
1818
done
1919
echo "$message"

scripts/install-build-tools.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fi
1717

1818
# Supporting these versions for buildflow
1919
PYTHON_VERSIONS=("3.10" "3.11" "3.12")
20-
echo "Python3 versions supported: ${PYTHON_VERSIONS[@]}"
20+
echo "Python3 versions supported: ${PYTHON_VERSIONS[*]}"
2121

2222
# check if supported version of python3 is already installed, and save the version
2323
PY_INSTALLED=''

scripts/lint.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ if [ -n "$whitespace_files" ] || [ -n "$newline_files" ] ; then
2525
exit 1
2626
fi
2727

28-
check_format_files=$(git ls-files | grep -E "tools|tests|src|cmake-tests" \
29-
| grep -E "\..*pp")
30-
clang-format --style=file --Werror --dry-run ${check_format_files[@]}
28+
check_format_files=$(git ls-files | \
29+
grep -E "tools|tests|src|cmake-tests" | \
30+
grep -E "\..*pp")
31+
32+
echo "${check_format_files}" | \
33+
xargs -n1 -I{} clang-format --style=file --Werror --dry-run {}
3134

3235
if ! command -v clang-tidy &>/dev/null; then
3336
echo "clang-tidy does not appear to be installed"

scripts/native-system-benchmark.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ on_int() {
151151
printf 'Interrupting all components\n'
152152
trap '' SIGINT # avoid interrupting ourself
153153
for i in $PIDS; do # intentionally unquoted
154-
if [[ -n "RECORD" ]]; then
154+
if [[ -n "$RECORD" ]]; then
155155
kill -SIGINT -- "-$i"
156156
else
157157
kill -SIGINT -- "$i"
@@ -194,7 +194,7 @@ on_int() {
194194

195195
printf 'Terminating any remaining processes\n'
196196
for i in $PIDS; do # intentionally unquoted
197-
if [[ -n "RECORD" ]]; then
197+
if [[ -n "$RECORD" ]]; then
198198
kill -SIGTERM -- "-$i"
199199
else
200200
kill -SIGTERM -- "$i"
@@ -253,15 +253,15 @@ run() {
253253
COMP=
254254
case "$RECORD" in
255255
perf)
256-
$@ &> "$PROC_LOG" &
256+
"$@" &> "$PROC_LOG" &
257257
COMP="$!"
258258
perf record -F 99 -a -g -o "$PNAME".perf -p "$COMP" &> "$PERF_LOG" &
259259
PERFS="$PERFS $!";;
260260
debug)
261261
${DBG} "$@" &> "$PROC_LOG" &
262262
COMP="$!";;
263263
*)
264-
$@ &> "$PROC_LOG" &
264+
"$@" &> "$PROC_LOG" &
265265
COMP="$!";;
266266
esac
267267

@@ -324,7 +324,7 @@ launch() {
324324
"$RT"/scripts/wait-for-it.sh -q -t 5 -h localhost -p "$ep"
325325
done
326326
printf 'Launched logical %s %d, replica %d [PID: %d]\n' "$1" "$id" "$node" "$PID"
327-
if [[ -n "RECORD" ]]; then
327+
if [[ -n "$RECORD" ]]; then
328328
PIDS="$PIDS $(getpgid $PID)"
329329
else
330330
PIDS="$PIDS $PID"
@@ -337,7 +337,7 @@ launch() {
337337
"$RT"/scripts/wait-for-it.sh -q -t 5 -h localhost -p "$ep"
338338
done
339339
printf 'Launched %s %d [PID: %d]\n' "$1" "$id" "$PID"
340-
if [[ -n "RECORD" ]]; then
340+
if [[ -n "$RECORD" ]]; then
341341
PIDS="$PIDS $(getpgid $PID)"
342342
else
343343
PIDS="$PIDS $PID"

0 commit comments

Comments
 (0)