Skip to content

Commit 38dbef0

Browse files
committed
🛠️ chore(CI): Create coverage workflow
1 parent 31eb26c commit 38dbef0

File tree

4 files changed

+99
-2
lines changed

4 files changed

+99
-2
lines changed

.github/workflows/coverage.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: coverage
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
coverage:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Install system dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y \
24+
build-essential \
25+
cmake \
26+
git \
27+
lcov \
28+
python3 \
29+
python3-pip
30+
31+
- name: Install Google Test
32+
run: |
33+
git clone https://github.com/google/googletest.git -b v1.14.0
34+
cd googletest
35+
cmake .
36+
make -j$(nproc)
37+
sudo make install
38+
39+
- name: Configure CMake with coverage
40+
run: |
41+
mkdir -p build
42+
cd build
43+
cmake .. \
44+
-DCMAKE_BUILD_TYPE=Debug \
45+
-DBUILD_TESTING=ON \
46+
-DBUILD_COVERAGE=ON
47+
48+
- name: Build
49+
run: |
50+
cd build
51+
cmake --build . -- -j$(nproc)
52+
53+
- name: Run tests with coverage
54+
run: |
55+
cd build
56+
make coverage
57+
58+
- name: Generate coverage summary
59+
run: |
60+
cd build
61+
make coverage-summary
62+
63+
- name: Upload coverage HTML report
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: coverage-report
67+
path: build/coverage_html/
68+
retention-days: 30
69+
70+
- name: Upload coverage to Codecov (optional)
71+
if: github.event_name == 'push' || github.event_name == 'pull_request'
72+
uses: codecov/codecov-action@v4
73+
with:
74+
file: build/coverage.info.cleaned
75+
flags: unittests
76+
name: codecov-umbrella
77+
fail_ci_if_error: false
78+
token: ${{ secrets.CODECOV_TOKEN }}
79+
80+
- name: Display coverage summary in logs
81+
if: always()
82+
run: |
83+
cd build
84+
if [ -f coverage.info.cleaned ]; then
85+
echo "=== Coverage Summary ==="
86+
lcov --summary coverage.info.cleaned
87+
else
88+
echo "Coverage file not found"
89+
fi

.github/workflows/lint.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ name: Lint
22

33
on:
44
pull_request:
5-
branches: [main]
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
69
jobs:
710
lint:
811
runs-on: ubuntu-latest

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: unit-tests
22

33
on:
44
pull_request:
5-
branches: [main]
5+
branches:
6+
- main
7+
workflow_dispatch:
68

79
jobs:
810
build-and-test:

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CppSerial
22

3+
[![unit-tests](https://github.com/NestorDP/cppserial/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/NestorDP/cppserial/actions/workflows/unit-tests.yml)
4+
[![coverage](https://github.com/NestorDP/cppserial/actions/workflows/coverage.yml/badge.svg)](https://github.com/NestorDP/cppserial/actions/workflows/coverage.yml)
5+
36
**C++ Application Programming Interface for the `asm/termbits.h` C library**
47

58
---

0 commit comments

Comments
 (0)