Skip to content

Commit 94a7ff9

Browse files
committed
Use "exit status" instead of "exit code"
"Exit status" seems to be the more correct term.
1 parent 12657b9 commit 94a7ff9

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Turn on/off arduino verbose output during compilation. This will show all the co
9797
##### `build_sketch sketchPath boardID allowFail IDEversion`
9898
##### `build_sketch sketchPath boardID allowFail [IDEversionList]`
9999
##### `build_sketch sketchPath boardID allowFail startIDEversion endIDEversion`
100-
Pass some parameters from .travis.yml to the script. `build_sketch` will echo the arduino exit code to the log, which is documented at https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#exit-status.
100+
Pass some parameters from .travis.yml to the script. `build_sketch` will echo the arduino exit status to the log, which is documented at https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#exit-status.
101101
- Parameter: **sketchPath** - Path to a sketch or folder containing sketches. If a folder is specified it will be recursively searched and all sketches will be verified.
102102
- Parameter: **boardID** - `package:arch:board[:parameters]` ID of the board to be compiled for. e.g. `arduino:avr:uno`. Board-specific parameters are only supported by Arduino IDE 1.5.5 and newer.
103103
- Parameter: **allowFail** - `true`, `require`, or `false`. Allow the verification to fail without causing the CI build to fail. `require` will cause the build to fail if the sketch verification doesn't fail.
@@ -126,7 +126,7 @@ Echo a tab separated report of all verification results to the log. The report i
126126
- Dynamic Memory (bytes) - Dynamic memory usage by global variables in the compiled sketch (not available for some boards).
127127
- # Warnings - Number of warnings reported by the compiler during the sketch compilation.
128128
- Allow Failure - Whether the sketch verification was allowed to fail (set by the `allowFail` argument of `build_sketch`).
129-
- Exit Code - Exit code returned by arduino after the sketch verification.
129+
- Exit Status - Exit status returned by arduino after the sketch verification.
130130
- # Board Issues - The number of board issues detected.
131131
- Board Issue - Short description of the last board issue detected.
132132

arduino-ci-script.sh

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ readonly ARDUINO_CI_SCRIPT_VERIFICATION_OUTPUT_FILENAME="${ARDUINO_CI_SCRIPT_TEM
2020
readonly ARDUINO_CI_SCRIPT_REPORT_FILENAME="travis_ci_job_report_$(printf "%05d\n" "${TRAVIS_BUILD_NUMBER}").$(printf "%03d\n" "$(echo "$TRAVIS_JOB_NUMBER" | cut -d'.' -f 2)").tsv"
2121
readonly ARDUINO_CI_SCRIPT_REPORT_FOLDER="${HOME}/arduino-ci-script_report"
2222
readonly ARDUINO_CI_SCRIPT_REPORT_FILE_PATH="${ARDUINO_CI_SCRIPT_REPORT_FOLDER}/${ARDUINO_CI_SCRIPT_REPORT_FILENAME}"
23-
# 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.
24-
readonly ARDUINO_CI_SCRIPT_HIGHEST_ACCEPTABLE_ARDUINO_EXIT_CODE=4
23+
# The arduino manpage(https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#exit-status) documents a range of exit statuses. These exit statuses indicate success, invalid arduino command, or compilation failed due to legitimate code errors. arduino sometimes returns other exit statuses that may indicate problems that may go away after a retry.
24+
readonly ARDUINO_CI_SCRIPT_HIGHEST_ACCEPTABLE_ARDUINO_EXIT_STATUS=4
2525
readonly ARDUINO_CI_SCRIPT_SKETCH_VERIFY_RETRIES=3
2626
readonly ARDUINO_CI_SCRIPT_REPORT_PUSH_RETRIES=10
2727

@@ -183,7 +183,7 @@ function install_ide()
183183
local -r endIDEversion="$2"
184184

185185
# https://docs.travis-ci.com/user/customizing-the-build/#Implementing-Complex-Build-Steps
186-
# set -o errexit will cause the script to exit as soon as any command returns a non-zero exit code. Without this the success of the function call is determined by the exit code of the last command in the function
186+
# set -o errexit will cause the script to exit as soon as any command returns a non-zero exit status. Without this the success of the function call is determined by the exit status of the last command in the function
187187
set -o errexit
188188

189189
generate_ide_version_list_array "$ARDUINO_CI_SCRIPT_FULL_IDE_VERSION_LIST_ARRAY" "$startIDEversion" "$endIDEversion"
@@ -654,8 +654,8 @@ function build_sketch()
654654
local -r startIDEversion="$4"
655655
local -r endIDEversion="$5"
656656

657-
# Set default value for buildSketchExitCode
658-
local buildSketchExitCode="$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS"
657+
# Set default value for buildSketchExitStatus
658+
local buildSketchExitStatus="$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS"
659659

660660
generate_ide_version_list_array "$INSTALLED_IDE_VERSION_LIST_ARRAY" "$startIDEversion" "$endIDEversion"
661661

@@ -682,8 +682,8 @@ function build_sketch()
682682
if [[ "$sketchPath" =~ \.ino$ || "$sketchPath" =~ \.pde$ ]]; then
683683
# A sketch was specified
684684
if ! build_this_sketch "$sketchPath" "$boardID" "$IDEversion" "$allowFail"; then
685-
# build_this_sketch returned a non-zero exit code
686-
buildSketchExitCode=1
685+
# build_this_sketch returned a non-zero exit status
686+
buildSketchExitStatus=1
687687
fi
688688
else
689689
# Search for all sketches in the path and put them in an array
@@ -701,8 +701,8 @@ function build_sketch()
701701
sketchNameWithoutPathWithoutExtension="${sketchNameWithoutPathWithExtension%.*}"
702702
if [[ "$sketchFolder" == "$sketchNameWithoutPathWithoutExtension" ]]; then
703703
if ! build_this_sketch "$sketchName" "$boardID" "$IDEversion" "$allowFail"; then
704-
# build_this_sketch returned a non-zero exit code
705-
buildSketchExitCode=1;
704+
# build_this_sketch returned a non-zero exit status
705+
buildSketchExitStatus=1;
706706
fi
707707
fi
708708
done
@@ -711,7 +711,7 @@ function build_sketch()
711711

712712
disable_verbosity
713713

714-
return $buildSketchExitCode
714+
return $buildSketchExitStatus
715715
}
716716

717717

@@ -733,33 +733,33 @@ function build_this_sketch()
733733
local absoluteSketchName
734734
absoluteSketchName="$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
735735

736-
# Define a dummy value for arduinoExitCode so that the while loop will run at least once
737-
local arduinoExitCode=255
738-
# 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
739-
while [[ $arduinoExitCode -gt $ARDUINO_CI_SCRIPT_HIGHEST_ACCEPTABLE_ARDUINO_EXIT_CODE && $verifyCount -le $ARDUINO_CI_SCRIPT_SKETCH_VERIFY_RETRIES ]]; do
736+
# Define a dummy value for arduinoExitStatus so that the while loop will run at least once
737+
local arduinoExitStatus=255
738+
# Retry the verification if arduino returns an exit status that indicates there may have been a temporary error not caused by a bug in the sketch or the arduino command
739+
while [[ $arduinoExitStatus -gt $ARDUINO_CI_SCRIPT_HIGHEST_ACCEPTABLE_ARDUINO_EXIT_STATUS && $verifyCount -le $ARDUINO_CI_SCRIPT_SKETCH_VERIFY_RETRIES ]]; do
740740
# Verify the sketch
741741
# shellcheck disable=SC2086
742-
"${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/arduino" $ARDUINO_CI_SCRIPT_DETERMINED_VERBOSE_BUILD --verify "$absoluteSketchName" --board "$boardID" 2>&1 | tee "$ARDUINO_CI_SCRIPT_VERIFICATION_OUTPUT_FILENAME"; local arduinoExitCode="${PIPESTATUS[0]}"
742+
"${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/arduino" $ARDUINO_CI_SCRIPT_DETERMINED_VERBOSE_BUILD --verify "$absoluteSketchName" --board "$boardID" 2>&1 | tee "$ARDUINO_CI_SCRIPT_VERIFICATION_OUTPUT_FILENAME"; local arduinoExitStatus="${PIPESTATUS[0]}"
743743
local verifyCount=$((verifyCount + 1))
744744
done
745745

746-
if [[ "$arduinoExitCode" != "$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS" ]]; then
746+
if [[ "$arduinoExitStatus" != "$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS" ]]; then
747747
# Sketch build failed
748748
if [[ "$allowFail" == "true" || "$allowFail" == "require" ]]; then
749749
# Failure is allowed for this test
750-
local -r buildThisSketchExitCode="$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS"
750+
local -r buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS"
751751
else
752752
# Failure is not allowed for this test, fail the Travis build after completing all sketch builds
753-
local -r buildThisSketchExitCode="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
753+
local -r buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
754754
fi
755755
else
756756
# Sketch build succeeded
757757
if [[ "$allowFail" == "require" ]]; then
758758
# Failure is required for this test, fail the Travis build after completing all sketch builds
759-
local -r buildThisSketchExitCode="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
759+
local -r buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
760760
else
761761
# Success is allowed
762-
local -r buildThisSketchExitCode="$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS"
762+
local -r buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS"
763763
fi
764764

765765
# Parse through the output from the sketch verification to count warnings and determine the compile size
@@ -800,20 +800,20 @@ function build_this_sketch()
800800

801801
if [[ "$boardIssue" != "" && "$ARDUINO_CI_SCRIPT_TEST_BOARD" == "true" && "$allowFail" != "true" ]]; then
802802
# There was a board issue and board testing is enabled so fail the build
803-
local -r buildThisSketchExitCode="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
803+
local -r buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
804804
fi
805805
fi
806806

807807
# Add the build data to the report file
808-
echo "$(date -u "+%Y-%m-%d %H:%M:%S")"$'\t'"$TRAVIS_BUILD_NUMBER"$'\t'"$TRAVIS_JOB_NUMBER"$'\t'"https://travis-ci.org/${TRAVIS_REPO_SLUG}/jobs/${TRAVIS_JOB_ID}"$'\t'"$TRAVIS_EVENT_TYPE"$'\t'"$TRAVIS_ALLOW_FAILURE"$'\t'"$TRAVIS_PULL_REQUEST"$'\t'"$TRAVIS_BRANCH"$'\t'"$TRAVIS_COMMIT"$'\t'"$TRAVIS_COMMIT_RANGE"$'\t'"${TRAVIS_COMMIT_MESSAGE%%$'\n'*}"$'\t'"$sketchName"$'\t'"$boardID"$'\t'"$IDEversion"$'\t'"$programStorage"$'\t'"$dynamicMemory"$'\t'"$warningCount"$'\t'"$allowFail"$'\t'"$arduinoExitCode"$'\t'"$boardIssueCount"$'\t'"$boardIssue"$'\r' >> "$ARDUINO_CI_SCRIPT_REPORT_FILE_PATH"
808+
echo "$(date -u "+%Y-%m-%d %H:%M:%S")"$'\t'"$TRAVIS_BUILD_NUMBER"$'\t'"$TRAVIS_JOB_NUMBER"$'\t'"https://travis-ci.org/${TRAVIS_REPO_SLUG}/jobs/${TRAVIS_JOB_ID}"$'\t'"$TRAVIS_EVENT_TYPE"$'\t'"$TRAVIS_ALLOW_FAILURE"$'\t'"$TRAVIS_PULL_REQUEST"$'\t'"$TRAVIS_BRANCH"$'\t'"$TRAVIS_COMMIT"$'\t'"$TRAVIS_COMMIT_RANGE"$'\t'"${TRAVIS_COMMIT_MESSAGE%%$'\n'*}"$'\t'"$sketchName"$'\t'"$boardID"$'\t'"$IDEversion"$'\t'"$programStorage"$'\t'"$dynamicMemory"$'\t'"$warningCount"$'\t'"$allowFail"$'\t'"$arduinoExitStatus"$'\t'"$boardIssueCount"$'\t'"$boardIssue"$'\r' >> "$ARDUINO_CI_SCRIPT_REPORT_FILE_PATH"
809809

810810
# End the folded section of the Travis CI build log
811811
echo -e "travis_fold:end:build_sketch"
812812
# Add a useful message to the Travis CI build log
813813

814-
echo "arduino exit code: $arduinoExitCode"
814+
echo "arduino exit status: $arduinoExitStatus"
815815

816-
return $buildThisSketchExitCode
816+
return $buildThisSketchExitStatus
817817
}
818818

819819

@@ -866,17 +866,17 @@ function publish_report_to_repository()
866866
# Do a pull now in case another job has finished about the same time and pushed a report after the clone happened, which would otherwise cause the push to fail. This is the last chance to pull without having to deal with a merge or rebase.
867867
git pull $ARDUINO_CI_SCRIPT_QUIET_OPTION
868868
git commit $ARDUINO_CI_SCRIPT_QUIET_OPTION $ARDUINO_CI_SCRIPT_VERBOSITY_OPTION --message="Add Travis CI job ${TRAVIS_JOB_NUMBER} report (${jobSuccessMessage})" --message="Job log: https://travis-ci.org/${TRAVIS_REPO_SLUG}/jobs/${TRAVIS_JOB_ID}" --message="Commit: https://github.com/${TRAVIS_REPO_SLUG}/commit/${TRAVIS_COMMIT}" --message="$TRAVIS_COMMIT_MESSAGE" --message="[skip ci]"
869-
local gitPushExitCode="1"
869+
local gitPushExitStatus="1"
870870
local pushCount=0
871-
while [[ "$gitPushExitCode" != "$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS" && $pushCount -le $ARDUINO_CI_SCRIPT_REPORT_PUSH_RETRIES ]]; do
871+
while [[ "$gitPushExitStatus" != "$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS" && $pushCount -le $ARDUINO_CI_SCRIPT_REPORT_PUSH_RETRIES ]]; do
872872
pushCount=$((pushCount + 1))
873873
# Do a pull now in case another job has finished about the same time and pushed a report since the last pull. This would require a merge or rebase. Rebase should be safe since the commits will be separate files.
874874
git pull $ARDUINO_CI_SCRIPT_QUIET_OPTION --rebase
875875
git push $ARDUINO_CI_SCRIPT_QUIET_OPTION $ARDUINO_CI_SCRIPT_VERBOSITY_OPTION "https://${token}@${repositoryURL#*//}"
876-
gitPushExitCode="$?"
876+
gitPushExitStatus="$?"
877877
done
878878
rm --recursive --force "${HOME}/report-repository"
879-
if [[ "$gitPushExitCode" == "$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS" ]]; then
879+
if [[ "$gitPushExitStatus" == "$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS" ]]; then
880880
if [[ "$doLinkComment" == "true" ]]; then
881881
# Only comment if it's job 1
882882
local -r firstJobRegex="\.1$"
@@ -981,7 +981,7 @@ create_folder "$ARDUINO_CI_SCRIPT_REPORT_FOLDER"
981981

982982

983983
# Add column names to report
984-
echo "Build Timestamp (UTC)"$'\t'"Build"$'\t'"Job"$'\t'"Job URL"$'\t'"Build Trigger"$'\t'"Allow Job Failure"$'\t'"PR#"$'\t'"Branch"$'\t'"Commit"$'\t'"Commit Range"$'\t'"Commit Message"$'\t'"Sketch Filename"$'\t'"Board ID"$'\t'"IDE Version"$'\t'"Program Storage (bytes)"$'\t'"Dynamic Memory (bytes)"$'\t'"# Warnings"$'\t'"Allow Failure"$'\t'"Exit Code"$'\t'"# Board Issues"$'\t'"Board Issue"$'\r' > "$ARDUINO_CI_SCRIPT_REPORT_FILE_PATH"
984+
echo "Build Timestamp (UTC)"$'\t'"Build"$'\t'"Job"$'\t'"Job URL"$'\t'"Build Trigger"$'\t'"Allow Job Failure"$'\t'"PR#"$'\t'"Branch"$'\t'"Commit"$'\t'"Commit Range"$'\t'"Commit Message"$'\t'"Sketch Filename"$'\t'"Board ID"$'\t'"IDE Version"$'\t'"Program Storage (bytes)"$'\t'"Dynamic Memory (bytes)"$'\t'"# Warnings"$'\t'"Allow Failure"$'\t'"Exit Status"$'\t'"# Board Issues"$'\t'"Board Issue"$'\r' > "$ARDUINO_CI_SCRIPT_REPORT_FILE_PATH"
985985

986986

987987
# Start the virtual display required by the Arduino IDE CLI: https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#bugs

0 commit comments

Comments
 (0)