Skip to content

Commit

Permalink
travis: rework coverity scan
Browse files Browse the repository at this point in the history
Using the addon kills the build immediately if we're throttled, so move
the logic to our main script where we have much better control over it.

This also let's us filter out duplicate builds -- instead of posting all
4 (current) matrix builds, we just post the first one.  The coverage is
pretty much the same.
  • Loading branch information
vapier committed Jun 24, 2016
1 parent ce8a177 commit 3fe0a71
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
31 changes: 4 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# https://docs.travis-ci.com/

language: cpp
# Order here matters for implicit matrix generation and coverity scan.
# See travis/main.sh for details.
compiler:
- clang
- gcc
- clang

env:
global:
Expand All @@ -13,6 +15,7 @@ env:

sudo: false

# Order here matters; see compiler comment above.
os:
- linux
- osx
Expand All @@ -39,29 +42,3 @@ addons:
- autoconf
- libtool
- html2text

coverity_scan:

# GitHub project metadata
# ** specific to your project **
project:
name: "libgd/libgd"
version: 2.2.2
description: "GD Graphics Library"
notification_email: pierre.php@gmail.com

# Where email notification of build analysis results will be sent
# notification_email: scan_notifications@example.com

# Commands to prepare for build_command
# ** likely specific to your build **
build_command_prepend: "autoreconf -fi && ./configure"

# The command that will be added as an argument to "cov-build" to compile your project for analysis,
# ** likely specific to your build **
build_command: "make"

# Pattern to match selecting branches that will run analysis. We recommend leaving this set to 'coverity_scan'.
# Take care in resource usage, and consider the build frequency allowances per
# https://scan.coverity.com/faq#frequency
branch_pattern: GD-2.2
24 changes: 24 additions & 0 deletions travis/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@

. "${0%/*}"/lib.sh

# We have to do this by hand rather than use the coverity addon because of
# matrix explosion: https://github.com/travis-ci/travis-ci/issues/1975
# We also do it by hand because when we're throttled, the addon will exit
# the build immediately and skip the main script!
coverity_scan() {
local reason
[[ ${TRAVIS_JOB_NUMBER} != *.1 ]] && reason="not first build job"
[[ -n ${TRAVIS_TAG} ]] && reason="git tag"
[[ ${TRAVIS_PULL_REQUEST} == "true" ]] && reason="pull request"
if [[ -n ${reason} ]] ; then
echo "Skipping coverity scan due to: ${reason}"
return
fi

export COVERITY_SCAN_PROJECT_NAME="${TRAVIS_REPO_SLUG}"
export COVERITY_SCAN_NOTIFICATION_EMAIL="pierre.php@gmail.com"
export COVERITY_SCAN_BUILD_COMMAND="make -j${ncpus}"
export COVERITY_SCAN_BUILD_COMMAND_PREPEND="git clean -q -x -d -f; git checkout -f; ./bootstrap.sh && ./configure"
export COVERITY_SCAN_BRANCH_PATTERN="GD-2.2"

curl -s "https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh" | bash || :
}

update_os() {
# Note: Linux deps are maintained in .travis.yml.
case ${TRAVIS_OS_NAME} in
Expand Down Expand Up @@ -109,5 +132,6 @@ main() {
build_autotools
build_cmake
compare_builds
v --fold="coverity_scan" coverity_scan
}
main "$@"

0 comments on commit 3fe0a71

Please sign in to comment.