Skip to content

Commit

Permalink
#sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
serges147 committed May 8, 2024
1 parent 98e6af8 commit 64848e9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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"
14 changes: 13 additions & 1 deletion test/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
11 changes: 11 additions & 0 deletions test/unittest/sonar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// @copyright
/// Copyright (C) OpenCyphal Development Team <opencyphal.org>
/// Copyright Amazon.com Inc. or its affiliates.
/// SPDX-License-Identifier: MIT

#include <libcyphal/types.hpp>

int main()
{
return 0;
}

0 comments on commit 64848e9

Please sign in to comment.