ci: replace lcov by gcovr (#965)

This commit is contained in:
Sergiu Deitsch 2023-10-07 02:29:58 +02:00 committed by GitHub
parent 1dffb4eb29
commit f6e4d960e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 38 deletions

View File

@ -25,7 +25,7 @@ jobs:
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \ DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
build-essential \ build-essential \
cmake \ cmake \
lcov \ gcovr \
libgflags-dev \ libgflags-dev \
libunwind-dev \ libunwind-dev \
ninja-build ninja-build
@ -117,27 +117,22 @@ jobs:
- name: Generate Coverage - name: Generate Coverage
if: matrix.build_type == 'Debug' if: matrix.build_type == 'Debug'
run: | run: |
lcov --directory . --capture --output-file coverage.info cd build_${{matrix.build_type}}
lcov --remove coverage.info \ gcovr -r .. . -s --xml coverage.xml
'${{github.workspace}}/gtest/*' \ cd ..
'*/src/*_unittest.cc' \
'*/src/googletest.h' \
'*/src/mock-log.h' \
'/usr/*' \
--output-file coverage.info
for file in src/glog/*.h.in; do for file in src/glog/*.h.in; do
name=$(basename ${file}) name=$(basename ${file})
name_we=${name%.h.in} name_we=${name%.h.in}
sed -i "s|build_${{matrix.build_type}}/glog/${name_we}.h\$|${file}|g" coverage.info sed -i "s|build_${{matrix.build_type}}/glog/${name_we}.h|${file}|g" build_${{matrix.build_type}}/coverage.xml
done done
lcov --list coverage.info
- name: Upload Coverage to Codecov - name: Upload Coverage to Codecov
if: matrix.build_type == 'Debug' if: matrix.build_type == 'Debug'
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
files: build_${{matrix.build_type}}/coverage.xml
fail_ci_if_error: true fail_ci_if_error: true
verbose: true verbose: true

View File

@ -19,7 +19,12 @@ jobs:
- name: Setup Dependencies - name: Setup Dependencies
run: | run: |
brew install lcov ninja brew install ninja
- name: Setup Coverage Dependencies
if: matrix.build_type == 'Debug'
run: |
brew install gcovr
- name: Setup Environment - name: Setup Environment
if: matrix.build_type == 'Debug' if: matrix.build_type == 'Debug'
@ -29,12 +34,10 @@ jobs:
- name: Configure - name: Configure
shell: bash shell: bash
env: env:
CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}} CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror -pedantic-errors ${{env.CXXFLAGS}}
run: | run: |
cmake -S . -B build_${{matrix.build_type}} \ cmake -S . -B build_${{matrix.build_type}} \
-DCMAKE_CXX_EXTENSIONS=OFF \ -DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_CXX_FLAGS_DEBUG=-pedantic-errors \
-DCMAKE_CXX_FLAGS_RELEASE=-pedantic-errors \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \ -DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \ -DCMAKE_CXX_STANDARD_REQUIRED=ON \
-G "${{matrix.generator}}" \ -G "${{matrix.generator}}" \
@ -53,26 +56,21 @@ jobs:
- name: Generate Coverage - name: Generate Coverage
if: matrix.build_type == 'Debug' if: matrix.build_type == 'Debug'
run: | run: |
lcov --directory . --capture --output-file coverage.info cd build_${{matrix.build_type}}
lcov --remove coverage.info \ gcovr -r .. . -s --cobertura coverage.xml
'*/src/*_unittest.cc' \ cd ..
'*/src/googletest.h' \
'*/src/mock-log.h' \
'*/usr/*' \
--output-file coverage.info
for file in src/glog/*.h.in; do for file in src/glog/*.h.in; do
name=$(basename ${file}) name=$(basename ${file})
name_we=${name%.h.in} name_we=${name%.h.in}
sed -i "" "s|${{github.workspace}}/glog/${name_we}.h\$|${file}|g" coverage.info sed -i "" "s|build_${{matrix.build_type}}/glog/${name_we}.h|${file}|g" build_${{matrix.build_type}}/coverage.xml
done done
lcov --list coverage.info
- name: Upload Coverage to Codecov - name: Upload Coverage to Codecov
if: matrix.build_type == 'Debug' if: matrix.build_type == 'Debug'
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
files: build_${{matrix.build_type}}/coverage.xml
fail_ci_if_error: true fail_ci_if_error: true
verbose: true verbose: true

View File

@ -152,11 +152,19 @@ jobs:
with: with:
msystem: ${{matrix.sys}} msystem: ${{matrix.sys}}
install: >- install: >-
lcov
mingw-w64-${{matrix.env}}-cmake mingw-w64-${{matrix.env}}-cmake
mingw-w64-${{matrix.env}}-gcc mingw-w64-${{matrix.env}}-gcc
mingw-w64-${{matrix.env}}-gflags mingw-w64-${{matrix.env}}-gflags
mingw-w64-${{matrix.env}}-ninja mingw-w64-${{matrix.env}}-ninja
mingw-w64-${{matrix.env}}-python-jinja
mingw-w64-${{matrix.env}}-python-lxml
mingw-w64-${{matrix.env}}-python-pip
mingw-w64-${{matrix.env}}-python-pygments
- name: Setup Coverage Dependencies
if: matrix.build_type == 'Debug'
run: |
pip install 'gcovr==6.0'
- name: Setup Environment - name: Setup Environment
if: matrix.build_type == 'Debug' if: matrix.build_type == 'Debug'
@ -197,28 +205,21 @@ jobs:
- name: Generate Coverage - name: Generate Coverage
if: matrix.build_type == 'Debug' if: matrix.build_type == 'Debug'
run: | run: |
lcov --directory . --capture --output-file coverage.info cd build_${{matrix.build_type}}
lcov --remove coverage.info \ gcovr -r .. . -s --cobertura coverage.xml
'*/install/include/*' \ cd ..
'*/msys64/mingw32/*' \
'*/msys64/mingw64/*' \
'*/src/*_unittest.cc' \
'*/src/googletest.h' \
'*/src/mock-log.h' \
--output-file coverage.info
for file in src/glog/*.h.in; do for file in src/glog/*.h.in; do
name=$(basename ${file}) name=$(basename ${file})
name_we=${name%.h.in} name_we=${name%.h.in}
sed -i "s|build_${{matrix.build_type}}/glog/${name_we}.h\$|${file}|g" coverage.info sed -i "s|build_${{matrix.build_type}}/glog/${name_we}.h|${file}|g" build_${{matrix.build_type}}/coverage.xml
done done
lcov --list coverage.info
- name: Upload Coverage to Codecov - name: Upload Coverage to Codecov
if: matrix.build_type == 'Debug' if: matrix.build_type == 'Debug'
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
files: build_${{matrix.build_type}}/coverage.xml
fail_ci_if_error: true fail_ci_if_error: true
verbose: true verbose: true

4
codecov.yml Normal file
View File

@ -0,0 +1,4 @@
ignore:
- "**/*_unittest.cc"
- "src/googletest.h"
- "src/mock-log.h"

7
gcovr.cfg Normal file
View File

@ -0,0 +1,7 @@
exclude = src/.*_unittest\.cc
exclude = src/googletest\.h
exclude = src/mock-log\.h
exclude-throw-branches = yes
exclude-unreachable-branches = yes
filter = .*/glog/.*\.h
filter = src/