From 7a6bc830dda05f0837c9c691bc8c9fc9635635f6 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Mon, 18 Oct 2021 12:09:22 +0200 Subject: [PATCH] let sonarcloud takes automated tests into account and report coverage Signed-off-by: Matthieu Gallien --- .drone.yml | 14 +++++++------- .github/workflows/sonarcloud.yml | 19 ++++++++++++++++--- sonar-project.properties | 3 +++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7ef6f2846..5b81297b6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,7 @@ name: qt-5.15 steps: - name: cmake - image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2 + image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4 volumes: - name: build path: /drone/build @@ -11,7 +11,7 @@ steps: - cd /drone/build - cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=Debug -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DECM_ENABLE_SANITIZERS=address -DCMAKE_CXX_FLAGS=-Werror ../src - name: compile - image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2 + image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4 volumes: - name: build path: /drone/build @@ -19,7 +19,7 @@ steps: - cd /drone/build - make -j$(nproc) - name: test - image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2 + image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4 volumes: - name: build path: /drone/build @@ -47,7 +47,7 @@ name: qt-5.15-clang steps: - name: cmake - image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2 + image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4 volumes: - name: build path: /drone/build @@ -55,7 +55,7 @@ steps: - cd /drone/build - cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_BUILD_TYPE=Debug -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DECM_ENABLE_SANITIZERS=address -DCMAKE_CXX_FLAGS=-Werror ../src - name: compile - image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2 + image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4 volumes: - name: build path: /drone/build @@ -63,7 +63,7 @@ steps: - cd /drone/build - ninja - name: test - image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2 + image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4 volumes: - name: build path: /drone/build @@ -73,7 +73,7 @@ steps: - chown -R test:test . - su -c 'ASAN_OPTIONS=detect_leaks=0 xvfb-run ctest --output-on-failure' test - name: clang-tidy - image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2 + image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4 volumes: - name: build path: /drone/build diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 43ffa489a..4843f25b6 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -9,7 +9,7 @@ jobs: build: name: Build runs-on: ubuntu-latest - container: ghcr.io/nextcloud/continuous-integration-client:client-5.15-3 + container: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4 env: SONAR_SERVER_URL: "https://sonarcloud.io" BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed @@ -27,11 +27,24 @@ jobs: - name: Run build-wrapper run: | mkdir build - cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_BUILD_TYPE=Release -DBUILD_UPDATER=ON -DBUILD_TESTING=1 - build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} ninja + cd build + cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DBUILD_COVERAGE=ON + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -j 2 + - name: Run tests + run: | + cd build + useradd -m -s /bin/bash test + chown -R test:test . + su -c 'xvfb-run ctest --output-on-failure --output-junit testResult.xml' test + - name: Generate coverage report + run: | + cd build + su -c 'ctest -T Coverage' test - name: Run sonar-scanner env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | + cp sonar-project.properties build + cd build sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" diff --git a/sonar-project.properties b/sonar-project.properties index 536c82d55..b039ad360 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,9 +1,12 @@ sonar.projectKey=nextcloud_desktop sonar.organization=nextcloud +sonar.projectBaseDir=.. sonar.sources=src sonar.exclusions=3rdparty/** sonar.language=c++ sonar.cfamily.cache.enabled=false +sonar.sourceEncoding=UTF-8 sonar.cfamily.threads=2 +sonar.cfamily.gcov.reportsPath=build/Testing/CoverageInfo sonar.cfamily.cache.enabled=true, sonar.cfamily.cache.path=/cache/sonarcloud