From 64848e986a335b55eb22f7a5ef98c983d614437f Mon Sep 17 00:00:00 2001 From: Sergei Shirokov Date: Wed, 8 May 2024 13:12:32 +0300 Subject: [PATCH] #sonar --- .github/workflows/sonar.yml | 17 ++++++++++++++--- test/unittest/CMakeLists.txt | 14 +++++++++++++- test/unittest/sonar.cpp | 11 +++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 test/unittest/sonar.cpp diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index ed63f9fd6..2781ab40a 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -37,6 +37,16 @@ jobs: --build-flavor Coverage --toolchain clang test + - name: upload-artifacts + uses: actions/upload-artifact@v4 + with: + name: Coverage-14-gcc + path: | + build/compile_commands.json + build/*/**/coverage.xml + build/*/**/*-sonarqube.xml + build/*/**/gcovr_html/*.* + if-no-files-found: error - name: Run sonar-scanner env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -48,13 +58,14 @@ jobs: --define sonar.projectKey=OpenCyphal-Garage_libcyphal --define sonar.projectName=libcyphal --define sonar.projectVersion=1.0 - --define sonar.sources=include + --define sonar.sources=include,test/unittest/sonar.cpp --define sonar.tests=test/unittest,docs/examples --define sonar.test.inclusions=test_*.cpp,example_*.cpp --define sonar.sourceEncoding=UTF-8 --define sonar.host.url=https://sonarcloud.io --define sonar.cfamily.ignoreHeaderComments=false - --define sonar.coverage.exclusions="test/unittest/**/*,docs/examples/**/*" - --define sonar.cpd.exclusions="test/unittest/**/*,docs/examples/**/*" + --define sonar.coverage.exclusions="test/unittest/**/*,docs/examples/**/*,**/sonar.cpp" + --define sonar.cpd.exclusions="test/unittest/**/*,docs/examples/**/*,**/sonar.cpp" --define sonar.cfamily.compile-commands="build/compile_commands.json" --define sonar.cfamily.reportingCppStandardOverride=c++14 + --define sonar.coverageReportPaths="build/test/unittest/coverage.xml,build/docs/examples/coverage.xml" diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index 74044c6ea..48b39825c 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -82,8 +82,20 @@ set_directory_properties(PROPERTIES ) if (CMAKE_BUILD_TYPE STREQUAL "Coverage") - enable_coverage_report(COVERAGE_REPORT_FORMATS html + + enable_coverage_report(COVERAGE_REPORT_FORMATS html sonarqube ROOT_DIRECTORY ${LIBCYPHAL_ROOT} OUT_REPORT_INDICIES LOCAL_COVERAGE_REPORT_INDICIES ) + + # we need to build at least one source file to get sonarqube to look at the cetl + # headers. + add_executable(cyphal_sonar + "sonar.cpp" + ) + + target_link_libraries(cyphal_sonar + PRIVATE cyphal + ) + endif() diff --git a/test/unittest/sonar.cpp b/test/unittest/sonar.cpp new file mode 100644 index 000000000..b6ee1d34c --- /dev/null +++ b/test/unittest/sonar.cpp @@ -0,0 +1,11 @@ +/// @copyright +/// Copyright (C) OpenCyphal Development Team +/// Copyright Amazon.com Inc. or its affiliates. +/// SPDX-License-Identifier: MIT + +#include + +int main() +{ + return 0; +}