Browse Source

Fix coverage for C++ on github actions

pull/1798/head
Alexey Sokolov 1 year ago
parent
commit
29142359cd
  1. 3
      .codecov.yml
  2. 48
      .github/build.sh
  3. 3
      .github/ubuntu_deps.sh
  4. 17
      .github/workflows/build.yml

3
.codecov.yml

@ -6,7 +6,8 @@ ignore:
- /modules/modpython/znc_core.py
- /modules/modperl/ZNC.pm
fixes:
- "usr/local/lib/znc/::modules/" # C++ and Python seem to work without this, but Perl needs this.
- "usr/local/lib/znc/::modules/"
- "/usr/local/lib/znc/::modules/"
codecov:
ci:
# Cygwin fails integration test with --coverage enabled, I don't know why

48
.github/build.sh

@ -7,25 +7,17 @@ cpanm --local-lib=~/perl5 local::lib
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
cpanm --notest Devel::Cover::Report::Clover
pip3 install --user coverage
export ZNC_MODPERL_COVERAGE=1"
export ZNC_MODPYTHON_COVERAGE=1"
export ZNC_MODPERL_COVERAGE=1
#export ZNC_MODPYTHON_COVERAGE=1
case "$RUNNER_OS" in
Linux)
CXX_FOR_COV=$CXX
case "${CC:-gcc}" in
gcc)
export CXXFLAGS="$CXXFLAGS --coverage"
export LDFLAGS="$LDFLAGS --coverage"
;;
macOS)
CXX_FOR_COV=clang++
;;
esac
case "$CXX_FOR_COV" in
g++)
CXXFLAGS+=" --coverage"
LDFLAGS+=" --coverage"
;;
clang++)
CXXFLAGS+=" -fprofile-instr-generate -fcoverage-mapping"
LDFLAGS+=" -fprofile-instr-generate"
clang)
export CXXFLAGS="$CXXFLAGS -fprofile-instr-generate -fcoverage-mapping"
export LDFLAGS="$LDFLAGS -fprofile-instr-generate"
;;
esac
@ -41,16 +33,20 @@ sudo make install
# TODO: use DEVEL_COVER_OPTIONS for https://metacpan.org/pod/Devel::Cover
env LLVM_PROFILE_FILE="$PWD/inttest.profraw" ZNC_MODPERL_COVERAGE_OPTS="-db,$PWD/cover_db" PYTHONWARNINGS=error make VERBOSE=1 inttest
ls -lRa
~/perl5/bin/cover --no-gcov --report=clover
case "$RUNNER_OS" in
Linux)
~/perl5/bin/cover --no-gcov --report=clover
case "${CC:-gcc}" in
gcc)
lcov --directory . --capture --output-file lcov-coverage.txt
lcov --list lcov-coverage.txt
;;
macOS)
xcrun llvm-profdata merge unittest.profraw -o unittest.profdata
xcrun llvm-profdata merge inttest.profraw -o inttest.profdata
xcrun llvm-cov show -show-line-counts-or-regions -instr-profile=unittest.profdata test/unittest_bin > unittest-cmake-coverage.txt
xcrun llvm-cov show -show-line-counts-or-regions -instr-profile=inttest.profdata /usr/local/bin/znc > inttest-znc-coverage.txt
find /usr/local/lib/znc -name '*.so' -or -name '*.bundle' | while read f; do xcrun llvm-cov show -show-line-counts-or-regions -instr-profile=inttest.profdata $f > inttest-$(basename $f)-coverage.txt; done
clang)
llvm-profdata merge unittest.profraw -o unittest.profdata
llvm-profdata merge inttest.profraw -o inttest.profdata
llvm-cov show -show-line-counts-or-regions -instr-profile=unittest.profdata test/unittest_bin > unittest-cmake-coverage.txt
llvm-cov show -show-line-counts-or-regions -instr-profile=inttest.profdata /usr/local/bin/znc > inttest-znc-coverage.txt
find /usr/local/lib/znc -name '*.so' -or -name '*.bundle' | while read f; do llvm-cov show -show-line-counts-or-regions -instr-profile=inttest.profdata $f > inttest-$(basename $f)-coverage.txt; done
;;
esac

3
.github/ubuntu_deps.sh

@ -1,3 +1,4 @@
sudo apt-get update
sudo apt-get install -y tcl-dev libsasl2-dev libicu-dev swig qtbase5-dev libboost-locale-dev libperl-dev cpanminus gettext
sudo apt-get install -y tcl-dev libsasl2-dev libicu-dev swig qtbase5-dev libboost-locale-dev libperl-dev cpanminus gettext clang llvm lcov
sudo apt-get upgrade -y

17
.github/workflows/build.yml

@ -15,6 +15,12 @@ jobs:
- run: source .github/ubuntu_deps.sh
- run: source .github/build.sh
- uses: codecov/codecov-action@v1
with:
name: ${{ github.job }}
- uses: actions/upload-artifact@v2
with:
name: codecov debug results ${{ github.job }}
path: "/tmp/codecov.*.gz"
tarball:
name: Tarball
@ -31,6 +37,8 @@ jobs:
export CFGFLAGS="--with-gtest=$GITHUB_WORKSPACE/third_party/googletest/googletest --with-gmock=$GITHUB_WORKSPACE/third_party/googletest/googlemock --disable-swig"
source $GITHUB_WORKSPACE/.github/build.sh
- uses: codecov/codecov-action@v1
with:
name: ${{ github.job }}
# can be removed when asan below is fixed
clang:
@ -38,6 +46,7 @@ jobs:
runs-on: ubuntu-20.04
env:
CXX: clang++
CC: clang
steps:
- uses: actions/checkout@v2
with:
@ -45,6 +54,12 @@ jobs:
- run: source .github/ubuntu_deps.sh
- run: source .github/build.sh
- uses: codecov/codecov-action@v1
with:
name: ${{ github.job }}
- uses: actions/upload-artifact@v2
with:
name: codecov debug results ${{ github.job }}
path: "/tmp/codecov.*.gz"
#clang_asan:
@ -52,6 +67,7 @@ jobs:
#runs-on: ubuntu-20.04
#env:
#CXX: clang++
#CC: clang
#CXXFLAGS: "-fsanitize=address -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fPIE"
#LDFLAGS: "-fsanitize=address -pie"
#steps:
@ -67,6 +83,7 @@ jobs:
#runs-on: ubuntu-20.04
#env:
#CXX: clang++
#CC: clang
#CXXFLAGS: "-fsanitize=thread -O1 -fPIE"
#LDFLAGS: "-fsanitize=thread"
#steps:

Loading…
Cancel
Save