Skip to content

Commit 52f6f44

Browse files
committed
Check for library issues
Detect library issues that are exposed by warnings generated by the IDE during the sketch verification process, rather than the compiler.
1 parent 51888c7 commit 52f6f44

File tree

3 files changed

+102
-5
lines changed

3 files changed

+102
-5
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ before_install:
4141
# Check for board definition errors that don't affect compilation
4242
- set_board_testing "true"
4343

44+
# Check for library issues that don't affect compilation
45+
- set_library_testing "true"
46+
4447
- install_ide "$INSTALL_IDE_START_VERSION" "$INSTALL_IDE_END_VERSION"
4548

4649
# Install hardware packages

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Control the level of verbosity of the script's output in the Travis CI log. Verb
4040
Turn on/off checking for errors with the board definition that don't affect sketch verification such as missing bootloader file. If this is turned on and an error is detected the build will be failed. This feature is off by default.
4141
- Parameter: **BOARD_TESTING** - `true`/`false`
4242

43+
##### `set_library_testing LIBRARY_TESTING`
44+
Turn on/off checking for errors with libraries that don't affect sketch verification such as missing or invalid items in the library.properties file. If this is turned on and an error is detected the build will be failed. This feature is off by default.
45+
- Parameter: **LIBRARY_TESTING** - `true`/`false`
46+
4347
##### Special version names:
4448
- `all`: Refers to all versions of the Arduino IDE (including the hourly build). In the context of `install_ide` this means all IDE versions listed in the script (those that support the command line interface, 1.5.2 and newer). In the context of all other functions this means all IDE versions that were installed via `install_ide`.
4549
- `oldest`: The oldest release version of the Arduino IDE. In the context of `install_ide` this is the oldest of the IDE versions listed in the script (1.5.2, the first version to have a command line interface). In the context of build_sketch this means the oldest IDE version that was installed via `install_ide`.
@@ -129,6 +133,8 @@ Echo a tab separated report of all verification results to the log. The report i
129133
- Exit Status - Exit status returned by arduino after the sketch verification.
130134
- # Board Issues - The number of board issues detected.
131135
- Board Issue - Short description of the last board issue detected.
136+
- # Library Issues - The number of library issues detected. Library issues are things that cause warnings in the sketch verification output from the IDE, rather than the compiler.
137+
- Library Issue - Short description of the last library issue detected.
132138

133139
##### `publish_report_to_repository REPORT_GITHUB_TOKEN repositoryURL reportBranch reportFolder doLinkComment`
134140
Add the report to a repository. See the [instructions for publishing job reports](publishing-job-reports) for details.

arduino-ci-script.sh

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ function set_board_testing()
177177
}
178178

179179

180+
# Check for errors with libraries that don't affect sketch verification
181+
function set_library_testing()
182+
{
183+
enable_verbosity
184+
185+
ARDUINO_CI_SCRIPT_TEST_LIBRARY="$1"
186+
187+
disable_verbosity
188+
}
189+
190+
180191
# Install all specified versions of the Arduino IDE
181192
function install_ide()
182193
{
@@ -756,6 +767,7 @@ function build_this_sketch()
756767
# Parse through the output from the sketch verification to count warnings and determine the compile size
757768
local warningCount=0
758769
local boardIssueCount=0
770+
local libraryIssueCount=0
759771
while read -r outputFileLine; do
760772
# Determine program storage memory usage
761773
local programStorageRegex="Sketch uses ([0-9,]+) *"
@@ -775,7 +787,7 @@ function build_this_sketch()
775787
warningCount=$((warningCount + 1))
776788
fi
777789

778-
# Check for missing bootloader
790+
# Check for board issues
779791
local bootloaderMissingRegex="Bootloader file specified but missing: "
780792
if [[ "$outputFileLine" =~ $bootloaderMissingRegex ]] > /dev/null; then
781793
local boardIssue="missing bootloader"
@@ -794,6 +806,75 @@ function build_this_sketch()
794806
boardIssueCount=$((boardIssueCount + 1))
795807
fi
796808

809+
# Check for library issues
810+
# This is the generic "invalid library" warning that doesn't specify the reason
811+
local invalidLibrarRegex1="Invalid library found in"
812+
local invalidLibrarRegex2="from library$"
813+
if [[ "$outputFileLine" =~ $invalidLibrarRegex1 ]] && ! [[ "$outputFileLine" =~ $invalidLibrarRegex2 ]] > /dev/null; then
814+
local libraryIssue="Invalid library"
815+
libraryIssueCount=$((libraryIssueCount + 1))
816+
fi
817+
818+
local missingNameRegex="Invalid library found in .* Missing 'name' from library"
819+
if [[ "$outputFileLine" =~ $missingNameRegex ]] > /dev/null; then
820+
local libraryIssue="Missing 'name' from library"
821+
libraryIssueCount=$((libraryIssueCount + 1))
822+
fi
823+
824+
local missingVersionRegex="Invalid library found in .* Missing 'version' from library"
825+
if [[ "$outputFileLine" =~ $missingVersionRegex ]] > /dev/null; then
826+
local libraryIssue="Missing 'version' from library"
827+
libraryIssueCount=$((libraryIssueCount + 1))
828+
fi
829+
830+
local missingAuthorRegex="Invalid library found in .* Missing 'author' from library"
831+
if [[ "$outputFileLine" =~ $missingAuthorRegex ]] > /dev/null; then
832+
local libraryIssue="Missing 'author' from library"
833+
libraryIssueCount=$((libraryIssueCount + 1))
834+
fi
835+
836+
local missingMaintainerRegex="Invalid library found in .* Missing 'maintainer' from library"
837+
if [[ "$outputFileLine" =~ $missingMaintainerRegex ]] > /dev/null; then
838+
local libraryIssue="Missing 'maintainer' from library"
839+
libraryIssueCount=$((libraryIssueCount + 1))
840+
fi
841+
842+
local missingSentenceRegex="Invalid library found in .* Missing 'sentence' from library"
843+
if [[ "$outputFileLine" =~ $missingSentenceRegex ]] > /dev/null; then
844+
local libraryIssue="Missing 'sentence' from library"
845+
libraryIssueCount=$((libraryIssueCount + 1))
846+
fi
847+
848+
local missingParagraphRegex="Invalid library found in .* Missing 'paragraph' from library"
849+
if [[ "$outputFileLine" =~ $missingParagraphRegex ]] > /dev/null; then
850+
local libraryIssue="Missing 'paragraph' from library"
851+
libraryIssueCount=$((libraryIssueCount + 1))
852+
fi
853+
854+
local missingURLregex="Invalid library found in .* Missing 'url' from library"
855+
if [[ "$outputFileLine" =~ $missingURLregex ]] > /dev/null; then
856+
local libraryIssue="Missing 'url' from library"
857+
libraryIssueCount=$((libraryIssueCount + 1))
858+
fi
859+
860+
local invalidVersionRegex="Invalid version found:"
861+
if [[ "$outputFileLine" =~ $invalidVersionRegex ]] > /dev/null; then
862+
local libraryIssue="Invalid version found:"
863+
libraryIssueCount=$((libraryIssueCount + 1))
864+
fi
865+
866+
local invalidCategoryRegex="is not valid. Setting to 'Uncategorized'"
867+
if [[ "$outputFileLine" =~ $invalidCategoryRegex ]] > /dev/null; then
868+
local libraryIssue="Invalid category"
869+
libraryIssueCount=$((libraryIssueCount + 1))
870+
fi
871+
872+
local spuriousFolderRegex="WARNING: Spurious"
873+
if [[ "$outputFileLine" =~ $spuriousFolderRegex ]] > /dev/null; then
874+
local libraryIssue="Spurious folder"
875+
libraryIssueCount=$((libraryIssueCount + 1))
876+
fi
877+
797878
done < "$ARDUINO_CI_SCRIPT_VERIFICATION_OUTPUT_FILENAME"
798879

799880
rm $ARDUINO_CI_SCRIPT_VERBOSITY_OPTION "$ARDUINO_CI_SCRIPT_VERIFICATION_OUTPUT_FILENAME"
@@ -806,10 +887,15 @@ function build_this_sketch()
806887
# There was a board issue and board testing is enabled so fail the build
807888
local buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
808889
fi
890+
891+
if [[ "$libraryIssue" != "" && "$ARDUINO_CI_SCRIPT_TEST_LIBRARY" == "true" ]]; then
892+
# There was a library issue and library testing is enabled so fail the build
893+
local buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
894+
fi
809895
fi
810896

811897
# Add the build data to the report file
812-
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"
898+
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"$'\t'"$libraryIssueCount"$'\t'"$libraryIssue"$'\r' >> "$ARDUINO_CI_SCRIPT_REPORT_FILE_PATH"
813899

814900
# Adjust the exit status according to the allowFail setting
815901
if [[ "$buildThisSketchExitStatus" == "$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS" && ("$allowFail" == "true" || "$allowFail" == "require") ]]; then
@@ -823,12 +909,13 @@ function build_this_sketch()
823909
fi
824910
ARDUINO_CI_SCRIPT_TOTAL_WARNING_COUNT=$((ARDUINO_CI_SCRIPT_TOTAL_WARNING_COUNT + warningCount + 0))
825911
ARDUINO_CI_SCRIPT_TOTAL_BOARD_ISSUE_COUNT=$((ARDUINO_CI_SCRIPT_TOTAL_BOARD_ISSUE_COUNT + boardIssueCount + 0))
912+
ARDUINO_CI_SCRIPT_TOTAL_LIBRARY_ISSUE_COUNT=$((ARDUINO_CI_SCRIPT_TOTAL_LIBRARY_ISSUE_COUNT + libraryIssueCount + 0))
826913

827914
# End the folded section of the Travis CI build log
828915
echo -e "travis_fold:end:build_sketch"
829916
# Add a useful message to the Travis CI build log
830917

831-
echo "arduino Exit Status: ${arduinoExitStatus}, Allow Failure: ${allowFail}, # Warnings: ${warningCount}, # Board Issues: ${boardIssueCount}"
918+
echo "arduino Exit Status: ${arduinoExitStatus}, Allow Failure: ${allowFail}, # Warnings: ${warningCount}, # Board Issues: ${boardIssueCount}, # Library Issues: ${libraryIssueCount}"
832919

833920
return $buildThisSketchExitStatus
834921
}
@@ -846,6 +933,7 @@ function display_report()
846933
echo "Total failed sketch builds: $ARDUINO_CI_SCRIPT_TOTAL_SKETCH_BUILD_FAILURE_COUNT"
847934
echo "Total warnings: $ARDUINO_CI_SCRIPT_TOTAL_WARNING_COUNT"
848935
echo "Total board issues: $ARDUINO_CI_SCRIPT_TOTAL_BOARD_ISSUE_COUNT"
936+
echo "Total library issues: $ARDUINO_CI_SCRIPT_TOTAL_LIBRARY_ISSUE_COUNT"
849937
echo -e "\n\n"
850938
else
851939
echo "No report file available for this job"
@@ -886,7 +974,7 @@ function publish_report_to_repository()
886974
fi
887975
# 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.
888976
git pull $ARDUINO_CI_SCRIPT_QUIET_OPTION
889-
git commit $ARDUINO_CI_SCRIPT_QUIET_OPTION $ARDUINO_CI_SCRIPT_VERBOSITY_OPTION --message="Add Travis CI job ${TRAVIS_JOB_NUMBER} report (${jobSuccessMessage})" --message="Total failed sketch builds: $ARDUINO_CI_SCRIPT_TOTAL_SKETCH_BUILD_FAILURE_COUNT" --message="Total warnings: $ARDUINO_CI_SCRIPT_TOTAL_WARNING_COUNT" --message="Total board issues: $ARDUINO_CI_SCRIPT_TOTAL_BOARD_ISSUE_COUNT" --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]"
977+
git commit $ARDUINO_CI_SCRIPT_QUIET_OPTION $ARDUINO_CI_SCRIPT_VERBOSITY_OPTION --message="Add Travis CI job ${TRAVIS_JOB_NUMBER} report (${jobSuccessMessage})" --message="Total failed sketch builds: $ARDUINO_CI_SCRIPT_TOTAL_SKETCH_BUILD_FAILURE_COUNT" --message="Total warnings: $ARDUINO_CI_SCRIPT_TOTAL_WARNING_COUNT" --message="Total board issues: $ARDUINO_CI_SCRIPT_TOTAL_BOARD_ISSUE_COUNT" --message="Total library issues: $ARDUINO_CI_SCRIPT_TOTAL_LIBRARY_ISSUE_COUNT" --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]"
890978
local gitPushExitStatus="1"
891979
local pushCount=0
892980
while [[ "$gitPushExitStatus" != "$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS" && $pushCount -le $ARDUINO_CI_SCRIPT_REPORT_PUSH_RETRIES ]]; do
@@ -1015,7 +1103,7 @@ create_folder "$ARDUINO_CI_SCRIPT_REPORT_FOLDER"
10151103

10161104

10171105
# Add column names to report
1018-
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"
1106+
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"$'\t'"# Library Issues"$'\t'"Library Issue"$'\r' > "$ARDUINO_CI_SCRIPT_REPORT_FILE_PATH"
10191107

10201108

10211109
# 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)