aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Neus <[email protected]>2016-08-04 19:25:28 +0200
committerDaniel Neus <[email protected]>2016-08-18 13:21:37 +0200
commit5f3a96204a4888367af45828bfe05cc05dd6ef95 (patch)
treec3bd9d507fc8910bd723df4b03b63f94d6f4b142 /src
parentfedaf80bad502a2f0c85b7acd0e2ead37c6c8ced (diff)
SonarQube integration / Travis CI changes
Travis CI changes: - Run SonarQube analysis for commits on master and in pull requests - Upgrade Travis CI build image to Ubuntu 14.04 and use standard system toolchain - Update lcov to 1.12 for coverage - Set git clone depth to 5 commits - Use 'builtin' ccache Travis CI addon - Add SonarQube badge to readme - No longer necessary to overwrite CXX variable in build.sh when using gcc
Diffstat (limited to 'src')
-rwxr-xr-xsrc/scripts/ci/travis/build.sh37
-rwxr-xr-xsrc/scripts/ci/travis/install.sh11
2 files changed, 36 insertions, 12 deletions
diff --git a/src/scripts/ci/travis/build.sh b/src/scripts/ci/travis/build.sh
index 50fc3164f..b3267ee70 100755
--- a/src/scripts/ci/travis/build.sh
+++ b/src/scripts/ci/travis/build.sh
@@ -4,7 +4,7 @@ which shellcheck > /dev/null && shellcheck "$0" # Run shellcheck on this if avai
if [ "$BUILD_MODE" = "static" ]; then
CFG_FLAGS=(--disable-shared --via-amalgamation)
-elif [ "$BUILD_MODE" = "shared" ]; then
+elif [ "$BUILD_MODE" = "shared" ] || [ "$BUILD_MODE" = "sonarqube" ]; then
CFG_FLAGS=()
elif [ "$BUILD_MODE" = "coverage" ]; then
CFG_FLAGS=(--with-coverage)
@@ -20,14 +20,8 @@ if [ "$BOOST" = "y" ]; then
CFG_FLAGS+=(--with-boost)
fi
-# Workaround for missing update-alternatives
-# https://github.com/travis-ci/travis-ci/issues/3668
-if [ "$CXX" = "g++" ]; then
- export CXX="/usr/bin/g++-4.8"
-fi
-
# enable ccache
-if [ "$TRAVIS_OS_NAME" = "linux" ]; then
+if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$BUILD_MODE" != "sonarqube" ]; then
ccache --max-size=30M
ccache --show-stats
@@ -55,11 +49,36 @@ fi
# build
if [ "${TARGETOS:0:3}" = "ios" ]; then
xcrun --sdk iphoneos make -j 2
+elif [ "$BUILD_MODE" = "sonarqube" ]; then
+ ./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-outputs make -j 2
else
make -j 2
fi
-if [ "$MODULES" != "min" ] && [ "${TARGETOS:0:3}" != "ios" ]; then
+# Run SonarQube analysis
+if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$BUILD_MODE" = "sonarqube" ]; then
+ # => This will run a full analysis of the project and push results to the SonarQube server.
+ #
+ # Analysis is done only on master so that build of branches don't push analyses to the same project and therefore "pollute" the results
+ echo "Starting analysis by SonarQube..."
+ sonar-scanner -Dsonar.login=$SONAR_TOKEN
+elif [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "${GITHUB_TOKEN-}" ] && [ "$BUILD_MODE" = "sonarqube" ]; then
+ # => This will analyse the PR and display found issues as comments in the PR, but it won't push results to the SonarQube server
+ #
+ # For security reasons environment variables are not available on the pull requests
+ # coming from outside repositories
+ # http://docs.travis-ci.com/user/pull-requests/#Security-Restrictions-when-testing-Pull-Requests
+ # That's why the analysis does not need to be executed if the variable GITHUB_TOKEN is not defined.
+ echo "Starting Pull Request analysis by SonarQube..."
+ sonar-scanner -Dsonar.login=$SONAR_TOKEN \
+ -Dsonar.analysis.mode=preview \
+ -Dsonar.github.oauth=$GITHUB_TOKEN \
+ -Dsonar.github.repository=$TRAVIS_REPO_SLUG \
+ -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST
+fi
+# When neither on master branch nor on a non-external pull request => nothing to do
+
+if [ "$MODULES" != "min" ] && [ "${TARGETOS:0:3}" != "ios" ] && [ "$BUILD_MODE" != "sonarqube" ]; then
./botan-test
fi
diff --git a/src/scripts/ci/travis/install.sh b/src/scripts/ci/travis/install.sh
index 0e49ad363..387ccef6c 100755
--- a/src/scripts/ci/travis/install.sh
+++ b/src/scripts/ci/travis/install.sh
@@ -3,16 +3,21 @@ set -ev
which shellcheck > /dev/null && shellcheck "$0" # Run shellcheck on this if available
if [ "$BUILD_MODE" = "coverage" ]; then
- wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz
- tar -xvf lcov_1.11.orig.tar.gz
+ wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.12.orig.tar.gz
+ tar -xvf lcov_1.12.orig.tar.gz
export PREFIX="/tmp"
- make -C lcov-1.11/ install
+ make -C lcov-1.12/ install
pip install --user coverage
pip install --user codecov
fi
+if [ "$BUILD_MODE" = "sonarqube" ]; then
+ curl -LsS https://sonarqube.com/static/cpp/build-wrapper-linux-x86.zip > build-wrapper-linux-x86.zip
+ unzip build-wrapper-linux-x86.zip
+fi
+
if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$TARGETOS" != "ios" ]; then
# Workaround for https://github.com/Homebrew/homebrew/issues/42553
brew update || brew update