Skip to content

Commit 1ddd35e

Browse files
committed
Add per-language coverage reporting
1 parent 8993c30 commit 1ddd35e

File tree

16 files changed

+239
-92
lines changed

16 files changed

+239
-92
lines changed

.github/workflows/build-cpp.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,24 @@ jobs:
2020
- name: Build
2121
if: steps.detect.outputs.present == 'true'
2222
run: |
23-
cmake -S cpp -B cppbuild
23+
cmake -S cpp -B cppbuild -DEPOCH_COVERAGE=ON
2424
cmake --build cppbuild
2525
- name: Test
2626
if: steps.detect.outputs.present == 'true'
2727
run: ctest --test-dir cppbuild --output-on-failure
28+
- name: Coverage
29+
if: steps.detect.outputs.present == 'true'
30+
run: |
31+
python -m pip install --upgrade pip
32+
python -m pip install gcovr
33+
gcovr -r . --object-directory cppbuild --xml-pretty -o cpp/coverage.xml --filter cpp
34+
- name: Upload coverage
35+
if: steps.detect.outputs.present == 'true'
36+
uses: codecov/codecov-action@v4
37+
with:
38+
files: cpp/coverage.xml
39+
flags: cpp
40+
fail_ci_if_error: false
2841
- name: Skip (no C++ project yet)
2942
if: steps.detect.outputs.present != 'true'
3043
run: echo "No C++ sources yet."

.github/workflows/build-dotnet.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ jobs:
3232
fi
3333
- name: Test
3434
if: steps.detect.outputs.present == 'true' && hashFiles('dotnet/Epoch.Tests/Epoch.Tests.csproj') != ''
35-
run: dotnet run --project dotnet/Epoch.Tests/Epoch.Tests.csproj
35+
run: dotnet test dotnet/Epoch.Tests/Epoch.Tests.csproj --collect:"XPlat Code Coverage"
36+
- name: Upload coverage
37+
if: steps.detect.outputs.present == 'true' && hashFiles('dotnet/Epoch.Tests/Epoch.Tests.csproj') != ''
38+
uses: codecov/codecov-action@v4
39+
with:
40+
files: dotnet/Epoch.Tests/TestResults/**/coverage.cobertura.xml
41+
flags: dotnet
42+
fail_ci_if_error: false
3643
- name: Skip (no .NET project yet)
3744
if: steps.detect.outputs.present != 'true'
3845
run: echo "No .NET sources yet."

.github/workflows/build-go.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ jobs:
2626
if: steps.detect.outputs.present == 'true'
2727
run: |
2828
cd go
29-
go test ./...
29+
go test ./... -coverprofile=coverage.out
30+
- name: Upload coverage
31+
if: steps.detect.outputs.present == 'true'
32+
uses: codecov/codecov-action@v4
33+
with:
34+
files: go/coverage.out
35+
flags: go
36+
fail_ci_if_error: false
3037
- name: Skip (no Go project yet)
3138
if: steps.detect.outputs.present != 'true'
3239
run: echo "No Go sources yet."

.github/workflows/build-java.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,18 @@ jobs:
2323
with:
2424
distribution: temurin
2525
java-version: "17"
26+
- name: Coverage (script)
27+
if: steps.detect.outputs.present == 'true' && hashFiles('java/scripts/run-coverage.sh') != ''
28+
run: java/scripts/run-coverage.sh
29+
- name: Upload coverage
30+
if: steps.detect.outputs.present == 'true' && hashFiles('java/scripts/run-coverage.sh') != ''
31+
uses: codecov/codecov-action@v4
32+
with:
33+
files: java/target/jacoco.xml
34+
flags: java
35+
fail_ci_if_error: false
2636
- name: Test (script)
27-
if: steps.detect.outputs.present == 'true' && hashFiles('java/scripts/run-tests.sh') != ''
37+
if: steps.detect.outputs.present == 'true' && hashFiles('java/scripts/run-coverage.sh') == '' && hashFiles('java/scripts/run-tests.sh') != ''
2838
run: java/scripts/run-tests.sh
2939
- name: Build (Gradle)
3040
if: steps.detect.outputs.present == 'true' && hashFiles('java/scripts/run-tests.sh') == '' && hashFiles('java/gradlew') != ''

.github/workflows/build-node.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ jobs:
2828
cd node
2929
npm install --no-package-lock
3030
npm test
31+
- name: Upload coverage
32+
if: steps.detect.outputs.present == 'true'
33+
uses: codecov/codecov-action@v4
34+
with:
35+
files: node/coverage/lcov.info
36+
flags: node
37+
fail_ci_if_error: false
3138
- name: Skip (no Node project yet)
3239
if: steps.detect.outputs.present != 'true'
3340
run: echo "No Node sources yet."

.github/workflows/build-python.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ jobs:
2626
if: steps.detect.outputs.present == 'true'
2727
run: |
2828
cd python
29-
python -m unittest discover -s tests
29+
python -m pip install --upgrade pip
30+
python -m pip install coverage
31+
coverage run -m unittest discover -s tests
32+
coverage xml -o coverage.xml
33+
- name: Upload coverage
34+
if: steps.detect.outputs.present == 'true'
35+
uses: codecov/codecov-action@v4
36+
with:
37+
files: python/coverage.xml
38+
flags: python
39+
fail_ci_if_error: false
3040
- name: Skip (no Python project yet)
3141
if: steps.detect.outputs.present != 'true'
3242
run: echo "No Python sources yet."

.github/workflows/docs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ jobs:
1414
node-version: "22"
1515
cache: "pnpm"
1616
- name: Enable pnpm
17-
run: corepack enable
17+
run: |
18+
corepack enable
19+
corepack prepare [email protected] --activate
1820
- name: Install
1921
run: pnpm install --frozen-lockfile
2022
- name: Build

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ node_modules/
6262
docs/.vuepress/dist/
6363
docs/.vuepress/cache/
6464
docs/.vuepress/temp/
65+
node/coverage/
6566

6667
# Build outputs
6768
cppbuild/
@@ -70,6 +71,7 @@ dotnet/bin/
7071
dotnet/obj/
7172
dotnet/**/bin/
7273
dotnet/**/obj/
74+
dotnet/**/TestResults/
7375
python/__pycache__/
7476
python/**/__pycache__/
7577
python/.pytest_cache/
@@ -79,3 +81,8 @@ python/dist/
7981
python/*.egg-info/
8082
python/**/*.pyc
8183
.gocache/
84+
go/coverage.out
85+
cpp/coverage.xml
86+
java/target/jacoco.exec
87+
java/target/jacoco.xml
88+
python/coverage.xml

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020

2121
## 支持语言
2222

23-
| Language | Version | Build |
24-
|---|---|---|
25-
| ![C++](https://img.shields.io/badge/C%2B%2B-00599C?logo=c%2B%2B&logoColor=white) | C++17 | [![build-cpp](https://github.com/cuihairu/epoch/actions/workflows/build-cpp.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-cpp.yml) |
26-
| ![Java](https://img.shields.io/badge/Java-007396?logo=openjdk&logoColor=white) | Java 17 | [![build-java](https://github.com/cuihairu/epoch/actions/workflows/build-java.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-java.yml) |
27-
| ![.NET](https://img.shields.io/badge/.NET-512BD4?logo=dotnet&logoColor=white) | .NET 8.0 | [![build-dotnet](https://github.com/cuihairu/epoch/actions/workflows/build-dotnet.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-dotnet.yml) |
28-
| ![Go](https://img.shields.io/badge/Go-00ADD8?logo=go&logoColor=white) | Go 1.24 | [![build-go](https://github.com/cuihairu/epoch/actions/workflows/build-go.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-go.yml) |
29-
| ![Node.js](https://img.shields.io/badge/Node.js-339933?logo=node.js&logoColor=white) | Node.js 22 | [![build-node](https://github.com/cuihairu/epoch/actions/workflows/build-node.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-node.yml) |
30-
| ![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white) | Python 3.12 | [![build-python](https://github.com/cuihairu/epoch/actions/workflows/build-python.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-python.yml) |
23+
| Language | Version | Build | Coverage |
24+
|---|---|---|---|
25+
| ![C++](https://img.shields.io/badge/C%2B%2B-00599C?logo=c%2B%2B&logoColor=white) | C++17 | [![build-cpp](https://github.com/cuihairu/epoch/actions/workflows/build-cpp.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-cpp.yml) | [![codecov](https://codecov.io/gh/cuihairu/epoch/branch/main/graph/badge.svg?flag=cpp)](https://codecov.io/gh/cuihairu/epoch) |
26+
| ![Java](https://img.shields.io/badge/Java-007396?logo=openjdk&logoColor=white) | Java 17 | [![build-java](https://github.com/cuihairu/epoch/actions/workflows/build-java.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-java.yml) | [![codecov](https://codecov.io/gh/cuihairu/epoch/branch/main/graph/badge.svg?flag=java)](https://codecov.io/gh/cuihairu/epoch) |
27+
| ![.NET](https://img.shields.io/badge/.NET-512BD4?logo=dotnet&logoColor=white) | .NET 8.0 | [![build-dotnet](https://github.com/cuihairu/epoch/actions/workflows/build-dotnet.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-dotnet.yml) | [![codecov](https://codecov.io/gh/cuihairu/epoch/branch/main/graph/badge.svg?flag=dotnet)](https://codecov.io/gh/cuihairu/epoch) |
28+
| ![Go](https://img.shields.io/badge/Go-00ADD8?logo=go&logoColor=white) | Go 1.24 | [![build-go](https://github.com/cuihairu/epoch/actions/workflows/build-go.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-go.yml) | [![codecov](https://codecov.io/gh/cuihairu/epoch/branch/main/graph/badge.svg?flag=go)](https://codecov.io/gh/cuihairu/epoch) |
29+
| ![Node.js](https://img.shields.io/badge/Node.js-339933?logo=node.js&logoColor=white) | Node.js 22 | [![build-node](https://github.com/cuihairu/epoch/actions/workflows/build-node.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-node.yml) | [![codecov](https://codecov.io/gh/cuihairu/epoch/branch/main/graph/badge.svg?flag=node)](https://codecov.io/gh/cuihairu/epoch) |
30+
| ![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white) | Python 3.12 | [![build-python](https://github.com/cuihairu/epoch/actions/workflows/build-python.yml/badge.svg)](https://github.com/cuihairu/epoch/actions/workflows/build-python.yml) | [![codecov](https://codecov.io/gh/cuihairu/epoch/branch/main/graph/badge.svg?flag=python)](https://codecov.io/gh/cuihairu/epoch) |
3131

3232
## 文档
3333
- 概念与设计:`docs/guide/concepts.md`

codecov.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: 0
6+
patch:
7+
default:
8+
target: 0
9+
10+
flags:
11+
cpp:
12+
paths:
13+
- cpp/
14+
java:
15+
paths:
16+
- java/
17+
dotnet:
18+
paths:
19+
- dotnet/
20+
go:
21+
paths:
22+
- go/
23+
node:
24+
paths:
25+
- node/
26+
python:
27+
paths:
28+
- python/

0 commit comments

Comments
 (0)