From f3de6dc91b8c5da7b2dd8e84226b1067cf226ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kardos?= Date: Mon, 16 Sep 2024 11:58:59 +0200 Subject: [PATCH] add template coverage --- .github/workflows/sonarqube.yml | 17 ++++++++++++++++- sonar-project.properties | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 7b2ca9a..9e72d89 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -66,13 +66,28 @@ jobs: run: | build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build --preset conan-${{ env.conan_preset }} + - name: Template coverage + run: | + wget https://github.com/petiaccja/TemplateCoverage/releases/download/v1.4.0/TemplateCoverage_Linux_x86_64.zip + unzip TemplateCoverage_Linux_x86_64.zip + chmod +x ./TemplateCoverage_Linux_x86_64/template-coverage + export RESOURCE_DIR=$(clang++ -print-resource-dir) + python3 ./TemplateCoverage_Linux_x86_64/run_on_compile_commands.py -p ${{github.workspace}}/build/${{env.conan_preset}}/compile_commands.json ./TemplateCoverage_Linux_x86_64/template-coverage -- --format=lcov --out-file=${{github.workspace}}/template_coverage.info -extra-arg=-resource-dir=$RESOURCE_DIR + - name: Test & code coverage working-directory: ${{github.workspace}}/build/${{ env.conan_preset }}/bin shell: bash run: | ./UnitTest --reporter junit --out ${{github.workspace}}/tests.xml llvm-profdata-17 merge -sparse default.profraw -o coverage.profdata - llvm-cov-17 show ./UnitTest -instr-profile=coverage.profdata > ${{github.workspace}}/coverage.txt + llvm-cov-17 export -format=lcov -object ./UnitTest -instr-profile=coverage.profdata > ${{github.workspace}}/test_coverage.info + + - name: Merge coverage reports + uses: danielpalme/ReportGenerator-GitHub-Action@5.2.4 + with: + reports: template_coverage.info;test_coverage.info + targetdir: coverage + reporttypes: SonarQube - name: Run sonar-scanner env: diff --git a/sonar-project.properties b/sonar-project.properties index 630762a..d715211 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -5,6 +5,6 @@ sonar.projectName=Mathter sonar.sources=include,test -sonar.cfamily.llvm-cov.reportPath=./coverage.txt +sonar.coverageReportPaths=./coverage/SonarQube.xml sonar.junit.reportPaths=./tests.xml sonar.cfamily.threads=4 \ No newline at end of file