Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
cache-downloads: true

- name: Configure using CMake
run: cmake -G Ninja -Bbuild -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_DOCS=ON
run: cmake -G Ninja -Bbuild -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DSPARROW_IPC_BUILD_DOCS=ON

- name: Build docs target
run: cmake --build build --target docs
Expand Down
40 changes: 31 additions & 9 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,23 @@ jobs:
- name: Configure using cmake
run: |
cmake -S ./ -B ./build \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX% \
-DCMAKE_PREFIX_PATH=%CONDA_PREFIX% \
-DSPARROW_IPC_BUILD_SHARED=${{ matrix.build_shared }} \
-DSPARROW_IPC_BUILD_TESTS=ON

- name: Build sparrow-ipc
working-directory: build
run: cmake --build . --target sparrow-ipc
run: cmake --build . --config ${{ matrix.build_type }} --target sparrow-ipc

- name: Build tests
working-directory: build
run: cmake --build . --target test_sparrow_ipc_lib
run: cmake --build . --config ${{ matrix.build_type }} --target test_sparrow_ipc_lib

- name: Run tests
working-directory: build
run: |
cmake --build . --target run_tests
cmake --build . --config ${{ matrix.build_type }} --target run_tests_with_junit_report

windows_build_fetch_from_source:
runs-on: windows-latest
Expand All @@ -61,22 +60,45 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Enable tests coverage
if: matrix.build_type == 'Debug'
run: |
choco install opencppcoverage
echo "TEST_COVERAGE_ACTIVATION=-DSPARROW_IPC_ENABLE_COVERAGE=ON" >> $GITHUB_ENV

- name: Configure using cmake
run: |
cmake -S ./ -B ./build \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DSPARROW_IPC_BUILD_SHARED=${{ matrix.build_shared }} \
-DSPARROW_IPC_BUILD_TESTS=ON \
-DFETCH_DEPENDENCIES_WITH_CMAKE=MISSING
-DFETCH_DEPENDENCIES_WITH_CMAKE=MISSING \
$TEST_COVERAGE_ACTIVATION

- name: Build sparrow-ipc
working-directory: build
run: cmake --build . --target sparrow-ipc
run: cmake --build . --config ${{ matrix.build_type }} --target sparrow-ipc

- name: Build tests
working-directory: build
run: cmake --build . --target test_sparrow_ipc_lib
run: cmake --build . --config ${{ matrix.build_type }} --target test_sparrow_ipc_lib

- name: Run tests
working-directory: build
run: cmake --build . --target run_tests_with_junit_report
run: cmake --build . --config ${{ matrix.build_type }} --target run_tests_with_junit_report

- name: Tests coverage
if: matrix.build_type == 'Debug'
working-directory: build
run: |
cmake --build . --config Debug --target sparrow_ipc_generate_cobertura

- name: Upload coverage to Codecov
if: matrix.build_type == 'Debug'
uses: codecov/codecov-action@v5
with:
directory: ./build/coverage_reports/
fail_ci_if_error: true
files: ./cobertura.xml
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,17 @@ endif()
OPTION(SPARROW_IPC_BUILD_TESTS "Build sparrow-ipc test suite" OFF)
MESSAGE(STATUS "🔧 Build tests: ${SPARROW_IPC_BUILD_TESTS}")

OPTION(BUILD_DOCS "Build sparrow-ipc documentation" OFF)
MESSAGE(STATUS "🔧 Build docs: ${BUILD_DOCS}")
OPTION(SPARROW_IPC_BUILD_DOCS "Build sparrow-ipc documentation" OFF)
MESSAGE(STATUS "🔧 Build docs: ${SPARROW_IPC_BUILD_DOCS}")

# Code coverage
# =============
OPTION(SPARROW_IPC_ENABLE_COVERAGE "Enable sparrow-ipc test coverage" OFF)
MESSAGE(STATUS "🔧 Enable coverage: ${SPARROW_IPC_ENABLE_COVERAGE}")

if(SPARROW_IPC_ENABLE_COVERAGE)
include(code_coverage)
endif()

set(SPARROW_IPC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(SPARROW_IPC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
Expand Down Expand Up @@ -166,7 +175,7 @@ endif()

# Docs
# ====
if(BUILD_DOCS)
if(SPARROW_IPC_BUILD_DOCS)
message(STATUS "📚 Create docs targets")
add_subdirectory(docs)
endif()
35 changes: 35 additions & 0 deletions cmake/code_coverage.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading")
endif()

set(COVERAGE_REPORT_PATH "${CMAKE_BINARY_DIR}/coverage_reports" CACHE PATH "Path to store coverage reports")
set(COBERTURA_REPORT_PATH "${COVERAGE_REPORT_PATH}/cobertura.xml" CACHE PATH "Path to store cobertura report")
set(COVERAGE_TARGETS_FOLDER "Tests utilities/Code Coverage")

if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
find_program(OpenCPPCoverage OpenCppCoverage.exe opencppcoverage.exe REQUIRED
PATHS "C:/Program Files/OpenCppCoverage" "C:/Program Files (x86)/OpenCppCoverage")

cmake_path(CONVERT ${CMAKE_SOURCE_DIR} TO_NATIVE_PATH_LIST OPENCPPCOVERAGE_SOURCES)
set(OPENCPPCOVERAGE_COMMON_ARGS --sources=${OPENCPPCOVERAGE_SOURCES} --modules=${OPENCPPCOVERAGE_SOURCES} --excluded_sources=test*)

add_custom_target(sparrow_ipc_generate_cobertura
COMMAND ${OpenCPPCoverage}
${OPENCPPCOVERAGE_COMMON_ARGS}
--export_type=cobertura:${COBERTURA_REPORT_PATH}
-- $<TARGET_FILE:test_sparrow_ipc_lib>
DEPENDS test_sparrow_ipc_lib
COMMENT "Generating coverage cobertura report with OpenCppCoverage: ${COBERTURA_REPORT_PATH}"
)
set(TARGET_PROPERTIES sparrow_ipc_generate_cobertura PROPERTIES FOLDER ${COVERAGE_TARGETS_FOLDER})

add_custom_target(sparrow_ipc_generate_html_coverage_report
COMMAND ${OpenCPPCoverage}
${OPENCPPCOVERAGE_COMMON_ARGS}
--export_type=html:${COVERAGE_REPORT_PATH}
-- $<TARGET_FILE:test_sparrow_ipc_lib>
DEPENDS test_sparrow_ipc_lib
COMMENT "Generating coverage report with OpenCppCoverage: ${COVERAGE_REPORT_PATH}"
)
set(TARGET_PROPERTIES sparrow_ipc_generate_cobertura PROPERTIES FOLDER "Tests utilities/Code Coverage")
endif()
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def generate(self):
tc = CMakeToolchain(self)
tc.variables["SPARROW_IPC_BUILD_SHARED"] = self.options.shared
tc.variables["SPARROW_IPC_BUILD_TESTS"] = self.options.build_tests
tc.variables["BUILD_DOCS"] = self.options.generate_documentation
tc.variables["SPARROW_IPC_BUILD_DOCS"] = self.options.generate_documentation
tc.generate()

def build(self):
Expand Down
3 changes: 2 additions & 1 deletion docs/source/dev_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ List of CMake options:
- `ACTIVATE_LINTER`: Create targets to run clang-format and clang-tidy (default: OFF)
- `ACTIVATE_LINTER_DURING_COMPILATION`: Run linter during the compilation (default: OFF),
requires `ACTIVATE_LINTER` to be ON
- `BUILD_DOCS`: Build the documentation (default: OFF)
- `SPARROW_IPC_BUILD_DOCS`: Build the documentation (default: OFF)
- `SPARROW_IPC_BUILD_TESTS`: Build the tests (default: OFF)
- `SPARROW_IPC_BUILD_SHARED`: Build sparrow-ipc as a shared library (default: ON)
- `SPARROW_IPC_ENABLE_COVERAGE`: Enable coverage reporting (default: OFF)

## Building

Expand Down
Loading