Skip to content

Commit

Permalink
Fail build if build_sketch passed invalid IDE version
Browse files Browse the repository at this point in the history
Previously the build_sketch command would return 0 if IDE version(s) that aren't installed were specified.
  • Loading branch information
per1234 committed Mar 12, 2018
1 parent 8895624 commit c9f5617
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions arduino-ci-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -769,68 +769,68 @@ function build_sketch()

if [[ "$ARDUINO_CI_SCRIPT_GENERATED_IDE_VERSION_LIST_ARRAY" == "$ARDUINO_CI_SCRIPT_IDE_VERSION_LIST_ARRAY_DECLARATION"'()' ]]; then
echo "ERROR: The IDE version(s) specified are not installed"
return_handler "$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
fi

eval "$ARDUINO_CI_SCRIPT_GENERATED_IDE_VERSION_LIST_ARRAY"
local IDEversion
for IDEversion in "${IDEversionListArray[@]}"; do
# Install the IDE
# This must be done before searching for sketches in case the path specified is in the Arduino IDE installation folder
install_ide_version "$IDEversion"

# The package_index files installed by some versions of the IDE (1.6.5, 1.6.5) can cause compilation to fail for other versions (1.6.5-r4, 1.6.5-r5). Attempting to install a dummy package ensures that the correct version of those files will be installed before the sketch verification.
# Check if the newest installed IDE version supports --install-boards
local unsupportedInstallBoardsOptionVersionsRange1regex="^1\.5\.[0-9]$"
local unsupportedInstallBoardsOptionVersionsRange2regex="^1\.6\.[0-3]$"
if ! [[ "$IDEversion" =~ $unsupportedInstallBoardsOptionVersionsRange1regex || "$IDEversion" =~ $unsupportedInstallBoardsOptionVersionsRange2regex ]]; then
# shellcheck disable=SC2086
eval \"${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/${ARDUINO_CI_SCRIPT_ARDUINO_COMMAND}\" --install-boards arduino:dummy "$ARDUINO_CI_SCRIPT_VERBOSITY_REDIRECT"
if [[ "$ARDUINO_CI_SCRIPT_VERBOSITY_LEVEL" -gt 1 ]]; then
# The warning is printed to stdout
echo "NOTE: The warning above \"Selected board is not available\" is caused intentionally and does not indicate a problem."
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
else
eval "$ARDUINO_CI_SCRIPT_GENERATED_IDE_VERSION_LIST_ARRAY"
local IDEversion
for IDEversion in "${IDEversionListArray[@]}"; do
# Install the IDE
# This must be done before searching for sketches in case the path specified is in the Arduino IDE installation folder
install_ide_version "$IDEversion"

# The package_index files installed by some versions of the IDE (1.6.5, 1.6.5) can cause compilation to fail for other versions (1.6.5-r4, 1.6.5-r5). Attempting to install a dummy package ensures that the correct version of those files will be installed before the sketch verification.
# Check if the newest installed IDE version supports --install-boards
local unsupportedInstallBoardsOptionVersionsRange1regex="^1\.5\.[0-9]$"
local unsupportedInstallBoardsOptionVersionsRange2regex="^1\.6\.[0-3]$"
if ! [[ "$IDEversion" =~ $unsupportedInstallBoardsOptionVersionsRange1regex || "$IDEversion" =~ $unsupportedInstallBoardsOptionVersionsRange2regex ]]; then
# shellcheck disable=SC2086
eval \"${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/${ARDUINO_CI_SCRIPT_ARDUINO_COMMAND}\" --install-boards arduino:dummy "$ARDUINO_CI_SCRIPT_VERBOSITY_REDIRECT"
if [[ "$ARDUINO_CI_SCRIPT_VERBOSITY_LEVEL" -gt 1 ]]; then
# The warning is printed to stdout
echo "NOTE: The warning above \"Selected board is not available\" is caused intentionally and does not indicate a problem."
fi
fi
fi

if [[ "$sketchPath" =~ \.ino$ || "$sketchPath" =~ \.pde$ ]]; then
# A sketch was specified
if ! [[ -f "$sketchPath" ]]; then
echo "ERROR: Specified sketch: $sketchPath doesn't exist"
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
elif ! build_this_sketch "$sketchPath" "$boardID" "$IDEversion" "$allowFail"; then
# build_this_sketch returned a non-zero exit status
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
fi
else
# Search for all sketches in the path and put them in an array
local sketchFound="false"
# https://github.com/koalaman/shellcheck/wiki/SC2207
declare -a sketches
mapfile -t sketches < <(find "$sketchPath" -name "*.pde" -o -name "*.ino")
local sketchName
for sketchName in "${sketches[@]}"; do
# Only verify the sketch that matches the name of the sketch folder, otherwise it will cause redundant verifications for sketches that have multiple .ino files
local sketchFolder
sketchFolder="$(echo "$sketchName" | rev | cut -d'/' -f 2 | rev)"
local sketchNameWithoutPathWithExtension
sketchNameWithoutPathWithExtension="$(echo "$sketchName" | rev | cut -d'/' -f 1 | rev)"
local sketchNameWithoutPathWithoutExtension
sketchNameWithoutPathWithoutExtension="${sketchNameWithoutPathWithExtension%.*}"
if [[ "$sketchFolder" == "$sketchNameWithoutPathWithoutExtension" ]]; then
sketchFound="true"
if ! build_this_sketch "$sketchName" "$boardID" "$IDEversion" "$allowFail"; then
# build_this_sketch returned a non-zero exit status
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
fi
if [[ "$sketchPath" =~ \.ino$ || "$sketchPath" =~ \.pde$ ]]; then
# A sketch was specified
if ! [[ -f "$sketchPath" ]]; then
echo "ERROR: Specified sketch: $sketchPath doesn't exist"
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
elif ! build_this_sketch "$sketchPath" "$boardID" "$IDEversion" "$allowFail"; then
# build_this_sketch returned a non-zero exit status
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
fi
done
else
# Search for all sketches in the path and put them in an array
local sketchFound="false"
# https://github.com/koalaman/shellcheck/wiki/SC2207
declare -a sketches
mapfile -t sketches < <(find "$sketchPath" -name "*.pde" -o -name "*.ino")
local sketchName
for sketchName in "${sketches[@]}"; do
# Only verify the sketch that matches the name of the sketch folder, otherwise it will cause redundant verifications for sketches that have multiple .ino files
local sketchFolder
sketchFolder="$(echo "$sketchName" | rev | cut -d'/' -f 2 | rev)"
local sketchNameWithoutPathWithExtension
sketchNameWithoutPathWithExtension="$(echo "$sketchName" | rev | cut -d'/' -f 1 | rev)"
local sketchNameWithoutPathWithoutExtension
sketchNameWithoutPathWithoutExtension="${sketchNameWithoutPathWithExtension%.*}"
if [[ "$sketchFolder" == "$sketchNameWithoutPathWithoutExtension" ]]; then
sketchFound="true"
if ! build_this_sketch "$sketchName" "$boardID" "$IDEversion" "$allowFail"; then
# build_this_sketch returned a non-zero exit status
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
fi
fi
done

if [[ "$sketchFound" == "false" ]]; then
echo "ERROR: No valid sketches were found in the specified path"
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
if [[ "$sketchFound" == "false" ]]; then
echo "ERROR: No valid sketches were found in the specified path"
buildSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
fi
fi
fi
done
done
fi

disable_verbosity

Expand Down

6 comments on commit c9f5617

@arduino-ci-script-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arduino-ci-script-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once completed, the job reports for Travis CI build 648 will be found at:
https://github.com/per1234/CI-reports/tree/arduino-ci-script/build_00648

@arduino-ci-script-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arduino-ci-script-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once completed, the job reports for Travis CI build 649 will be found at:
https://github.com/per1234/CI-reports/tree/arduino-ci-script/build_00649

@arduino-ci-script-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arduino-ci-script-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once completed, the job reports for Travis CI build 650 will be found at:
https://github.com/per1234/CI-reports/tree/arduino-ci-script/build_00650

Please sign in to comment.