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
31 changes: 23 additions & 8 deletions .github/actions/coverage_epilogue/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,32 @@ inputs:
runs:
using: "composite"
steps:
- name: "Install lcov"
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y lcov

- name: Generate Coverage Report
shell: bash
run: |
lcov --capture --directory ${{ inputs.build-output-dir }} --output-file coverage.info --ignore-errors mismatch
lcov --remove coverage.info '/usr/*' '*/_deps/*' '*/include/bitlib/bit-algorithms/libpopcnt.h' '*/test/inc/*' '*/test/src/*' --output-file coverage.info
# Capture actual coverage data after tests
lcov --capture \
--directory "${{ inputs.build-output-dir }}" \
--output-file coverage.info \
--ignore-errors mismatch

# Combine with baseline
lcov --add-tracefile coverage.baseline \
--add-tracefile coverage.info\
--output-file coverage.info

# Clean the coverage report from system and external deps
lcov --remove coverage.info \
'/usr/*' \
'*/_deps/*' \
'*/include/bitlib/bit-algorithms/libpopcnt.h' \
'*/test/inc/*' \
'*/test/src/*' \
--output-file coverage.info

# Show a summary in the logs
lcov --list coverage.info

# Generate an HTML report
genhtml coverage.info --output-directory out/coverage

Expand All @@ -31,6 +45,7 @@ runs:
name: coverage-report
path: |
out/coverage
coverage.baseline
coverage.info

- name: Coveralls
Expand Down
24 changes: 24 additions & 0 deletions .github/actions/coverage_prologue/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Coverage Prologue"
description: "Installs lcov and generates the baseline coverage"
inputs:
build-output-dir:
required: true
description: 'Build output directory'

runs:
using: "composite"
steps:
- name: "Install lcov"
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y lcov

- name: "Initialize 0% coverage baseline"
shell: bash
run: |
lcov --capture --initial \
--base-directory "$GITHUB_WORKSPACE" \
--directory "${{ inputs.build-output-dir }}" \
--output-file coverage.baseline \
--ignore-errors mismatch
24 changes: 17 additions & 7 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,23 @@ jobs:
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

echo "build-output-dir=$(readlink -f "${{ github.workspace }}/../build")" >> "$GITHUB_OUTPUT"
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }} -S ${{ github.workspace }}
--preset=${{ matrix.preset }}_${{ matrix.os }}_${{ matrix.compiler }}_${{ matrix.stdlib }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
run: |
# Configure
cmake -B ${{ steps.strings.outputs.build-output-dir }} -S ${{ github.workspace }} \
--preset=${{ matrix.preset }}_${{ matrix.os }}_${{ matrix.compiler }}_${{ matrix.stdlib }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}

# Delete any coverage files created from CMake probing
find ${{ github.workspace }} \( -name '*.gcno' -o -name '*.gcda' \) -delete
find ${{ steps.strings.outputs.build-output-dir }} \( -name '*.gcno' -o -name '*.gcda' \) -delete

- name: Register Compiler Problem Matcher
run: echo "::add-matcher::.github/problem_matchers/${{ matrix.compiler}}_problem_matcher.json"

Expand All @@ -115,6 +120,11 @@ jobs:
- name: Unregister Compiler Problem Matcher
run: echo "::remove-matcher owner=${{ matrix.compiler}}::"

- uses: ./.github/actions/coverage_prologue
if: matrix.preset == 'coverage'
with:
build-output-dir: ${{ steps.strings.outputs.build-output-dir }}

- name: Test
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
Expand Down
4 changes: 2 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"name": "gnu_base",
"hidden": true,
"cacheVariables": {
"CMAKE_C_FLAGS_DEBUG": "-DPOPCNT_NO_UNALIGNED -g3 -fno-omit-frame-pointer -fstack-protector-all -fsanitize=address -fsanitize=undefined -finstrument-functions -fno-inline",
"CMAKE_CXX_FLAGS_DEBUG": "-DPOPCNT_NO_UNALIGNED -g3 -fno-omit-frame-pointer -DPOPCNT_NO_UNALIGNED -fstack-protector-all -fsanitize=address -fsanitize=undefined -finstrument-functions -fno-inline",
"CMAKE_C_FLAGS_DEBUG": "-DPOPCNT_NO_UNALIGNED -g3 -fno-omit-frame-pointer -fstack-protector-all -fsanitize=address -fsanitize=undefined -finstrument-functions -fno-inline -fno-inline-small-functions -fno-default-inline",
"CMAKE_CXX_FLAGS_DEBUG": "-DPOPCNT_NO_UNALIGNED -g3 -fno-omit-frame-pointer -DPOPCNT_NO_UNALIGNED -fstack-protector-all -fsanitize=address -fsanitize=undefined -finstrument-functions -fno-inline -fno-inline-small-functions -fno-default-inline",
"CMAKE_C_FLAGS_RELEASE": "-O3 -DNDEBUG -march=native",
"CMAKE_CXX_FLAGS_RELEASE": "-O3 -DNDEBUG -march=native"
}
Expand Down
Loading