Skip to content

Commit 63d3696

Browse files
ShfdisShfdis
authored andcommitted
add proper codecov label to the repo
1 parent f9e21e6 commit 63d3696

4 files changed

Lines changed: 39 additions & 6 deletions

File tree

.github/actions/gcovr/post_pr_comment.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,18 @@ summary = json.loads(Path(os.environ["SUMMARY_JSON"]).read_text())
3333
repo = os.environ["GITHUB_REPOSITORY"]
3434
run_id = os.environ["GITHUB_RUN_ID"]
3535
36-
line = summary["line"]
37-
branch = summary["branch"]
38-
func = summary["function"]
36+
def metric(name: str) -> dict:
37+
if name in summary:
38+
return summary[name]
39+
return {
40+
"covered": summary[f"{name}_covered"],
41+
"num": summary[f"{name}_total"],
42+
"percent": summary.get(f"{name}_percent") or 0,
43+
}
44+
45+
line = metric("line")
46+
branch = metric("branch")
47+
func = metric("function")
3948
4049
def bar(percent: float) -> str:
4150
filled = max(0, min(10, int(round(percent / 10))))

.github/actions/gcovr/run_gcovr.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,19 @@ if [[ -n "${GITHUB_STEP_SUMMARY:-}" && -f "${OUTPUT_DIR}/summary.json" ]]; then
3838
echo "| Metric | Covered | Total | Percent |"
3939
echo "| --- | ---: | ---: | ---: |"
4040
jq -r '
41-
.line as $l
42-
| .branch as $b
43-
| .function as $f
41+
def metric($name):
42+
if has($name) then
43+
.[$name]
44+
else
45+
{
46+
covered: .[$name + "_covered"],
47+
num: .[$name + "_total"],
48+
percent: .[$name + "_percent"]
49+
}
50+
end;
51+
metric("line") as $l
52+
| metric("branch") as $b
53+
| metric("function") as $f
4454
| "| Line | \($l.covered) | \($l.num) | \($l.percent // 0)% |",
4555
"| Branch | \($b.covered) | \($b.num) | \($b.percent // 0)% |",
4656
"| Function | \($f.covered) | \($f.num) | \($f.percent // 0)% |"

.github/workflows/coverage.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
runs-on: ubuntu-22.04
1919
permissions:
2020
contents: read
21+
id-token: write
2122
pull-requests: write
2223
services:
2324
ydb:
@@ -71,6 +72,17 @@ jobs:
7172
gcov-executable: gcov-13
7273
post-pr-comment: ${{ github.event_name == 'pull_request' }}
7374

75+
- name: Upload coverage to Codecov
76+
uses: codecov/codecov-action@v5
77+
with:
78+
use_oidc: true
79+
files: build/coverage/cobertura.xml
80+
disable_search: true
81+
flags: sdk
82+
name: ydb-cpp-sdk
83+
fail_ci_if_error: true
84+
verbose: true
85+
7486
- name: Upload coverage reports
7587
uses: actions/upload-artifact@v4
7688
with:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# YDB C++ SDK: driver for [YDB](https://github.com/ydb-platform/ydb)
22

3+
[![Codecov](https://codecov.io/gh/ydb-platform/ydb-cpp-sdk/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ydb-platform/ydb-cpp-sdk)
4+
35
## Building YDB C++ SDK from sources
46

57
### Prerequisites

0 commit comments

Comments
 (0)