Skip to content

Commit 1f4c5f0

Browse files
authored
Create coverage.yml
1 parent 7cbd645 commit 1f4c5f0

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/coverage.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- '**/*.cpp'
8+
- '**/*.hpp'
9+
- 'CMakeLists.txt'
10+
- 'cmake/Coverage.cmake'
11+
- '.github/workflows/coverage.yml'
12+
13+
jobs:
14+
coverage:
15+
name: Coverage Report
16+
runs-on: ubuntu-latest
17+
env:
18+
CMAKE_C_COMPILER_LAUNCHER: ccache
19+
CMAKE_CXX_COMPILER_LAUNCHER: ccache
20+
CCACHE_DIR: ${{ github.workspace }}/.ccache
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with: { fetch-depth: 0 }
26+
27+
- name: Install CMake and Ninja
28+
uses: lukka/get-cmake@latest
29+
with:
30+
cmakeVersion: ^3.28.0
31+
ninjaVersion: ^1.11.0
32+
33+
- name: Install dependencies
34+
run: |
35+
sudo apt-get -qq update
36+
sudo apt install -y gcc g++ ccache gcovr lcov
37+
38+
- name: Cache ccache
39+
uses: actions/cache@v3
40+
with:
41+
path: $CACHE_DIR
42+
key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ hashFiles('CMakeLists.txt') }}
43+
restore-keys: |
44+
${{ runner.os }}-ccache-
45+
46+
- name: Cache build directory
47+
uses: actions/cache@v3
48+
with:
49+
path: build/
50+
key: ${{ runner.os }}-build-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ github.sha }}
51+
restore-keys: |
52+
${{ runner.os }}-build-
53+
54+
- name: Configure → Build → Test (Coverage)
55+
run: cmake --workflow --preset coverage-report
56+
57+
- name: Generate coverage XML
58+
run: cmake --build --preset gcc-Coverage --target coverage
59+
60+
- name: Upload coverage to Codecov
61+
uses: codecov/codecov-action@v3
62+
with:
63+
files: build/gcc-Coverage/coverage.xml
64+
token: ${{ secrets.CODECOV_TOKEN }}
65+
fail_ci_if_error: true

0 commit comments

Comments
 (0)