Browse Source

enable sonar-scan in travis-ci builds

Ilya Shipitsin 6 years ago
parent
commit
e10983ec6f
2 changed files with 18 additions and 1 deletions
  1. 12 0
      .ci/sonarcloud.sh
  2. 6 1
      .travis.yml

+ 12 - 0
.ci/sonarcloud.sh

@@ -0,0 +1,12 @@
+#!/bin/sh
+set -eu
+
+RUN_SONARCLOUD="${RUN_SONARCLOUD:-0}"
+
+if [ "${RUN_SONARCLOUD}" = "1" ] && [ ! -z ${SONAR_TOKEN+x} ]; then
+   ./configure
+   build-wrapper-linux-x86-64 --out-dir bw-output make -C tmp
+   sonar-scanner -Dsonar.projectKey=SoftEtherVPN_SoftEtherVPN -Dsonar.organization=softethervpn -Dsonar.sources=. -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN}
+else
+    echo "Skipping sonar-scan because \$RUN_SONARCLOUD != \"1\" or \$SONAR_TOKEN is not set"
+fi

+ 6 - 1
.travis.yml

@@ -7,12 +7,16 @@ env:
   global:
     - OPENSSL_INSTALL_DIR="${HOME}/opt"
 
+addons:
+  sonarcloud:
+    organization: "softethervpn"
+
 matrix:
   include:
     - env: OPENSSL_VERSION="1.0.2o" BUILD_DEB="1"
       os: linux
       compiler: gcc
-    - env: OPENSSL_VERSION="1.1.0f"
+    - env: RUN_SONARCLOUD=1 OPENSSL_VERSION="1.1.0f"
       os: linux
       compiler: gcc
     - env: OPENSSL_VERSION="1.1.0f" LABEL="linux-ppc64le" CMAKE_VERSION="3.9.6"
@@ -70,6 +74,7 @@ script:
   - export LDFLAGS="-L${HOME}/opt/lib"
   - echo "check_certificate = off" > ~/.wgetrc
   - .ci/coverity.sh
+  - .ci/sonarcloud.sh
   - ./configure
   - make -j $(nproc || sysctl -n hw.ncpu || echo 4) -C tmp
   - ldd build/vpnserver