Skip to content

Commit 7fd36de

Browse files
committed
Retry sketch verification after any undocumented exit code
The arduino manpage(https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#exit-status) documents a range of exit codes. These exit codes indicate success, invalid arduino command, or compilation failed due to legitimate code errors. arduino sometimes returns other exit codes that may indicate problems that may go away after a retry.
1 parent dc0c81d commit 7fd36de

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arduino-ci-script.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ VERIFICATION_OUTPUT_FILENAME="${TEMPORARY_FOLDER}/verification_output.txt"
2424
REPORT_FILENAME="travis_ci_job_report_$(printf "%05d\n" "${TRAVIS_BUILD_NUMBER}").$(printf "%03d\n" "$(echo "$TRAVIS_JOB_NUMBER" | cut -d'.' -f 2)").tsv"
2525
REPORT_FOLDER="${HOME}/arduino-ci-script_report"
2626
REPORT_FILE_PATH="${REPORT_FOLDER}/${REPORT_FILENAME}"
27-
# The Arduino IDE returns exit code 255 after a failed file signature verification of the boards manager JSON file. This does not indicate an issue with the sketch and the problem may go away after a retry.
27+
# The arduino manpage(https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#exit-status) documents a range of exit codes. These exit codes indicate success, invalid arduino command, or compilation failed due to legitimate code errors. arduino sometimes returns other exit codes that may indicate problems that may go away after a retry.
28+
HIGHEST_ACCEPTABLE_ARDUINO_EXIT_CODE=4
2829
SKETCH_VERIFY_RETRIES=3
2930
REPORT_PUSH_RETRIES=10
3031

@@ -694,9 +695,10 @@ function build_this_sketch()
694695
# Set default value of buildThisSketchExitCode
695696
local buildThisSketchExitCode=0
696697

698+
# Define a dummy value for arduinoExitCode so that the while loop will run at least once
697699
local arduinoExitCode=255
698-
# Retry the verification if it returns exit code 255
699-
while [[ "$arduinoExitCode" == "255" && $verifyCount -le $SKETCH_VERIFY_RETRIES ]]; do
700+
# Retry the verification if arduino returns an exit code that indicates there may have been a temporary error not caused by a bug in the sketch or the arduino command
701+
while [[ $arduinoExitCode -gt $HIGHEST_ACCEPTABLE_ARDUINO_EXIT_CODE && $verifyCount -le $SKETCH_VERIFY_RETRIES ]]; do
700702
# Verify the sketch
701703
arduino $VERBOSE_BUILD --verify "$sketchName" --board "$boardID" 2>&1 | tee "$VERIFICATION_OUTPUT_FILENAME"; local arduinoExitCode="${PIPESTATUS[0]}"
702704
local verifyCount=$((verifyCount + 1))

0 commit comments

Comments
 (0)