Commit 15256b7b by Edward Thomson Committed by Patrick Steinhardt

ci: run coverity from travis's cron

Instead of trying to run coverity builds during the regular PR process,
run them during a regularly scheduled cron process.  These only need to
run nightly, so it makes sense to bring them out of the PR process.

(cherry picked from commit 6b92368c)
parent a5604c6f
...@@ -48,10 +48,6 @@ matrix: ...@@ -48,10 +48,6 @@ matrix:
compiler: gcc compiler: gcc
include: include:
- compiler: gcc - compiler: gcc
env: COVERITY=1
os: linux
dist: trusty
- compiler: gcc
env: env:
- LEAK_CHECK=valgrind - LEAK_CHECK=valgrind
CMAKE_OPTIONS="-DBUILD_CLAR=ON -DBUILD_EXAMPLES=OFF -DDEBUG_POOL=ON -DCMAKE_BUILD_TYPE=Debug" CMAKE_OPTIONS="-DBUILD_CLAR=ON -DBUILD_EXAMPLES=OFF -DDEBUG_POOL=ON -DCMAKE_BUILD_TYPE=Debug"
...@@ -67,8 +63,8 @@ install: ...@@ -67,8 +63,8 @@ install:
script: script:
- mkdir build - mkdir build
- cd build - cd build
- if [ "$COVERITY" ]; then ../ci/coverity.sh; fi - if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then ../ci/coverity.sh; fi
- if [ -z "$COVERITY" ]; then ../ci/build.sh && ../ci/test.sh; fi - if [ "$TRAVIS_EVENT_TYPE" != "cron" ]; then ../ci/build.sh && ../ci/test.sh; fi
# Only watch the development and master branches # Only watch the development and master branches
branches: branches:
......
#!/bin/bash #!/bin/bash
set -e
# Only run this on our branches set -e
echo "Branch: $TRAVIS_BRANCH | Pull request: $TRAVIS_PULL_REQUEST | Slug: $TRAVIS_REPO_SLUG"
if [ "$TRAVIS_BRANCH" != "master" -o "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "libgit2/libgit2" ];
then
echo "Only analyzing the 'master' brach of the main repository."
exit 0
fi
# Environment check # Environment check
[ -z "$COVERITY_TOKEN" ] && echo "Need to set a coverity token" && exit 1 [ -z "$COVERITY_TOKEN" ] && echo "Need to set a coverity token" && exit 1
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
BUILD_DIR=$(pwd)
case $(uname -m) in case $(uname -m) in
i?86) BITS=32 ;; i?86) BITS=32 ;;
amd64|x86_64) BITS=64 ;; amd64|x86_64) BITS=64 ;;
...@@ -32,28 +28,29 @@ if [ ! -d "$TOOL_BASE" ]; then ...@@ -32,28 +28,29 @@ if [ ! -d "$TOOL_BASE" ]; then
ln -s "$TOOL_DIR" "$TOOL_BASE"/cov-analysis ln -s "$TOOL_DIR" "$TOOL_BASE"/cov-analysis
fi fi
cp ../script/user_nodefs.h "$TOOL_BASE"/cov-analysis/config/user_nodefs.h cp "${SOURCE_DIR}/script/user_nodefs.h" "$TOOL_BASE"/cov-analysis/config/user_nodefs.h
COV_BUILD="$TOOL_BASE/cov-analysis/bin/cov-build" COV_BUILD="$TOOL_BASE/cov-analysis/bin/cov-build"
# Configure and build # Configure and build
cmake .. -DTHREADSAFE=ON cmake ${SOURCE_DIR}
COVERITY_UNSUPPORTED=1 \ COVERITY_UNSUPPORTED=1 \
$COV_BUILD --dir cov-int \ $COV_BUILD --dir cov-int \
cmake --build . cmake --build .
# Upload results # Upload results
tar czf libgit2.tgz cov-int tar czf libgit2.tgz cov-int
SHA=$(git rev-parse --short HEAD) SHA=$(cd ${SOURCE_DIR} && git rev-parse --short HEAD)
HTML="$(curl \ HTML="$(curl \
--silent \ --silent \
--write-out "\n%{http_code}" \ --write-out "\n%{http_code}" \
--form token="$COVERITY_TOKEN" \ --form token="$COVERITY_TOKEN" \
--form email=bs@github.com \ --form email=libgit2@gmail.com \
--form file=@libgit2.tgz \ --form file=@libgit2.tgz \
--form version="$SHA" \ --form version="$SHA" \
--form description="Travis build" \ --form description="libgit2 build" \
https://scan.coverity.com/builds?project=libgit2)" https://scan.coverity.com/builds?project=libgit2)"
# Body is everything up to the last line # Body is everything up to the last line
BODY="$(echo "$HTML" | head -n-1)" BODY="$(echo "$HTML" | head -n-1)"
...@@ -62,7 +59,7 @@ STATUS_CODE="$(echo "$HTML" | tail -n1)" ...@@ -62,7 +59,7 @@ STATUS_CODE="$(echo "$HTML" | tail -n1)"
echo "${BODY}" echo "${BODY}"
if [ "${STATUS_CODE}" != "201" ]; then if [ "${STATUS_CODE}" != "200" -o "${STATUS_CODE}" != "201" ]; then
echo "Received error code ${STATUS_CODE} from Coverity" echo "Received error code ${STATUS_CODE} from Coverity"
exit 1 exit 1
fi fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment