diff options
Diffstat (limited to 'src/scripts/ci/travis/build.sh')
-rwxr-xr-x | src/scripts/ci/travis/build.sh | 37 |
1 files changed, 28 insertions, 9 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 |