Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit 17b5afd

Browse files
authored
Merge pull request #165 from jmarrec/codecov
2 parents 7cab40a + d224e44 commit 17b5afd

1 file changed

Lines changed: 42 additions & 8 deletions

File tree

.github/workflows/build_cmake.yml

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ jobs:
2828
strategy:
2929
matrix:
3030
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
31+
include:
32+
- os: ubuntu-latest
33+
ENABLE_COVERAGE: ON
34+
- os: windows-latest
35+
# Windows works differently
36+
ENABLE_COVERAGE: OFF
37+
- os: macos-latest
38+
ENABLE_COVERAGE: ON
39+
3140

3241
steps:
3342
- uses: actions/checkout@v2
@@ -44,24 +53,49 @@ jobs:
4453

4554
- name: Install conan
4655
run: |
47-
pip3 install wheel setuptools
56+
pip3 install wheel setuptools gcovr
4857
pip3 install conan --upgrade
49-
- name: Ubuntu - Fix Conan Path
50-
if: startsWith(matrix.os,'ubuntu')
58+
59+
- name: Install / Configure dependencies
60+
shell: bash
5161
run: |
52-
sudo update-alternatives --install /usr/bin/conan conan /home/runner/.local/bin/conan 10
53-
sudo update-alternatives --config conan
62+
if [ "$RUNNER_OS" == "Linux" ]; then
63+
echo "Ubuntu - Fix Conan Path"
64+
sudo update-alternatives --install /usr/bin/conan conan /home/runner/.local/bin/conan 10
65+
sudo update-alternatives --config conan
66+
elif [ "$RUNNER_OS" == "Windows" ]; then
67+
echo "Using chocolatey to install OpenCppCoverage"
68+
choco install opencppcoverage
69+
# Add to Path
70+
echo "C:/Program Files/OpenCppCoverage" >> $GITHUB_PATH
71+
fi;
5472
5573
- name: Configure CMake
5674
run: |
57-
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=$BUILD_TYPE
75+
cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE -DENABLE_COVERAGE:BOOL=${{ matrix.ENABLE_COVERAGE }}
5876
5977
- name: Build
6078
# Execute the build. You can specify a specific target with "--target <NAME>"
6179
run: cmake --build ./build --config $BUILD_TYPE
6280

63-
- name: Test
81+
- name: Unix - Test and coverage
82+
if: runner.os != 'Windows'
6483
working-directory: ./build
6584
# Execute tests defined by the CMake configuration.
6685
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
67-
run: ctest -C $BUILD_TYPE
86+
run: |
87+
ctest -C $BUILD_TYPE
88+
gcovr -j $(nproc) --delete --root ../ --print-summary --xml-pretty --xml coverage.xml .
89+
90+
- name: Windows - Test and coverage
91+
if: runner.os == 'Windows'
92+
working-directory: ./build
93+
run: |
94+
OpenCppCoverage.exe --sources cpp_starter_project --export_type cobertura:coverage.xml --cover_children -- ctest -C $BUILD_TYPE
95+
96+
- name: Publish to codecov
97+
uses: codecov/codecov-action@v2
98+
with:
99+
flags: ${{ runner.os }}
100+
name: ${{ runner.os }}-coverage
101+
files: ./build/coverage.xml

0 commit comments

Comments
 (0)