From cbd1e42aa29a4b996687e3a7aa302c1f02a1fb85 Mon Sep 17 00:00:00 2001 From: Marco Edoardo Santimaria Date: Wed, 8 Oct 2025 13:54:45 +0200 Subject: [PATCH 1/2] Added coverage to project This commits enable the CI action to upload the coverage info to CodeCov and also enables coverage collection with the correct CMake flags. --- .github/workflows/ci-test.yml | 27 ++++++++++++++------------- CMakeLists.txt | 10 ++++++++++ README.md | 1 + 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index ab25acf..3da89c6 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -87,6 +87,7 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DENABLE_COVERAGE=${{ matrix.build_type == 'Debug' && 'ON' || 'OFF' }} \ + -DBUILD_PYTHON_BINDINGS=OFF \ -G Ninja \ -B ../build \ -S ${GITHUB_WORKSPACE} @@ -123,16 +124,16 @@ jobs: retention-days: 1 if-no-files-found: error -# upload-to-codecov: -# name: "Codecov report upload" -# needs: [ "unit-tests" , "codespell-check" , "format-check" ] -# runs-on: ubuntu-22.04 -# steps: -# - uses: actions/checkout@v4 -# - name: "Download artifacts" -# uses: actions/download-artifact@v4 -# - name: "Upload coverage to Codecov" -# uses: codecov/codecov-action@v4 -# with: -# fail_ci_if_error: true -# token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + upload-to-codecov: + name: "Codecov report upload" + needs: [ "unit-tests" , "codespell-check" , "format-check" ] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: "Download artifacts" + uses: actions/download-artifact@v4 + - name: "Upload coverage to Codecov" + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 8097fdc..78890f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,16 @@ if (NOT PROJECT_IS_TOP_LEVEL) message(STATUS "CAPIO-CL included as subproject → tests disabled") endif () +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_compile_options(-O0 -g) +endif() + +if(ENABLE_COVERAGE) + message(STATUS "Building with code coverage instrumentation") + add_compile_options(--coverage -O0 -g) + add_link_options(--coverage) +endif() + ##################################### # External projects ##################################### diff --git a/README.md b/README.md index dcc7a1f..eafa55c 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![CI](https://github.com/High-Performance-IO/CAPIO-CL/actions/workflows/ci-test.yml/badge.svg)](https://github.com/High-Performance-IO/CAPIO-CL/actions/workflows/ci-test.yml) [![Python Bindings](https://github.com/High-Performance-IO/CAPIO-CL/actions/workflows/python-bindings.yml/badge.svg)](https://github.com/High-Performance-IO/CAPIO-CL/actions/workflows/python-bindings.yml) +[![codecov](https://codecov.io/gh/High-Performance-IO/CAPIO-CL/graph/badge.svg)](https://codecov.io/gh/High-Performance-IO/capio) ![CMake](https://img.shields.io/badge/CMake-%E2%89%A53.15-blue?logo=cmake&logoColor=white) ![C++](https://img.shields.io/badge/C%2B%2B-%E2%89%A517-blueviolet?logo=c%2B%2B&logoColor=white) From a62231836c37fecd5e083f7e1cee7a6fe377e66c Mon Sep 17 00:00:00 2001 From: Marco Edoardo Santimaria Date: Wed, 8 Oct 2025 14:15:09 +0200 Subject: [PATCH 2/2] Enabled coverage in python bindings --- .github/workflows/ci-test.yml | 3 +- .github/workflows/python-bindings.yml | 41 +++++++++++++++++++++++++-- README.md | 2 +- pyproject.toml | 1 - 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 3da89c6..a99495b 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -36,6 +36,7 @@ jobs: check-path: "${{ matrix.path }}" unit-tests: name: "Build ${{ matrix.build_type }} with ${{ matrix.cxx }}" + needs: [ "codespell-check" , "format-check" ] runs-on: ubuntu-22.04 strategy: matrix: @@ -126,7 +127,7 @@ jobs: upload-to-codecov: name: "Codecov report upload" - needs: [ "unit-tests" , "codespell-check" , "format-check" ] + needs: [ "unit-tests" ] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index 15eb4cc..2ce6180 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -14,7 +14,7 @@ jobs: name: "Test Python bindings" strategy: matrix: - on: [ 'ubuntu-24.04', 'macos-15-intel', 'macos-26' ] + on: [ 'ubuntu-22.04', 'ubuntu-24.04', 'macos-15-intel', 'macos-26' ] python: [ '3.10', '3.11', '3.12', '3.13' ] runs-on: ${{ matrix.on }} @@ -48,7 +48,12 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install -r build-requirements.txt - python -m build + + python -m build \ + -Ccmake.define.ENABLE_COVERAGE=ON \ + -Ccmake.build-type=Debug \ + -Ccmake.define.CAPIO_CL_BUILD_TESTS=OFF + pip install dist/*.whl # Run unit tests @@ -56,3 +61,35 @@ jobs: run: | python -m pip install -r test-requirements.txt pytest -v tests/python/test_* + + - name: "Generate coverage report" + if: ${{ startsWith(matrix.on, 'ubuntu-') }} + run: | + pip install --upgrade gcovr + gcovr \ + --exclude-throw-branches \ + --xml coverage.xml \ + . + + - name: "Upload coverage report" + if: ${{ startsWith(matrix.on, 'ubuntu-') }} + uses: actions/upload-artifact@v4 + with: + name: ${{ format('{0}-{1}-tests', matrix.on, matrix.python) }} + path: ./coverage.xml + retention-days: 1 + if-no-files-found: error + + upload-to-codecov: + name: "Codecov report upload" + needs: [ "python-tests" ] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: "Download artifacts" + uses: actions/download-artifact@v4 + - name: "Upload coverage to Codecov" + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index eafa55c..013f394 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![CI](https://github.com/High-Performance-IO/CAPIO-CL/actions/workflows/ci-test.yml/badge.svg)](https://github.com/High-Performance-IO/CAPIO-CL/actions/workflows/ci-test.yml) [![Python Bindings](https://github.com/High-Performance-IO/CAPIO-CL/actions/workflows/python-bindings.yml/badge.svg)](https://github.com/High-Performance-IO/CAPIO-CL/actions/workflows/python-bindings.yml) -[![codecov](https://codecov.io/gh/High-Performance-IO/CAPIO-CL/graph/badge.svg)](https://codecov.io/gh/High-Performance-IO/capio) +[![codecov](https://codecov.io/gh/High-Performance-IO/CAPIO-CL/graph/badge.svg)](https://codecov.io/gh/High-Performance-IO/CAPIO-CL) ![CMake](https://img.shields.io/badge/CMake-%E2%89%A53.15-blue?logo=cmake&logoColor=white) ![C++](https://img.shields.io/badge/C%2B%2B-%E2%89%A517-blueviolet?logo=c%2B%2B&logoColor=white) diff --git a/pyproject.toml b/pyproject.toml index 711b17b..9ff828a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,6 @@ Documentation = "https://capio.hpc4ai.it/docs/coord-language/" Repository = "https://github.com/High-Performance-IO/CAPIO-CL" Issues = "https://github.com/High-Performance-IO/CAPIO-CL/issues" - [tool.scikit-build.metadata.version] provider = "scikit_build_core.metadata.regex" input = "CMakeLists.txt"