6
6
pull_request :
7
7
branches : [ "main" ]
8
8
9
- env :
10
- # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11
- BUILD_TYPE : Release
12
-
13
9
jobs :
14
10
build :
15
11
strategy :
16
12
matrix :
13
+ # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
14
+ build : [Release, Debug]
17
15
os : [ubuntu-latest, windows-latest]
18
16
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
19
17
# You can convert this to a matrix build if you need cross-platform coverage.
@@ -26,16 +24,39 @@ jobs:
26
24
- name : Configure CMake
27
25
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
28
26
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
29
- run : cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE }}
27
+ run : cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build }}
30
28
31
29
- name : Build
32
30
# Build your program with the given configuration
33
- run : cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE }}
31
+ run : cmake --build ${{github.workspace}}/build --config ${{matrix.build }}
34
32
35
33
- name : Test
36
34
working-directory : ${{github.workspace}}/build
37
35
# Execute tests defined by the CMake configuration.
38
36
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
39
37
# Use debug flag to show all exeucted tests
40
- run : ctest --debug -C ${{env.BUILD_TYPE}}
41
-
38
+ run : ctest --debug -C ${{matrix.build}}
39
+
40
+ # Coverage collection based on https://about.codecov.io/blog/how-to-set-up-codecov-with-c-plus-plus-and-github-actions/
41
+ - name : Prepare Coverage
42
+ if : ${{ (matrix.OS == 'windows-latest') && ( matrix.build == 'Debug') }}
43
+ run : |
44
+ choco install OpenCppCoverage -y
45
+ echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH
46
+
47
+ - name : Get Coverage
48
+ if : ${{ (matrix.OS == 'windows-latest') && ( matrix.build == 'Debug') }}
49
+ working-directory : ${{github.workspace}}/build/Src/libCZI_UnitTests/${{matrix.build}}
50
+ shell : cmd
51
+ run : OpenCppCoverage.exe --export_type cobertura:${{github.workspace}}\coverage.xml --config_file "${{github.workspace}}\opencppcoverage.txt" -- libCZI_UnitTests.exe
52
+
53
+ - name : Upload Coverage
54
+ uses : codecov/codecov-action@v3
55
+ if : ${{ (matrix.OS == 'windows-latest') && ( matrix.build == 'Debug') }}
56
+ with :
57
+ files : ./coverage.xml
58
+ fail_ci_if_error : true
59
+ verbose : true
60
+ # Only one flag to be safe with
61
+ # https://docs.codecov.com/docs/flags#one-to-one-relationship-of-flags-to-uploads
62
+ flags : ${{matrix.OS}}
0 commit comments