From f6e4d960e916be8f90e6504c341a18db44417783 Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Sat, 7 Oct 2023 02:29:58 +0200 Subject: [PATCH] ci: replace lcov by gcovr (#965) --- .github/workflows/linux.yml | 17 ++++++----------- .github/workflows/macos.yml | 26 ++++++++++++-------------- .github/workflows/windows.yml | 27 ++++++++++++++------------- codecov.yml | 4 ++++ gcovr.cfg | 7 +++++++ 5 files changed, 43 insertions(+), 38 deletions(-) create mode 100644 codecov.yml create mode 100644 gcovr.cfg diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index f0d74b1..210234b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -25,7 +25,7 @@ jobs: DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \ build-essential \ cmake \ - lcov \ + gcovr \ libgflags-dev \ libunwind-dev \ ninja-build @@ -117,27 +117,22 @@ jobs: - name: Generate Coverage if: matrix.build_type == 'Debug' run: | - lcov --directory . --capture --output-file coverage.info - lcov --remove coverage.info \ - '${{github.workspace}}/gtest/*' \ - '*/src/*_unittest.cc' \ - '*/src/googletest.h' \ - '*/src/mock-log.h' \ - '/usr/*' \ - --output-file coverage.info + cd build_${{matrix.build_type}} + gcovr -r .. . -s --xml coverage.xml + cd .. for file in src/glog/*.h.in; do name=$(basename ${file}) 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 - lcov --list coverage.info - name: Upload Coverage to Codecov if: matrix.build_type == 'Debug' uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} + files: build_${{matrix.build_type}}/coverage.xml fail_ci_if_error: true verbose: true diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 95b26a2..fa128b5 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -19,7 +19,12 @@ jobs: - name: Setup Dependencies run: | - brew install lcov ninja + brew install ninja + + - name: Setup Coverage Dependencies + if: matrix.build_type == 'Debug' + run: | + brew install gcovr - name: Setup Environment if: matrix.build_type == 'Debug' @@ -29,12 +34,10 @@ jobs: - name: Configure shell: bash 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: | cmake -S . -B build_${{matrix.build_type}} \ -DCMAKE_CXX_EXTENSIONS=OFF \ - -DCMAKE_CXX_FLAGS_DEBUG=-pedantic-errors \ - -DCMAKE_CXX_FLAGS_RELEASE=-pedantic-errors \ -DCMAKE_CXX_STANDARD=${{matrix.std}} \ -DCMAKE_CXX_STANDARD_REQUIRED=ON \ -G "${{matrix.generator}}" \ @@ -53,26 +56,21 @@ jobs: - name: Generate Coverage if: matrix.build_type == 'Debug' run: | - lcov --directory . --capture --output-file coverage.info - lcov --remove coverage.info \ - '*/src/*_unittest.cc' \ - '*/src/googletest.h' \ - '*/src/mock-log.h' \ - '*/usr/*' \ - --output-file coverage.info + cd build_${{matrix.build_type}} + gcovr -r .. . -s --cobertura coverage.xml + cd .. for file in src/glog/*.h.in; do name=$(basename ${file}) 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 - lcov --list coverage.info - - name: Upload Coverage to Codecov if: matrix.build_type == 'Debug' uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} + files: build_${{matrix.build_type}}/coverage.xml fail_ci_if_error: true verbose: true diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c3e7924..c029425 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -152,11 +152,19 @@ jobs: with: msystem: ${{matrix.sys}} install: >- - lcov mingw-w64-${{matrix.env}}-cmake mingw-w64-${{matrix.env}}-gcc mingw-w64-${{matrix.env}}-gflags 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 if: matrix.build_type == 'Debug' @@ -197,28 +205,21 @@ jobs: - name: Generate Coverage if: matrix.build_type == 'Debug' run: | - lcov --directory . --capture --output-file coverage.info - lcov --remove coverage.info \ - '*/install/include/*' \ - '*/msys64/mingw32/*' \ - '*/msys64/mingw64/*' \ - '*/src/*_unittest.cc' \ - '*/src/googletest.h' \ - '*/src/mock-log.h' \ - --output-file coverage.info + cd build_${{matrix.build_type}} + gcovr -r .. . -s --cobertura coverage.xml + cd .. for file in src/glog/*.h.in; do name=$(basename ${file}) 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 - lcov --list coverage.info - - name: Upload Coverage to Codecov if: matrix.build_type == 'Debug' uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} + files: build_${{matrix.build_type}}/coverage.xml fail_ci_if_error: true verbose: true diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..a0d37e2 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,4 @@ +ignore: + - "**/*_unittest.cc" + - "src/googletest.h" + - "src/mock-log.h" diff --git a/gcovr.cfg b/gcovr.cfg new file mode 100644 index 0000000..77c7324 --- /dev/null +++ b/gcovr.cfg @@ -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/