Skip to content

Commit 77b089a

Browse files
authored
Fix codecov upload condition in CI workflow (#361)
* Fix codecov upload condition in CI workflow The upload condition used 'discard' which never matches any matrix value, preventing coverage data from being uploaded. Changed to 'ubuntu' to match the actual os-type matrix value. * Replace deprecated Codecov bash uploader with official GitHub Action The bash uploader now requires a token and is deprecated. Using codecov/codecov-action@v5 which handles authentication automatically for public repos via GitHub OIDC. * Add gcovr step to generate coverage report before Codecov upload The codecov-action@v5 does not auto-process gcov data like the old bash uploader did. This adds a step to run gcovr to convert .gcda/.gcno files to Cobertura XML format, which codecov can parse. * Add CODECOV_TOKEN for protected branch uploads Codecov requires authentication token for uploading coverage reports to protected branches. * Trigger CI to test Codecov upload with token * Add --root option to gcovr for correct source path mapping The coverage report was unusable because gcovr generated paths relative to the build directory (e.g., ../src/webserver.cpp). Adding --root .. ensures paths are relative to the repository root, allowing Codecov to correctly match source files. * Exclude test directory from coverage reports * Ignore tests
1 parent e06f83a commit 77b089a

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

.github/workflows/verify-build.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,16 @@ jobs:
665665
sleep 5 && ab -n 1000000 -c 100 127.0.0.1:8080/plaintext
666666
if: ${{ matrix.build-type == 'threads' }}
667667

668-
- name: Push code coverage data
668+
- name: Generate coverage report
669669
run: |
670-
cd build ;
671-
bash <(curl -s https://codecov.io/bash) ;
672-
if: ${{ matrix.os-type == 'discard' && matrix.c-compiler == 'gcc' && matrix.debug == 'debug' && matrix.coverage == 'coverage' && success() }}
670+
cd build
671+
gcovr --root .. --exclude test/ --xml coverage.xml --xml-pretty
672+
if: ${{ matrix.os-type == 'ubuntu' && matrix.c-compiler == 'gcc' && matrix.debug == 'debug' && matrix.coverage == 'coverage' && success() }}
673+
674+
- name: Upload coverage to Codecov
675+
uses: codecov/codecov-action@v5
676+
with:
677+
token: ${{ secrets.CODECOV_TOKEN }}
678+
files: build/coverage.xml
679+
fail_ci_if_error: false
680+
if: ${{ matrix.os-type == 'ubuntu' && matrix.c-compiler == 'gcc' && matrix.debug == 'debug' && matrix.coverage == 'coverage' && success() }}

codecov.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ comment:
1818
layout: "reach,diff,flags,files,footer"
1919
behavior: default
2020
require_changes: no
21+
22+
ignore:
23+
- "test"

0 commit comments

Comments
 (0)