]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
ci: build coverage reports on Coveralls
authorEvgeny Vereshchagin <evvers@ya.ru>
Tue, 2 Nov 2021 15:18:19 +0000 (15:18 +0000)
committerEvgeny Vereshchagin <evvers@ya.ru>
Wed, 3 Nov 2021 02:29:02 +0000 (02:29 +0000)
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
.github/workflows/cibuild-setup-ubuntu.sh
.github/workflows/cibuild.sh
.github/workflows/cibuild.yml

index 12a28f2f4cf49584ab0961b2cfd70d209bde02d4..1ea51c542a9cf9edbc446aa3b2fd748cd35c223d 100755 (executable)
@@ -18,6 +18,7 @@ PACKAGES=(
        socat
        asciidoctor
        meson
+       lcov
 )
 
 PACKAGES_OPTIONAL=(
index 023ab6ed3f1d7360eb246985a95cabe76886501f..6d821b1c4375b70596aebc5b492a83a9fe06796a 100755 (executable)
@@ -5,6 +5,7 @@ COMPILER="${COMPILER:?}"
 COMPILER_VERSION="${COMPILER_VERSION}"
 CFLAGS=(-O1 -g)
 CXXFLAGS=(-O1 -g)
+LDFLAGS=()
 
 if [[ "$COMPILER" == clang ]]; then
     CC="clang${COMPILER_VERSION:+-$COMPILER_VERSION}"
@@ -27,6 +28,12 @@ for phase in "${PHASES[@]}"; do
             --enable-werror
         )
 
+        if [[ "$COVERAGE" == "yes" ]]; then
+            CFLAGS+=(--coverage)
+            CXXFLAGS+=(--coverage)
+            LDFLAGS+=(--coverage)
+        fi
+
         if [[ "$SANITIZE" == "yes" ]]; then
             opts+=(--enable-asan --enable-ubsan)
             CFLAGS+=(-fno-omit-frame-pointer)
@@ -42,7 +49,7 @@ for phase in "${PHASES[@]}"; do
         sudo -E git clean -xdf
 
         ./autogen.sh
-        CC="$CC" CXX="$CXX" CFLAGS="${CFLAGS[@]}" CXXFLAGS="${CXXFLAGS[@]}" ./configure "${opts[@]}"
+        CC="$CC" CXX="$CXX" CFLAGS="${CFLAGS[@]}" CXXFLAGS="${CXXFLAGS[@]}" LDFLAGS="${LDFLAGS[@]}" ./configure "${opts[@]}"
         ;;
     MAKE)
         make -j
@@ -89,6 +96,13 @@ for phase in "${PHASES[@]}"; do
         fi
 
         ./tests/run.sh --show-diff
+
+        if [[ "$COVERAGE" == "yes" ]]; then
+            lcov --directory . --capture --initial --output-file coverage.info.initial
+            lcov --directory . --capture --output-file coverage.info.run --no-checksum --rc lcov_branch_coverage=1
+            lcov -a coverage.info.initial -a coverage.info.run --rc lcov_branch_coverage=1 -o coverage.info.raw
+            lcov --extract coverage.info.raw "$(pwd)/*" --rc lcov_branch_coverage=1 --output-file coverage.info
+        fi
         ;;
     DISTCHECK)
         make distcheck
index 9db288f47edf018d02e435f1e3a78912519e60c0..811537cc8820d4c24f75fba1617d76da3812106b 100644 (file)
@@ -37,6 +37,28 @@ jobs:
         run: sudo -E .github/workflows/cibuild.sh CHECK
       - name: Make install
         run: .github/workflows/cibuild.sh INSTALL
+  coveralls:
+    runs-on: ubuntu-latest
+    if: github.repository == 'util-linux/util-linux'
+    env:
+      COMPILER: gcc
+      COMPILER_VERSION: 10
+      SANITIZE: no
+      COVERAGE: yes
+    steps:
+      - name: Repository checkout
+        uses: actions/checkout@v1
+      - name: Ubuntu setup
+        run: sudo -E .github/workflows/cibuild-setup-ubuntu.sh
+      - name: Configure & Make
+        run: .github/workflows/cibuild.sh CONFIGURE MAKE
+      - name: Check
+        run: sudo -E .github/workflows/cibuild.sh CHECK
+      - name: Coveralls
+        uses: coverallsapp/github-action@master
+        with:
+          github-token: ${{ secrets.GITHUB_TOKEN }}
+          path-to-lcov: ./coverage.info
   meson:
     needs: build
     runs-on: ubuntu-latest