Skip to content

Commit 995ac15

Browse files
committed
fix
1 parent 59b285c commit 995ac15

File tree

5 files changed

+43
-43
lines changed

5 files changed

+43
-43
lines changed

.github/scripts/on-push.sh

+15-17
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,38 @@ function build {
1010
local chunks_cnt=$3
1111
local build_log=$4
1212
local sketches_file=$5
13-
shift; shift; shift; shift; shift;
14-
local sketches=$*
13+
shift 5
14+
local sketches=("$@")
1515

1616
local BUILD_SKETCH="${SCRIPTS_DIR}/sketch_utils.sh build"
1717
local BUILD_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh chunk_build"
1818

19-
local args="-ai $ARDUINO_IDE_PATH -au $ARDUINO_USR_PATH"
20-
21-
args+=" -t $target"
19+
local args=("-ai" "$ARDUINO_IDE_PATH" "-au" "$ARDUINO_USR_PATH" "-t" "$target")
2220

2321
if [ "$OS_IS_LINUX" == "1" ]; then
24-
args+=" -p $ARDUINO_ESP32_PATH/libraries"
25-
args+=" -i $chunk_index -m $chunks_cnt"
22+
args+=("-p" "$ARDUINO_ESP32_PATH/libraries" "-i" "$chunk_index" "-m" "$chunks_cnt")
2623
if [ -n "$sketches_file" ]; then
27-
args+=" -f $sketches_file"
24+
args+=("-f" "$sketches_file")
2825
fi
2926
if [ "$build_log" -eq 1 ]; then
30-
args+=" -l $build_log"
27+
args+=("-l" "$build_log")
3128
fi
32-
${BUILD_SKETCHES} "${args}"
29+
${BUILD_SKETCHES} "${args[@]}"
3330
else
34-
for sketch in ${sketches}; do
35-
local sargs
31+
for sketch in "${sketches[@]}"; do
32+
local sargs=("${args[@]}")
3633
local ctags_version
3734
local preprocessor_version
38-
sargs="$args -s $(dirname "$sketch")"
35+
sargs+=("-s" "$(dirname "$sketch")")
3936
if [ "$OS_IS_WINDOWS" == "1" ] && [ -d "$ARDUINO_IDE_PATH/tools-builder" ]; then
4037
ctags_version=$(ls "$ARDUINO_IDE_PATH/tools-builder/ctags/")
4138
preprocessor_version=$(ls "$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/")
42-
win_opts="-prefs=runtime.tools.ctags.path=$ARDUINO_IDE_PATH/tools-builder/ctags/$ctags_version
43-
-prefs=runtime.tools.arduino-preprocessor.path=$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/$preprocessor_version"
44-
sargs+=" ${win_opts}"
39+
sargs+=(
40+
"-prefs=runtime.tools.ctags.path=$ARDUINO_IDE_PATH/tools-builder/ctags/$ctags_version"
41+
"-prefs=runtime.tools.arduino-preprocessor.path=$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/$preprocessor_version"
42+
)
4543
fi
46-
${BUILD_SKETCH} "${sargs}"
44+
${BUILD_SKETCH} "${sargs[@]}"
4745
done
4846
fi
4947
}

.github/scripts/sketch_utils.sh

+10-10
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
9999
shift
100100
done
101101

102-
xtra_opts=$*
102+
xtra_opts=("$@")
103103
len=0
104104

105105
if [ -z "$sketchdir" ]; then
@@ -268,7 +268,7 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
268268
--build-property "compiler.warning_flags.all=-Wall -Werror=all -Wextra" \
269269
--build-cache-path "$ARDUINO_CACHE_DIR" \
270270
--build-path "$build_dir" \
271-
"$xtra_opts" "${sketchdir}" \
271+
"${xtra_opts[@]}" "${sketchdir}" \
272272
2>&1 | tee "$output_file"
273273

274274
exit_status=${PIPESTATUS[0]}
@@ -313,7 +313,7 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
313313
-libraries "$user_path/libraries" \
314314
-build-cache "$ARDUINO_CACHE_DIR" \
315315
-build-path "$build_dir" \
316-
"$xtra_opts" "${sketchdir}/${sketchname}.ino"
316+
"${xtra_opts[@]}" "${sketchdir}/${sketchname}.ino"
317317

318318
exit_status=$?
319319
if [ $exit_status -ne 0 ]; then
@@ -398,9 +398,9 @@ function count_sketches { # count_sketches <path> [target] [file] [ignore-requir
398398
}
399399

400400
function build_sketches { # build_sketches <ide_path> <user_path> <target> <path> <chunk> <total-chunks> [extra-options]
401-
402401
local args=""
403402
while [ -n "$1" ]; do
403+
echo "arg: $1"
404404
case $1 in
405405
-ai )
406406
shift
@@ -447,7 +447,7 @@ function build_sketches { # build_sketches <ide_path> <user_path> <target> <path
447447
shift
448448
done
449449

450-
local xtra_opts=$*
450+
local xtra_opts=("$@")
451451

452452
if [ -z "$chunk_index" ] || [ -z "$chunk_max" ]; then
453453
echo "ERROR: Invalid chunk parameters"
@@ -546,7 +546,7 @@ function build_sketches { # build_sketches <ide_path> <user_path> <target> <path
546546
fi
547547
echo ""
548548
echo "Building Sketch Index $sketchnum - $sketchdirname"
549-
build_sketch "$args" -s "$sketchdir" "$xtra_opts"
549+
build_sketch "$args" -s "$sketchdir" "${xtra_opts[@]}"
550550
local result=$?
551551
if [ $result -ne 0 ]; then
552552
return $result
@@ -585,13 +585,13 @@ if [ -z "$cmd" ]; then
585585
fi
586586

587587
case "$cmd" in
588-
"count") count_sketches "$*"
588+
"count") count_sketches "$@"
589589
;;
590-
"build") build_sketch "$*"
590+
"build") build_sketch "$@"
591591
;;
592-
"chunk_build") build_sketches "$*"
592+
"chunk_build") build_sketches "$@"
593593
;;
594-
"check_requirements") check_requirements "$*"
594+
"check_requirements") check_requirements "$@"
595595
;;
596596
*)
597597
echo "ERROR: Unrecognized command"

.github/scripts/tests_build.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ done
5454
source ${SCRIPTS_DIR}/install-arduino-cli.sh
5555
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
5656

57-
args="-ai $ARDUINO_IDE_PATH -au $ARDUINO_USR_PATH"
57+
args=("-ai" "$ARDUINO_IDE_PATH" "-au" "$ARDUINO_USR_PATH")
5858

5959
if [[ $test_type == "all" ]] || [[ -z $test_type ]]; then
6060
if [ -n "$sketch" ]; then
@@ -71,10 +71,10 @@ fi
7171

7272
if [ $chunk_build -eq 1 ]; then
7373
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh chunk_build"
74-
args+=" -p $test_folder -i 0 -m 1"
74+
args+=("-p" "$test_folder" "-i" "0" "-m" "1")
7575
else
7676
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh build"
77-
args+=" -s $test_folder/$sketch"
77+
args+=("-s" "$test_folder/$sketch")
7878
fi
7979

80-
${BUILD_CMD} "${args}" "$*"
80+
${BUILD_CMD} "${args[@]}" "$@"

.github/scripts/tests_run.sh

+13-12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function run_test {
1010
local result=0
1111
local error=0
1212
local sdkconfig_path
13+
local extra_args
1314

1415
sketchdir=$(dirname "$sketch")
1516
sketchname=$(basename "$sketchdir")
@@ -32,7 +33,7 @@ function run_test {
3233
if [ -f "$sketchdir"/ci.json ]; then
3334
# If the target or platform is listed as false, skip the sketch. Otherwise, include it.
3435
is_target=$(jq -r --arg target "$target" '.targets[$target]' "$sketchdir"/ci.json)
35-
selected_platform=$(jq -r --arg platform $platform '.platforms[$platform]' "$sketchdir"/ci.json)
36+
selected_platform=$(jq -r --arg platform "$platform" '.platforms[$platform]' "$sketchdir"/ci.json)
3637

3738
if [[ $is_target == "false" ]] || [[ $selected_platform == "false" ]]; then
3839
printf "\033[93mSkipping %s test for %s, platform: %s\033[0m\n" "$sketchname" "$target" "$platform"
@@ -85,41 +86,41 @@ function run_test {
8586
fi
8687

8788
if [ $platform == "wokwi" ]; then
88-
extra_args="--target $target --embedded-services arduino,wokwi --wokwi-timeout=$wokwi_timeout"
89+
extra_args=("--target" "$target" "--embedded-services" "arduino,wokwi" "--wokwi-timeout=$wokwi_timeout")
8990
if [[ -f "$sketchdir/scenario.yaml" ]]; then
90-
extra_args+=" --wokwi-scenario $sketchdir/scenario.yaml"
91+
extra_args+=("--wokwi-scenario" "$sketchdir/scenario.yaml")
9192
fi
9293
if [[ -f "$sketchdir/diagram.$target.json" ]]; then
93-
extra_args+=" --wokwi-diagram $sketchdir/diagram.$target.json"
94+
extra_args+=("--wokwi-diagram" "$sketchdir/diagram.$target.json")
9495
fi
9596

9697
elif [ $platform == "qemu" ]; then
9798
PATH=$HOME/qemu/bin:$PATH
98-
extra_args="--embedded-services qemu --qemu-image-path $build_dir/$sketchname.ino.merged.bin"
99+
extra_args=("--embedded-services" "qemu" "--qemu-image-path" "$build_dir/$sketchname.ino.merged.bin")
99100

100101
if [ "$target" == "esp32" ] || [ "$target" == "esp32s3" ]; then
101-
extra_args+=" --qemu-prog-path qemu-system-xtensa --qemu-cli-args=\"-machine $target -m 4M -nographic\""
102+
extra_args+=("--qemu-prog-path" "qemu-system-xtensa" "--qemu-cli-args=\"-machine $target -m 4M -nographic\"")
102103
elif [ "$target" == "esp32c3" ]; then
103-
extra_args+=" --qemu-prog-path qemu-system-riscv32 --qemu-cli-args=\"-machine $target -icount 3 -nographic\""
104+
extra_args+=("--qemu-prog-path" "qemu-system-riscv32" "--qemu-cli-args=\"-machine $target -icount 3 -nographic\"")
104105
else
105106
printf "\033[91mUnsupported QEMU target: %s\033[0m\n" "$target"
106107
exit 1
107108
fi
108109
else
109-
extra_args="--embedded-services esp,arduino"
110+
extra_args=("--embedded-services" "esp,arduino")
110111
fi
111112

112113
rm "$sketchdir"/diagram.json 2>/dev/null || true
113114

114115
result=0
115-
printf "\033[95mpytest %s/test_%s.py --build-dir %s --junit-xml=%s %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "$extra_args"
116-
bash -c "set +e; pytest $sketchdir/test_$sketchname.py --build-dir $build_dir --junit-xml=$report_file $extra_args; exit \$?" || result=$?
116+
printf "\033[95mpytest \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "${extra_args[*]@Q}"
117+
bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" ${extra_args[*]@Q}; exit \$?" || result=$?
117118
printf "\n"
118119
if [ $result -ne 0 ]; then
119120
result=0
120121
printf "\033[95mRetrying test: %s -- Config: %s\033[0m\n" "$sketchname" "$i"
121-
printf "\033[95mpytest %s/test_%s.py --build-dir %s --junit-xml=%s %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "$extra_args"
122-
bash -c "set +e; pytest $sketchdir/test_$sketchname.py --build-dir $build_dir --junit-xml=$report_file $extra_args; exit \$?" || result=$?
122+
printf "\033[95mpytest \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "${extra_args[*]@Q}"
123+
bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" ${extra_args[*]@Q}; exit \$?" || result=$?
123124
printf "\n"
124125
if [ $result -ne 0 ]; then
125126
printf "\033[91mFailed test: %s -- Config: %s\033[0m\n\n" "$sketchname" "$i"

.shellcheckrc

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ enable=add-default-case,deprecate-which,avoid-nullary-conditions
77
external-sources=true
88

99
# Search folder for sourced files
10+
# Considering the scripts being in .github/scripts, the source path is set to the root of the repository.
1011
source-path=SCRIPTDIR/../..

0 commit comments

Comments
 (0)