这是indexloc提供的服务,不要输入任何密码
Skip to content

ci: improved coverage calculation setup #136

ci: improved coverage calculation setup

ci: improved coverage calculation setup #136

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
pull_request:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Update submodules
run: git submodule update --init --recursive
- name: Configure and build
run: mkdir build && cd build && cmake .. && cmake --build .
# This workflow contains a single job called "build"
test:
# The type of runner that the job will run on
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Update submodules
run: git submodule update --init --recursive
- name: Install tools
run: sudo apt-get update && sudo apt-get install -y lcov
- name: Configure and build
run: mkdir build && cd build && cmake -DBUILD_TESTING=ON -DCOVERAGE_CHECK=on .. && cmake --build .
- name: Run tests
run: cd ./build && make test
- name: Collect coverage data (version-aware)
run: |
# Check lcov version and use appropriate flags
LCOV_VERSION=$(lcov --version 2>&1 | grep -oP 'lcov version \K[0-9]+\.[0-9]+' || echo "0.0")
echo "Detected lcov version: $LCOV_VERSION"
# lcov 2.0+ supports geninfo_unexecuted_blocks, older versions (1.x) do not
if [ "$(printf '%s\n' "2.0" "$LCOV_VERSION" | sort -V | head -n1)" = "2.0" ]; then
echo "Using lcov 2.0+ flags with geninfo_unexecuted_blocks"
/usr/bin/lcov --directory ./build --capture --output-file ./build/coverage.info \
--rc geninfo_unexecuted_blocks=1 --ignore-errors mismatch,negative,unused
else
echo "Using lcov 1.x flags (geninfo_unexecuted_blocks not supported)"
/usr/bin/lcov --directory ./build --capture --output-file ./build/coverage.info \
--ignore-errors mismatch,negative,unused
fi
# Filter coverage data (same for all versions)
/usr/bin/lcov --ignore-errors unused -remove ./build/coverage.info \
"/usr/*" \
"*/tests/*" \
"*/src/demo/*" \
--output-file ./build/coverage.info
- name: Show coverage summary
run: /usr/bin/lcov --list ./build/coverage.info
- uses: codecov/codecov-action@v4
if: github.ref == 'refs/heads/main'
with:
fail_ci_if_error: true
files: ./build/coverage.info
exclude: tests, src/demo
flags: unittests # optional
token: ${{ secrets.CODECOV_TOKEN }} # required
verbose: true # optional (default = false)