Skip to content

Commit 3a8959d

Browse files
Add ci.yml and update README.md for codecov
1 parent 7deb0f1 commit 3a8959d

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

.github/workflows/ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
coverage:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Install deps (GTest, lcov)
16+
run: |
17+
sudo apt-get update
18+
sudo apt-get install -y lcov libgtest-dev
19+
# Build GoogleTest (if you vendor it, skip this)
20+
sudo apt-get install -y cmake
21+
sudo cmake -S /usr/src/googletest -B /usr/src/googletest/build
22+
sudo cmake --build /usr/src/googletest/build --target install
23+
24+
- name: Build tests with coverage
25+
run: |
26+
make clean
27+
make tests COVERAGE=1 CXX=g++ CXXFLAGS="-std=c++14 -O0 -g --coverage" LDFLAGS="--coverage"
28+
29+
- name: Run tests
30+
run: ./tests
31+
32+
- name: Generate coverage (LCOV)
33+
run: |
34+
# Capture
35+
lcov --capture --directory . --output-file coverage.info
36+
# Remove system & irrelevant paths
37+
lcov --remove coverage.info '/usr/*' '*/tests/*' '*/third_party/*' --output-file coverage.info
38+
# Optional: HTML report for debugging (artifact, not needed by Codecov)
39+
genhtml coverage.info --output-directory coverage
40+
41+
- name: Upload to Codecov
42+
uses: codecov/codecov-action@v4
43+
with:
44+
files: coverage.info
45+
flags: unittests
46+
name: ubuntu-gcc
47+
fail_ci_if_error: true
48+
env:
49+
# Public repos don't need a token. Private repos: add a secret CODECOV_TOKEN
50+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<img alt="CI" src="https://img.shields.io/github/actions/workflow/status/JohnsonBiophysicsLab/SLIMED/ci.yml?branch=main&label=CI">
1010
</a>
1111
<!-- Codecov (or Coveralls) -->
12-
<!--a href="https://codecov.io/gh/JohnsonBiophysicsLab/SLIMED">
12+
<a href="https://codecov.io/gh/JohnsonBiophysicsLab/SLIMED">
1313
<img alt="Coverage" src="https://img.shields.io/codecov/c/github/JohnsonBiophysicsLab/SLIMED?logo=codecov">
1414
</a>
1515
<!-- Release -->

0 commit comments

Comments
 (0)