Skip to content

Commit 5c35fba

Browse files
committed
Fail the sketch build if no sketches were found
1 parent ebae5e5 commit 5c35fba

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

arduino-ci-script.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,12 +695,16 @@ function build_sketch()
695695

696696
if [[ "$sketchPath" =~ \.ino$ || "$sketchPath" =~ \.pde$ ]]; then
697697
# A sketch was specified
698-
if ! build_this_sketch "$sketchPath" "$boardID" "$IDEversion" "$allowFail"; then
698+
if ! [[ -f "$sketchPath" ]]; then
699+
echo "ERROR: Specified sketch: $sketchPath doesn't exist"
700+
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
701+
elif ! build_this_sketch "$sketchPath" "$boardID" "$IDEversion" "$allowFail"; then
699702
# build_this_sketch returned a non-zero exit status
700703
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
701704
fi
702705
else
703706
# Search for all sketches in the path and put them in an array
707+
local sketchFound="false"
704708
# https://github.com/koalaman/shellcheck/wiki/SC2207
705709
declare -a sketches
706710
mapfile -t sketches < <(find "$sketchPath" -name "*.pde" -o -name "*.ino")
@@ -714,12 +718,18 @@ function build_sketch()
714718
local sketchNameWithoutPathWithoutExtension
715719
sketchNameWithoutPathWithoutExtension="${sketchNameWithoutPathWithExtension%.*}"
716720
if [[ "$sketchFolder" == "$sketchNameWithoutPathWithoutExtension" ]]; then
721+
sketchFound="true"
717722
if ! build_this_sketch "$sketchName" "$boardID" "$IDEversion" "$allowFail"; then
718723
# build_this_sketch returned a non-zero exit status
719724
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
720725
fi
721726
fi
722727
done
728+
729+
if [[ "$sketchFound" == "false" ]]; then
730+
echo "ERROR: No valid sketches were found in the specified path"
731+
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
732+
fi
723733
fi
724734
done
725735

0 commit comments

Comments
 (0)