From d822aab4a5fd548327bf9c75837a95e427b7a446 Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Thu, 2 Nov 2023 20:48:16 +0100 Subject: [PATCH] Generate coverage reports for Sonar --- .github/workflows/sonar.yml | 10 ++++++++++ sonar-project.properties | 3 +++ 2 files changed, 13 insertions(+) diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index 20f7da24..af9f176a 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -27,6 +27,16 @@ jobs: CXX: g++-13 run: | build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -j5 debug + - name: Run the tests + run: make -j1 debug_test + - name: Generate coverage reports + run: | + mkdir gcov-reports + pushd gcov-reports + for f in $(find ../debug -iname '*.o'); do + gcov-13 --preserve-paths -o $f x + done + popd - name: Run sonar-scanner env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/sonar-project.properties b/sonar-project.properties index 86484661..94c5e2f9 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -8,6 +8,9 @@ sonar.projectVersion=1.3.0 # C++23 support in SonarCloud is experimental, so enable it sonar.cfamily.cpp23.enabled=true +# Get coverage from gcov files +sonar.cfamily.gcov.reportsPath=gcov-reports + # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. #sonar.sources=.