From 967d03b542e0dec5991e4b2331009bda34d4edb3 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 5 Jun 2026 13:53:07 +0200 Subject: [PATCH 1/5] Add C++ coverage to Codecov workflow Co-authored-by: Codex --- .github/workflows/CI.yml | 9 +++++++++ deps/build.jl | 8 ++++++-- deps/src/CMakeLists.txt | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3e39db0..c1b4cfb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -28,6 +28,9 @@ jobs: os: - ubuntu-latest include: + - julia-version: 1 + os: ubuntu-latest + cxx-coverage: true # Add a few windows and macOS jobs (not too many, the number we can run in parallel is limited) - julia-version: lts os: macOS-latest @@ -53,6 +56,8 @@ jobs: update_packager_index: false - name: "Build package" uses: julia-actions/julia-buildpkg@v1 + env: + NORMALIZ_JL_CXX_COVERAGE: ${{ matrix.cxx-coverage == true && 'true' || 'false' }} - name: "Run tests" uses: julia-actions/julia-runtest@v1 with: @@ -70,6 +75,10 @@ jobs: - name: "Process code coverage" uses: julia-actions/julia-processcoverage@v1 + - name: "Process C++ coverage" + if: ${{ matrix.cxx-coverage == true }} + run: | + find deps/src/build -name '*.gcda' -exec gcov -pb -r -s "$PWD" {} \; - name: "Upload coverage data to Codecov" continue-on-error: true uses: codecov/codecov-action@v6 diff --git a/deps/build.jl b/deps/build.jl index 64829f2..9f0af59 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -6,6 +6,9 @@ using normaliz_jll # Parse some basic command-line arguments const verbose = "--verbose" in ARGS +const cxx_coverage = + lowercase(get(ENV, "NORMALIZ_JL_CXX_COVERAGE", "false")) in + ("1", "true", "yes", "on") jlcxx_cmake_dir = joinpath(CxxWrap.prefix_path(), "lib", "cmake", "JlCxx") julia_exec = joinpath(Sys.BINDIR, Base.julia_exename()) @@ -48,7 +51,8 @@ CMake_jll.cmake() do exe run(`$exe -DJulia_EXECUTABLE=$julia_exec -DJlCxx_DIR=$jlcxx_cmake_dir - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=$(cxx_coverage ? "Debug" : "Release") + -DNORMALIZ_JULIA_ENABLE_COVERAGE=$(cxx_coverage ? "ON" : "OFF") -Dnormaliz_prefix=$(jll_artifact_dir(normaliz_jll)) -Dgmp_prefix=$(jll_artifact_dir(normaliz_jll.GMP_jll)) -Dmpfr_prefix=$(jll_artifact_dir(normaliz_jll.MPFR_jll)) @@ -67,7 +71,7 @@ CMake_jll.cmake() do exe run(`$exe --build $(builddir) - --config Release + --config $(cxx_coverage ? "Debug" : "Release") -- -j$(div(Sys.CPU_THREADS,2)) `) diff --git a/deps/src/CMakeLists.txt b/deps/src/CMakeLists.txt index 95af051..60b7071 100644 --- a/deps/src/CMakeLists.txt +++ b/deps/src/CMakeLists.txt @@ -18,6 +18,9 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}") +option(NORMALIZ_JULIA_ENABLE_COVERAGE + "Build libnormaliz_julia with C++ coverage instrumentation" OFF) + include_directories( ${gmp_prefix}/include ${normaliz_prefix}/include @@ -28,6 +31,17 @@ include_directories( add_library(${JL_TARGET} SHARED normaliz.cpp) +if(NORMALIZ_JULIA_ENABLE_COVERAGE) + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + message(STATUS "Building ${JL_TARGET} with C++ coverage flags") + target_compile_options(${JL_TARGET} PRIVATE --coverage -O0 -g) + target_link_libraries(${JL_TARGET} --coverage) + else() + message(FATAL_ERROR + "C++ coverage is only supported with GCC or Clang") + endif() +endif() + target_link_libraries(${JL_TARGET} JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl From 265a113df67a185f187077caafcb8f011e7767ff Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 5 Jun 2026 14:13:41 +0200 Subject: [PATCH 2/5] Upload C++ coverage as lcov Generate the C++ coverage report with gcovr. Append it to the Julia lcov report and disable Codecov's own gcov scan. Co-authored-by: Codex --- .github/workflows/CI.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c1b4cfb..742ff0b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -75,15 +75,26 @@ jobs: - name: "Process code coverage" uses: julia-actions/julia-processcoverage@v1 + - name: "Install gcovr" + if: ${{ matrix.cxx-coverage == true }} + run: python3 -m pip install --user gcovr - name: "Process C++ coverage" if: ${{ matrix.cxx-coverage == true }} run: | - find deps/src/build -name '*.gcda' -exec gcov -pb -r -s "$PWD" {} \; + python3 -m gcovr \ + --root "$PWD" \ + --filter deps/src/normaliz.cpp \ + --gcov-object-directory deps/src/build \ + --lcov cxx.lcov + cat cxx.lcov >> lcov.info - name: "Upload coverage data to Codecov" continue-on-error: true uses: codecov/codecov-action@v6 with: token: ${{ secrets.CODECOV_TOKEN }} + disable_search: true + files: lcov.info + plugins: noop docs: name: Documentation From 908b0f5d343b267f403c33b80477da87983387ac Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 5 Jun 2026 14:38:08 +0200 Subject: [PATCH 3/5] Cover cone property output type mapping Add direct tests for each output type reported by the C++ helper, including MatrixFloat, FieldElem, and Void. Co-authored-by: Codex --- test/runtests.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 39e2031..1bf0c81 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -238,6 +238,21 @@ end @test occursin("Complex", err.value.msg) end +@testset "cone property output types" begin + @test String(Normaliz._cone_property_output_type("HilbertBasis")) == "Matrix" + @test String(Normaliz._cone_property_output_type("ExtremeRaysFloat")) == "MatrixFloat" + @test String(Normaliz._cone_property_output_type("Grading")) == "Vector" + @test String(Normaliz._cone_property_output_type("TriangulationDetSum")) == "Integer" + @test String(Normaliz._cone_property_output_type("ExternalIndex")) == "GMPInteger" + @test String(Normaliz._cone_property_output_type("Multiplicity")) == "Rational" + @test String(Normaliz._cone_property_output_type("RenfVolume")) == "FieldElem" + @test String(Normaliz._cone_property_output_type("EuclideanVolume")) == "Float" + @test String(Normaliz._cone_property_output_type("EmbeddingDim")) == "MachineInteger" + @test String(Normaliz._cone_property_output_type("IsPointed")) == "Bool" + @test String(Normaliz._cone_property_output_type("Triangulation")) == "Complex" + @test String(Normaliz._cone_property_output_type("DefaultMode")) == "Void" +end + # TODO: reactivate these tests once Renf support is back #@testset "basic renf test" begin # r = Normaliz.RenfClass("a4-5a2+5", "a", "1.9021+/-0.01") From f9a26631161e70aef9d1c9b5b5667be726ddd3b7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 5 Jun 2026 14:41:38 +0200 Subject: [PATCH 4/5] Ignore throw branches in C++ coverage Pass gcovr's exclude-throw-branches option when creating the C++ lcov report. Co-authored-by: Codex --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 742ff0b..a64979c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -85,6 +85,7 @@ jobs: --root "$PWD" \ --filter deps/src/normaliz.cpp \ --gcov-object-directory deps/src/build \ + --exclude-throw-branches \ --lcov cxx.lcov cat cxx.lcov >> lcov.info - name: "Upload coverage data to Codecov" From 1106497938ecd86853fdc596f1bd7a75410b21ce Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 5 Jun 2026 14:53:20 +0200 Subject: [PATCH 5/5] tweaks --- .github/workflows/CI.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a64979c..401e807 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -77,25 +77,28 @@ jobs: uses: julia-actions/julia-processcoverage@v1 - name: "Install gcovr" if: ${{ matrix.cxx-coverage == true }} - run: python3 -m pip install --user gcovr + run: python -m pip install gcovr - name: "Process C++ coverage" if: ${{ matrix.cxx-coverage == true }} run: | - python3 -m gcovr \ + gcovr --version + gcovr \ --root "$PWD" \ --filter deps/src/normaliz.cpp \ --gcov-object-directory deps/src/build \ --exclude-throw-branches \ - --lcov cxx.lcov - cat cxx.lcov >> lcov.info + --xml-pretty \ + --output coverage.xml \ + --print-summary - name: "Upload coverage data to Codecov" continue-on-error: true uses: codecov/codecov-action@v6 with: token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.xml disable_search: true - files: lcov.info - plugins: noop + fail_ci_if_error: true + verbose: true docs: name: Documentation