Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz committed Dec 4, 2024
1 parent 59b285c commit 995ac15
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 43 deletions.
32 changes: 15 additions & 17 deletions .github/scripts/on-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,38 @@ function build {
local chunks_cnt=$3
local build_log=$4
local sketches_file=$5
shift; shift; shift; shift; shift;
local sketches=$*
shift 5
local sketches=("$@")

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

local args="-ai $ARDUINO_IDE_PATH -au $ARDUINO_USR_PATH"

args+=" -t $target"
local args=("-ai" "$ARDUINO_IDE_PATH" "-au" "$ARDUINO_USR_PATH" "-t" "$target")

if [ "$OS_IS_LINUX" == "1" ]; then
args+=" -p $ARDUINO_ESP32_PATH/libraries"
args+=" -i $chunk_index -m $chunks_cnt"
args+=("-p" "$ARDUINO_ESP32_PATH/libraries" "-i" "$chunk_index" "-m" "$chunks_cnt")
if [ -n "$sketches_file" ]; then
args+=" -f $sketches_file"
args+=("-f" "$sketches_file")
fi
if [ "$build_log" -eq 1 ]; then
args+=" -l $build_log"
args+=("-l" "$build_log")
fi
${BUILD_SKETCHES} "${args}"
${BUILD_SKETCHES} "${args[@]}"
else
for sketch in ${sketches}; do
local sargs
for sketch in "${sketches[@]}"; do
local sargs=("${args[@]}")
local ctags_version
local preprocessor_version
sargs="$args -s $(dirname "$sketch")"
sargs+=("-s" "$(dirname "$sketch")")
if [ "$OS_IS_WINDOWS" == "1" ] && [ -d "$ARDUINO_IDE_PATH/tools-builder" ]; then
ctags_version=$(ls "$ARDUINO_IDE_PATH/tools-builder/ctags/")
preprocessor_version=$(ls "$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/")
win_opts="-prefs=runtime.tools.ctags.path=$ARDUINO_IDE_PATH/tools-builder/ctags/$ctags_version
-prefs=runtime.tools.arduino-preprocessor.path=$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/$preprocessor_version"
sargs+=" ${win_opts}"
sargs+=(
"-prefs=runtime.tools.ctags.path=$ARDUINO_IDE_PATH/tools-builder/ctags/$ctags_version"
"-prefs=runtime.tools.arduino-preprocessor.path=$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/$preprocessor_version"
)
fi
${BUILD_SKETCH} "${sargs}"
${BUILD_SKETCH} "${sargs[@]}"
done
fi
}
Expand Down
20 changes: 10 additions & 10 deletions .github/scripts/sketch_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
shift
done

xtra_opts=$*
xtra_opts=("$@")
len=0

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

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

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

function build_sketches { # build_sketches <ide_path> <user_path> <target> <path> <chunk> <total-chunks> [extra-options]

local args=""
while [ -n "$1" ]; do
echo "arg: $1"
case $1 in
-ai )
shift
Expand Down Expand Up @@ -447,7 +447,7 @@ function build_sketches { # build_sketches <ide_path> <user_path> <target> <path
shift
done

local xtra_opts=$*
local xtra_opts=("$@")

if [ -z "$chunk_index" ] || [ -z "$chunk_max" ]; then
echo "ERROR: Invalid chunk parameters"
Expand Down Expand Up @@ -546,7 +546,7 @@ function build_sketches { # build_sketches <ide_path> <user_path> <target> <path
fi
echo ""
echo "Building Sketch Index $sketchnum - $sketchdirname"
build_sketch "$args" -s "$sketchdir" "$xtra_opts"
build_sketch "$args" -s "$sketchdir" "${xtra_opts[@]}"
local result=$?
if [ $result -ne 0 ]; then
return $result
Expand Down Expand Up @@ -585,13 +585,13 @@ if [ -z "$cmd" ]; then
fi

case "$cmd" in
"count") count_sketches "$*"
"count") count_sketches "$@"
;;
"build") build_sketch "$*"
"build") build_sketch "$@"
;;
"chunk_build") build_sketches "$*"
"chunk_build") build_sketches "$@"
;;
"check_requirements") check_requirements "$*"
"check_requirements") check_requirements "$@"
;;
*)
echo "ERROR: Unrecognized command"
Expand Down
8 changes: 4 additions & 4 deletions .github/scripts/tests_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ done
source ${SCRIPTS_DIR}/install-arduino-cli.sh
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh

args="-ai $ARDUINO_IDE_PATH -au $ARDUINO_USR_PATH"
args=("-ai" "$ARDUINO_IDE_PATH" "-au" "$ARDUINO_USR_PATH")

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

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

${BUILD_CMD} "${args}" "$*"
${BUILD_CMD} "${args[@]}" "$@"
25 changes: 13 additions & 12 deletions .github/scripts/tests_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function run_test {
local result=0
local error=0
local sdkconfig_path
local extra_args

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

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

if [ $platform == "wokwi" ]; then
extra_args="--target $target --embedded-services arduino,wokwi --wokwi-timeout=$wokwi_timeout"
extra_args=("--target" "$target" "--embedded-services" "arduino,wokwi" "--wokwi-timeout=$wokwi_timeout")
if [[ -f "$sketchdir/scenario.yaml" ]]; then
extra_args+=" --wokwi-scenario $sketchdir/scenario.yaml"
extra_args+=("--wokwi-scenario" "$sketchdir/scenario.yaml")
fi
if [[ -f "$sketchdir/diagram.$target.json" ]]; then
extra_args+=" --wokwi-diagram $sketchdir/diagram.$target.json"
extra_args+=("--wokwi-diagram" "$sketchdir/diagram.$target.json")
fi

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

if [ "$target" == "esp32" ] || [ "$target" == "esp32s3" ]; then
extra_args+=" --qemu-prog-path qemu-system-xtensa --qemu-cli-args=\"-machine $target -m 4M -nographic\""
extra_args+=("--qemu-prog-path" "qemu-system-xtensa" "--qemu-cli-args=\"-machine $target -m 4M -nographic\"")
elif [ "$target" == "esp32c3" ]; then
extra_args+=" --qemu-prog-path qemu-system-riscv32 --qemu-cli-args=\"-machine $target -icount 3 -nographic\""
extra_args+=("--qemu-prog-path" "qemu-system-riscv32" "--qemu-cli-args=\"-machine $target -icount 3 -nographic\"")
else
printf "\033[91mUnsupported QEMU target: %s\033[0m\n" "$target"
exit 1
fi
else
extra_args="--embedded-services esp,arduino"
extra_args=("--embedded-services" "esp,arduino")
fi

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

result=0
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"
bash -c "set +e; pytest $sketchdir/test_$sketchname.py --build-dir $build_dir --junit-xml=$report_file $extra_args; exit \$?" || result=$?
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}"
bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" ${extra_args[*]@Q}; exit \$?" || result=$?
printf "\n"
if [ $result -ne 0 ]; then
result=0
printf "\033[95mRetrying test: %s -- Config: %s\033[0m\n" "$sketchname" "$i"
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"
bash -c "set +e; pytest $sketchdir/test_$sketchname.py --build-dir $build_dir --junit-xml=$report_file $extra_args; exit \$?" || result=$?
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}"
bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" ${extra_args[*]@Q}; exit \$?" || result=$?
printf "\n"
if [ $result -ne 0 ]; then
printf "\033[91mFailed test: %s -- Config: %s\033[0m\n\n" "$sketchname" "$i"
Expand Down
1 change: 1 addition & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ enable=add-default-case,deprecate-which,avoid-nullary-conditions
external-sources=true

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

0 comments on commit 995ac15

Please sign in to comment.