Skip to content

Commit 0bc631b

Browse files
committed
feat: add C/C++ coverage workflow
1 parent 7349c1d commit 0bc631b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/coverage.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: C/C++ Coverage
2+
3+
on:
4+
push:
5+
branches: [ main, v* ]
6+
pull_request:
7+
branches: [ main, v* ]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Install dependencies
17+
run: sudo apt-get update && sudo apt-get install -y lcov gcc cmake make
18+
19+
- name: Configure CMake (with coverage flags)
20+
run: |
21+
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="--coverage" -DCMAKE_EXE_LINKER_FLAGS="--coverage"
22+
23+
- name: Build
24+
run: cmake --build build
25+
26+
- name: Run tests
27+
run: |
28+
cd build && ctest --output-on-failure
29+
30+
- name: Generate coverage report
31+
run: |
32+
lcov --capture --directory build --output-file coverage.info
33+
lcov --remove coverage.info '*/Unity/*' '*/cJSON/*' --output-file coverage.info
34+
lcov --list coverage.info
35+
36+
- name: Upload coverage artifact
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: coverage-report
40+
path: coverage.info

0 commit comments

Comments
 (0)