Fix coverage for C++ on github actions

This commit is contained in:
Alexey Sokolov
2021-07-03 20:26:03 +01:00
parent 315da8e104
commit 29142359cd
4 changed files with 43 additions and 28 deletions
+2 -1
View File
@@ -6,7 +6,8 @@ ignore:
- /modules/modpython/znc_core.py - /modules/modpython/znc_core.py
- /modules/modperl/ZNC.pm - /modules/modperl/ZNC.pm
fixes: 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: codecov:
ci: ci:
# Cygwin fails integration test with --coverage enabled, I don't know why # Cygwin fails integration test with --coverage enabled, I don't know why
+22 -26
View File
@@ -7,25 +7,17 @@ cpanm --local-lib=~/perl5 local::lib
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib) eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
cpanm --notest Devel::Cover::Report::Clover cpanm --notest Devel::Cover::Report::Clover
pip3 install --user coverage pip3 install --user coverage
export ZNC_MODPERL_COVERAGE=1" export ZNC_MODPERL_COVERAGE=1
export ZNC_MODPYTHON_COVERAGE=1" #export ZNC_MODPYTHON_COVERAGE=1
case "$RUNNER_OS" in case "${CC:-gcc}" in
Linux) gcc)
CXX_FOR_COV=$CXX export CXXFLAGS="$CXXFLAGS --coverage"
export LDFLAGS="$LDFLAGS --coverage"
;; ;;
macOS) clang)
CXX_FOR_COV=clang++ export CXXFLAGS="$CXXFLAGS -fprofile-instr-generate -fcoverage-mapping"
;; export LDFLAGS="$LDFLAGS -fprofile-instr-generate"
esac
case "$CXX_FOR_COV" in
g++)
CXXFLAGS+=" --coverage"
LDFLAGS+=" --coverage"
;;
clang++)
CXXFLAGS+=" -fprofile-instr-generate -fcoverage-mapping"
LDFLAGS+=" -fprofile-instr-generate"
;; ;;
esac esac
@@ -41,16 +33,20 @@ sudo make install
# TODO: use DEVEL_COVER_OPTIONS for https://metacpan.org/pod/Devel::Cover # 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 env LLVM_PROFILE_FILE="$PWD/inttest.profraw" ZNC_MODPERL_COVERAGE_OPTS="-db,$PWD/cover_db" PYTHONWARNINGS=error make VERBOSE=1 inttest
ls -lRa
case "$RUNNER_OS" in ~/perl5/bin/cover --no-gcov --report=clover
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) clang)
xcrun llvm-profdata merge unittest.profraw -o unittest.profdata llvm-profdata merge unittest.profraw -o unittest.profdata
xcrun llvm-profdata merge inttest.profraw -o inttest.profdata 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 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 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 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 esac
+2 -1
View File
@@ -1,3 +1,4 @@
sudo apt-get update 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
View File
@@ -15,6 +15,12 @@ jobs:
- run: source .github/ubuntu_deps.sh - run: source .github/ubuntu_deps.sh
- run: source .github/build.sh - run: source .github/build.sh
- uses: codecov/codecov-action@v1 - 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: tarball:
name: 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" 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 source $GITHUB_WORKSPACE/.github/build.sh
- uses: codecov/codecov-action@v1 - uses: codecov/codecov-action@v1
with:
name: ${{ github.job }}
# can be removed when asan below is fixed # can be removed when asan below is fixed
clang: clang:
@@ -38,6 +46,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
env: env:
CXX: clang++ CXX: clang++
CC: clang
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@@ -45,6 +54,12 @@ jobs:
- run: source .github/ubuntu_deps.sh - run: source .github/ubuntu_deps.sh
- run: source .github/build.sh - run: source .github/build.sh
- uses: codecov/codecov-action@v1 - 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: #clang_asan:
@@ -52,6 +67,7 @@ jobs:
#runs-on: ubuntu-20.04 #runs-on: ubuntu-20.04
#env: #env:
#CXX: clang++ #CXX: clang++
#CC: clang
#CXXFLAGS: "-fsanitize=address -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fPIE" #CXXFLAGS: "-fsanitize=address -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fPIE"
#LDFLAGS: "-fsanitize=address -pie" #LDFLAGS: "-fsanitize=address -pie"
#steps: #steps:
@@ -67,6 +83,7 @@ jobs:
#runs-on: ubuntu-20.04 #runs-on: ubuntu-20.04
#env: #env:
#CXX: clang++ #CXX: clang++
#CC: clang
#CXXFLAGS: "-fsanitize=thread -O1 -fPIE" #CXXFLAGS: "-fsanitize=thread -O1 -fPIE"
#LDFLAGS: "-fsanitize=thread" #LDFLAGS: "-fsanitize=thread"
#steps: #steps: