summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2014-01-13 14:11:14 -0800
committerBen Straub <bs@github.com>2014-01-13 14:11:14 -0800
commit9bf17d2cf59127573c0be812883170785f0dc340 (patch)
treedc5fcbb7d4b56242172e659a65ddd6e0e81824ce /script
parent426d8456ea979cfae401ced2f88cc811a8b8264a (diff)
downloadlibgit2-9bf17d2cf59127573c0be812883170785f0dc340.tar.gz
Add coverity-scan script
Diffstat (limited to 'script')
-rwxr-xr-xscript/cibuild.sh6
-rwxr-xr-xscript/coverity.sh49
2 files changed, 55 insertions, 0 deletions
diff --git a/script/cibuild.sh b/script/cibuild.sh
index aa4fa47aa..5c0584a80 100755
--- a/script/cibuild.sh
+++ b/script/cibuild.sh
@@ -1,5 +1,11 @@
#!/bin/sh
+if [ "$COVERITY" -eq 1 ];
+then
+ ./script/coverity.sh;
+ exit $?;
+fi
+
# Create a test repo which we can use for the online::push tests
mkdir $HOME/_temp
git init --bare $HOME/_temp/test.git
diff --git a/script/coverity.sh b/script/coverity.sh
new file mode 100755
index 000000000..e75395948
--- /dev/null
+++ b/script/coverity.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+set -e
+
+# Environment check
+[ -z "$COVERITY_TOKEN" ] && echo "Need to set a coverity token" && exit 1
+
+COV_VERSION=6.6.1
+case `uname -m` in
+ i?86) BITS=32 ;;
+ amd64|x86_64) BITS=64 ;;
+esac
+SCAN_TOOL=https://scan.coverity.com/download/linux-${BITS}
+TOOL_BASE=`pwd`/_coverity-scan
+
+# Install coverity tools
+if [ ! -d $TOOL_BASE ]; then
+ echo "Downloading coverity..."
+ mkdir -p $TOOL_BASE
+ cd $TOOL_BASE
+ wget -O coverity_tool.tgz $SCAN_TOOL \
+ --post-data "project=libgit2&token=$COVERITY_TOKEN"
+ tar xzf coverity_tool.tgz
+ cd ..
+ TOOL_DIR=`find $TOOL_BASE -type d -name 'cov-analysis*'`
+ ln -s $TOOL_DIR $TOOL_BASE/cov-analysis
+fi
+
+COV_BUILD="$TOOL_BASE/cov-analysis/bin/cov-build"
+
+# Configure and build
+rm -rf _build
+mkdir _build
+cd _build
+cmake .. -DTHREADSAFE=ON
+COVERITY_UNSUPPORTED=1 \
+ $COV_BUILD --dir cov-int \
+ cmake --build .
+
+# Upload results
+tar czf libgit2.tgz cov-int
+SHA=`git rev-parse --short HEAD`
+curl \
+ --form project=libgit2 \
+ --form token=$COVERITY_TOKEN \
+ --form email=bs@github.com \
+ --form file=@libgit2.tgz \
+ --form version=$SHA \
+ --form description="Travis build" \
+ http://scan5.coverity.com/cgi-bin/upload.py