]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
ci: add code coverage via Codecov
authorEmil Velikov <emil.l.velikov@gmail.com>
Tue, 5 Nov 2024 15:07:34 +0000 (15:07 +0000)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 8 Nov 2024 17:51:52 +0000 (11:51 -0600)
Add a simple code coverage pipeline based on the CodeQL one.

Should give us pretty reports in the PRs and web UI with the results. We
can consider having HTML reports on our website (once it's up that is)
in addition or instead of at a future point.

Closes: https://github.com/kmod-project/kmod/issues/61
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/229
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
.github/actions/setup-ubuntu/action.yml
.github/workflows/coverage.yml [new file with mode: 0644]

index 1bc2a2808bb2adc67f863f932180f70cafebfba0..810fc32fb2bfaca09488f2c0eebee23f86e1733f 100644 (file)
@@ -20,6 +20,7 @@ runs:
           build-essential \
           clang \
           gcc-multilib \
+          gcovr \
           git \
           gtk-doc-tools \
           liblzma-dev \
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
new file mode 100644 (file)
index 0000000..0575a45
--- /dev/null
@@ -0,0 +1,65 @@
+# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
+# SPDX-FileCopyrightText: 2024 Lucas De Marchi <lucas.de.marchi@gmail.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+name: Code Coverage
+
+on:
+  push:
+    branches: [master, ci-test]
+  pull_request:
+    branches: [master]
+  schedule:
+    - cron: "30 2 * * 0"
+
+permissions:
+  contents: read
+
+jobs:
+  analyze:
+    name: Analyze
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        container:
+          - name: 'ubuntu:24.04'
+            meson_setup: '-D b_sanitize=none -D b_coverage=true'
+
+    container:
+      image: ${{ matrix.container.name }}
+
+    steps:
+      - name: Sparse checkout the local actions
+        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
+        with:
+          sparse-checkout: .github
+
+      - uses: ./.github/actions/setup-ubuntu
+        if: ${{ startsWith(matrix.container.name, 'ubuntu') }}
+
+      - name: Checkout the whole project
+        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
+
+      - name: Set the environment
+        run: |
+          # The second checkout above claims to set safe.directory, yet it
+          # doesn't quite work. Perhaps our double/sparse checkout is to blame?
+          git config --global --add safe.directory '*'
+
+          .github/print-kdir.sh >> "$GITHUB_ENV"
+
+      - name: Build
+        run: |
+          mkdir build && cd build
+          meson setup --native-file ../build-dev.ini ${{ matrix.container.meson_setup }} . ..
+          meson compile
+          meson test
+          ninja coverage-xml
+
+      - name: Upload Coverage
+        uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
+          file: build/meson-logs/coverage.xml