Skip to content

Commit c1f2ee2

Browse files
committed
Add CodeCov
1 parent 60ffd22 commit c1f2ee2

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

.github/workflows/c-cpp.yml

+26-12
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ name: CI
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [main]
66
pull_request:
7-
branches: [ "main" ]
7+
branches: [main]
88

99
env:
1010
BUILD_TYPE: Release
1111

1212
jobs:
13-
build:
14-
13+
build-and-test:
1514
runs-on: ubuntu-latest
1615

1716
env:
@@ -23,17 +22,32 @@ jobs:
2322
- name: Install dependencies
2423
run: |
2524
sudo apt-get update
26-
sudo apt-get install -y build-essential cmake libgtest-dev googletest
27-
28-
- name: Create build directory
29-
run: mkdir build
25+
sudo apt-get install -y build-essential cmake lcov
26+
sudo apt-get install -y libgtest-dev googletest
3027
3128
- name: Configure CMake
32-
run: cmake -B ${{github.workspace}}/build
29+
run: |
30+
cmake -B build -DCMAKE_BUILD_TYPE=Debug \
31+
-DCMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage -fprofile-update=atomic -O0"
3332
3433
- name: Build
35-
run: cmake --build ${{github.workspace}}/build
34+
run: cmake --build build --clean-first
3635

37-
- name: Run Unit Tests
38-
working-directory: ${{github.workspace}}/build
36+
- name: Run Tests
37+
working-directory: ./build
3938
run: ./test/flexitimerTest
39+
40+
- name: Generate Coverage Report
41+
run: |
42+
lcov --capture --directory ./build --output-file coverage.info \
43+
--rc geninfo_unexecuted_blocks=1 \
44+
--ignore-errors mismatch,negative
45+
lcov --remove coverage.info '/usr/*' --output-file coverage.info
46+
lcov --list coverage.info || true # Prevent failure on warnings
47+
48+
- name: Upload to Codecov
49+
uses: codecov/codecov-action@v5
50+
with:
51+
token: ${{ secrets.CODECOV_TOKEN }}
52+
file: coverage.info
53+
fail_ci_if_error: false

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Build Status](https://github.com/diffstorm/flexitimer/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/diffstorm/flexitimer/actions)
44
[![License](https://img.shields.io/github/license/diffstorm/flexitimer)](https://github.com/diffstorm/flexitimer/blob/main/LICENSE)
55
[![Language](https://img.shields.io/github/languages/top/diffstorm/flexitimer)](https://github.com/diffstorm/flexitimer)
6+
[![Code Coverage](https://codecov.io/gh/diffstorm/flexitimer/branch/main/graph/badge.svg)](https://codecov.io/gh/diffstorm/flexitimer)
67
![GitHub Stars](https://img.shields.io/github/stars/diffstorm/flexitimer?style=social)
78
![Platforms](https://img.shields.io/badge/Platform-Linux%20%7C%20Windows%20%7C%20macOS-lightgrey)
89

0 commit comments

Comments
 (0)