feat: add code coverage with branch coverage
All checks were successful
CI Code / Check spelling (pull_request) Successful in 21s
CI Code / Check coding style (pull_request) Successful in 35s
CI Code / Code Coverage (pull_request) Successful in 15m31s
CI Code / Linux (debian) (pull_request) Successful in 16m1s
CI Code / Linux (arch) (pull_request) Successful in 16m11s
CI Code / Linux (ubuntu) (pull_request) Successful in 18m24s
All checks were successful
CI Code / Check spelling (pull_request) Successful in 21s
CI Code / Check coding style (pull_request) Successful in 35s
CI Code / Code Coverage (pull_request) Successful in 15m31s
CI Code / Linux (debian) (pull_request) Successful in 16m1s
CI Code / Linux (arch) (pull_request) Successful in 16m11s
CI Code / Linux (ubuntu) (pull_request) Successful in 18m24s
- Add --enable-coverage configure option - Add lcov targets for generating coverage reports - Enable branch coverage (--rc branch_coverage=1) - Install lcov in all Docker images - Coverage report displayed via lcov --summary (no Codecov - doesn't work with Gitea)
This commit is contained in:
25
.github/workflows/ci-code.yml
vendored
25
.github/workflows/ci-code.yml
vendored
@@ -98,3 +98,28 @@ jobs:
|
|||||||
- name: Check spelling
|
- name: Check spelling
|
||||||
run: |
|
run: |
|
||||||
codespell
|
codespell
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Code Coverage
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Build and run coverage
|
||||||
|
run: |
|
||||||
|
docker build -f Dockerfile.debian -t profanity-cov .
|
||||||
|
docker run -v ${{ github.workspace }}/coverage:/coverage profanity-cov bash -c '
|
||||||
|
./bootstrap.sh
|
||||||
|
./configure --enable-coverage --enable-otr --enable-pgp --enable-omemo --enable-plugins
|
||||||
|
make -j$(nproc)
|
||||||
|
make check || true
|
||||||
|
make check-functional-parallel || true
|
||||||
|
lcov --capture --directory . --output-file /coverage/coverage.info \
|
||||||
|
--rc branch_coverage=1 \
|
||||||
|
--ignore-errors inconsistent
|
||||||
|
lcov --remove /coverage/coverage.info \
|
||||||
|
"/usr/include/*" "*/tests/*" \
|
||||||
|
--output-file /coverage/coverage.info \
|
||||||
|
--rc branch_coverage=1 \
|
||||||
|
--ignore-errors inconsistent,empty,unused
|
||||||
|
lcov --summary /coverage/coverage.info
|
||||||
|
'
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -107,3 +107,4 @@ breaks
|
|||||||
*.tar.*
|
*.tar.*
|
||||||
*.zip
|
*.zip
|
||||||
*.log*
|
*.log*
|
||||||
|
coverage/
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ RUN pacman -S --needed --noconfirm \
|
|||||||
check \
|
check \
|
||||||
cmake \
|
cmake \
|
||||||
cmocka \
|
cmocka \
|
||||||
|
lcov \
|
||||||
curl \
|
curl \
|
||||||
debuginfod \
|
debuginfod \
|
||||||
doxygen \
|
doxygen \
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
ccache \
|
ccache \
|
||||||
gcc \
|
gcc \
|
||||||
git \
|
git \
|
||||||
|
lcov \
|
||||||
libcmocka-dev \
|
libcmocka-dev \
|
||||||
libcurl3-dev \
|
libcurl3-dev \
|
||||||
libgcrypt-dev \
|
libgcrypt-dev \
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ RUN dnf install -y \
|
|||||||
ccache \
|
ccache \
|
||||||
gcc \
|
gcc \
|
||||||
git \
|
git \
|
||||||
|
lcov \
|
||||||
glib2-devel \
|
glib2-devel \
|
||||||
glibc-all-langpacks \
|
glibc-all-langpacks \
|
||||||
gtk2-devel \
|
gtk2-devel \
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ RUN zypper --non-interactive in --no-recommends \
|
|||||||
ccache \
|
ccache \
|
||||||
gcc \
|
gcc \
|
||||||
git \
|
git \
|
||||||
|
lcov \
|
||||||
glib2-devel \
|
glib2-devel \
|
||||||
glibc-locale \
|
glibc-locale \
|
||||||
gtk2-devel \
|
gtk2-devel \
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
ccache \
|
ccache \
|
||||||
gcc \
|
gcc \
|
||||||
git \
|
git \
|
||||||
|
lcov \
|
||||||
libcmocka-dev \
|
libcmocka-dev \
|
||||||
libcurl3-dev \
|
libcurl3-dev \
|
||||||
libgcrypt-dev \
|
libgcrypt-dev \
|
||||||
|
|||||||
14
Makefile.am
14
Makefile.am
@@ -386,6 +386,20 @@ check-unit: tests/unittests/unittests
|
|||||||
@VALGRIND_CHECK_RULES@
|
@VALGRIND_CHECK_RULES@
|
||||||
VALGRIND_SUPPRESSIONS_FILES=prof.supp
|
VALGRIND_SUPPRESSIONS_FILES=prof.supp
|
||||||
|
|
||||||
|
# Code coverage targets (requires --enable-coverage)
|
||||||
|
coverage-clean:
|
||||||
|
find . -name '*.gcda' -delete
|
||||||
|
find . -name '*.gcno' -delete
|
||||||
|
rm -rf coverage-html coverage.info
|
||||||
|
|
||||||
|
coverage-report: check
|
||||||
|
lcov --capture --directory . --output-file coverage.info --ignore-errors inconsistent
|
||||||
|
lcov --remove coverage.info '/usr/*' '*/tests/*' --output-file coverage.info --ignore-errors inconsistent
|
||||||
|
genhtml coverage.info --output-directory coverage-html
|
||||||
|
@echo "Coverage report generated in coverage-html/index.html"
|
||||||
|
|
||||||
|
.PHONY: coverage-clean coverage-report
|
||||||
|
|
||||||
format: $(all_c_sources)
|
format: $(all_c_sources)
|
||||||
clang-format -i $(all_c_sources)
|
clang-format -i $(all_c_sources)
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ AC_ARG_ENABLE([gdk-pixbuf],
|
|||||||
[AS_HELP_STRING([--enable-gdk-pixbuf], [enable GDK Pixbuf support to scale avatars before uploading])])
|
[AS_HELP_STRING([--enable-gdk-pixbuf], [enable GDK Pixbuf support to scale avatars before uploading])])
|
||||||
AC_ARG_ENABLE([omemo-qrcode],
|
AC_ARG_ENABLE([omemo-qrcode],
|
||||||
[AS_HELP_STRING([--enable-omemo-qrcode], [enable ability to display omemo qr code])])
|
[AS_HELP_STRING([--enable-omemo-qrcode], [enable ability to display omemo qr code])])
|
||||||
|
AC_ARG_ENABLE([coverage],
|
||||||
|
[AS_HELP_STRING([--enable-coverage], [enable code coverage analysis])])
|
||||||
|
|
||||||
m4_include([m4/ax_valgrind_check.m4])
|
m4_include([m4/ax_valgrind_check.m4])
|
||||||
AX_VALGRIND_DFLT([drd], [off])
|
AX_VALGRIND_DFLT([drd], [off])
|
||||||
@@ -386,6 +388,11 @@ AC_SUBST([FORKPTY_LIB])
|
|||||||
AM_CFLAGS="$AM_CFLAGS -Wall -Wno-deprecated-declarations -std=gnu99 -ggdb3"
|
AM_CFLAGS="$AM_CFLAGS -Wall -Wno-deprecated-declarations -std=gnu99 -ggdb3"
|
||||||
AM_LDFLAGS="$AM_LDFLAGS -export-dynamic"
|
AM_LDFLAGS="$AM_LDFLAGS -export-dynamic"
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_coverage" = xyes],
|
||||||
|
[AM_CFLAGS="$AM_CFLAGS --coverage -O0"
|
||||||
|
AM_LDFLAGS="$AM_LDFLAGS --coverage"
|
||||||
|
AC_MSG_NOTICE([Code coverage analysis enabled])])
|
||||||
|
|
||||||
AS_IF([test "x$PACKAGE_STATUS" = xdevelopment],
|
AS_IF([test "x$PACKAGE_STATUS" = xdevelopment],
|
||||||
[AM_CFLAGS="$AM_CFLAGS -Wunused -Werror"])
|
[AM_CFLAGS="$AM_CFLAGS -Wunused -Werror"])
|
||||||
AS_IF([test "x$PLATFORM" = xosx],
|
AS_IF([test "x$PLATFORM" = xosx],
|
||||||
|
|||||||
Reference in New Issue
Block a user