Skip to content

Commit

Permalink
Use Codecov for coverage (#22)
Browse files Browse the repository at this point in the history
* CI: Use Codecov for coverage

* CI: Use Codecov for coverage [2]

* CI: Use Codecov for coverage [3]

* CI: Use Codecov for coverage [5]

* CI: Use Codecov for coverage [6]

* CI: Use Codecov for coverage [7]

Downgrade Codecov script from v4 to v3 (Codecov token discovery failure bug).
  • Loading branch information
axionbuster authored Feb 14, 2024
1 parent eb03aa6 commit c5c1916
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
- os: ubuntu-latest
c_compiler: clang-17
cpp_compiler: clang++-17
cxx_flags: -fcoverage-mapping -fprofile-instr-generate
c_flags: -fcoverage-mapping -fprofile-instr-generate
- os: ubuntu-latest
c_compiler: icx
cpp_compiler: icpx
Expand Down Expand Up @@ -96,24 +98,53 @@ jobs:
echo "PATH = $PATH"
- 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
if: matrix.cxx_flags == ''
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Configure CMake (Coverage)
if: matrix.cxx_flags != ''
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}"
-DCMAKE_C_FLAGS="${{ matrix.c_flags }}"
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows
# generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
if: matrix.cxx_flags == ''
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# 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
run: ctest --build-config ${{ matrix.build_type }}

- name: Test (Coverage)
if: matrix.cxx_flags != ''
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# In the third line, `tests/units` is the name of the test runner binary.
run: |
pwd
ls
ctest --build-config ${{ matrix.build_type }}
llvm-profdata-17 merge -sparse tests/default.profraw -o my_profile
llvm-cov-17 show -instr-profile my_profile tests/units > coverage.txt
ls
- name: Upload coverage reports to Codecov
if: matrix.cxx_flags != ''
uses: codecov/codecov-action@v3
env:
token: ${{ secrets.CODECOV_TOKEN }}
slug: axionbuster/grass

0 comments on commit c5c1916

Please sign in to comment.