From 8d757e26f1f8ea99dfecaf0d78c649399ac60997 Mon Sep 17 00:00:00 2001 From: kdesnos Date: Mon, 4 Oct 2021 14:56:16 +0200 Subject: [PATCH] (CI) Try sonarcloud config from https://github.com/sonarsource-cfamily-examples/linux-cmake-gh-actions-sc --- .github/workflows/ci.yml | 49 +++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d02ba1be..0f5b90c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -196,36 +196,59 @@ jobs: Analyze-Sonar: runs-on: ubuntu-latest #needs: [Build-Ubuntu, Build-MacOS-clang, Build-Windows-MSVC] + env: + SONAR_SCANNER_VERSION: 4.6.1.2450 # Find the latest version in the "Linux" link on this page: + # https://sonarcloud.io/documentation/analysis/scan/sonarscanner/ + SONAR_SERVER_URL: "https://sonarcloud.io" + BUILD_WRAPPER_OUT_DIR: bw-output # Directory where build-wrapper output will be placed steps: - name: Checkout uses: actions/checkout@v2 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar - name: Install run: | sudo apt install doxygen gcovr - - name: Download Sonarcloud + - name: Download and set up sonar-scanner + env: + SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip run: | - curl -L -O https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip - unzip -o build-wrapper-linux-x86.zip + mkdir -p $HOME/.sonar + curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }} + unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ + echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH + - name: Download and set up build-wrapper + env: + BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip + run: | + curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }} + unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ + echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH - name: Build run: | - cd bin - cmake .. -DCMAKE_BUILD_TYPE=Debug - cd .. - build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output cmake --build bin/ --target runTests + cmake -S . -B bin -DCMAKE_BUILD_TYPE=Debug + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build bin/ --target runTests - name: Run Tests run: | cd bin ./bin/runTests gcovr -r .. -s --sonarqube=sonarqube.xml sed 's/ branchesToCover=\"[0-9]\+\" coveredBranches=\"[0-9]\+\"/ /g' sonarqube.xml > sonarqubecleaned.xml # Remove condition coverage info from report, only line coverage interests us. - - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@master - with: - args: > - -X + - name: Run sonar-scanner env: GITHUB_TOKEN: ${{ secrets.BOT_DEPLOY_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" + \ No newline at end of file