Fix CodeCov #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential cmake lcov | |
sudo apt-get install -y libgtest-dev googletest | |
sudo apt-get install -y gcovr # Alternative coverage tool | |
- name: Clean workspace | |
run: | | |
rm -rf build | |
find . -name "*.gcda" -delete | |
- name: Configure CMake | |
run: | | |
cmake -B build -DCMAKE_BUILD_TYPE=Debug \ | |
-DCMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage -fprofile-update=atomic -O0" \ | |
-DCMAKE_EXE_LINKER_FLAGS="-lgcov --coverage" | |
- name: Build | |
run: | | |
cmake --build build --clean-first | |
- name: Run Tests | |
working-directory: ./build | |
run: ./ConcurrentHashMapTest | |
- name: Generate Coverage (lcov) | |
run: | | |
lcov --capture --directory ./build --output-file coverage.info \ | |
--rc geninfo_unexecuted_blocks=1 \ | |
--ignore-errors mismatch,negative | |
lcov --remove coverage.info '/usr/*' '*/test/*' --output-file coverage.info | |
lcov --list coverage.info | |
- name: Generate Coverage (gcovr alternative) | |
run: | | |
gcovr -r ${{ github.workspace }} --exclude-unreachable-branches \ | |
--exclude-throw-branches --html-details coverage.html | |
- name: Upload to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage.info,coverage.xml | |
flags: cpp | |
fail_ci_if_error: false |