Skip to content

Commit 6a956b5

Browse files
committed
ci: enable coverage in github actions
1 parent e784a16 commit 6a956b5

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: CI
22
on:
3+
push:
34
pull_request:
45
jobs:
56
lint:
@@ -27,7 +28,10 @@ jobs:
2728
- name: build (LLVM ${{ matrix.llvm_version }})
2829
# Run the build manually in `nix develop` to keep non-outputs around
2930
run: |
30-
nix develop .#oid-llvm${{ matrix.llvm_version }} --command cmake -B build -G Ninja -DWITH_FLAKY_TESTS=Off -DFORCE_BOOST_STATIC=Off
31+
nix develop .#oid-llvm${{ matrix.llvm_version }} --command cmake -B build -G Ninja \
32+
-DWITH_FLAKY_TESTS=Off \
33+
-DFORCE_BOOST_STATIC=Off \
34+
-DCODE_COVERAGE=On
3135
nix develop .#oid-llvm${{ matrix.llvm_version }} --command ninja -C build
3236
- name: test (LLVM ${{ matrix.llvm_version }})
3337
env:
@@ -46,9 +50,37 @@ jobs:
4650
--repeat until-pass:3 \
4751
--exclude-from-file ../../.github/workflows/tests_failing_under_nix.txt \
4852
--output-junit results.xml
53+
54+
- name: prepare coverage
55+
run: |
56+
nix develop .#oid-llvm${{ matrix.llvm_version }} --command lcov --capture --directory . --filter branch --no-external --ignore-errors mismatch --ignore-errors source --rc lcov_branch_coverage=1 --output-file coverage.info
57+
# Empirically, extract-then-remove is faster than remove-then-extract
58+
nix develop .#oid-llvm${{ matrix.llvm_version }} --command lcov --extract coverage.info '/tmp/object-introspection/*' --rc lcov_branch_coverage=1 --output-file coverage.info
59+
nix develop .#oid-llvm${{ matrix.llvm_version }} --command lcov --remove coverage.info '/tmp/object-introspection/build/*' '/tmp/object-introspection/extern/*' --rc lcov_branch_coverage=1 --output-file coverage.info
60+
nix develop .#oid-llvm${{ matrix.llvm_version }} --command lcov --list --rc lcov_branch_coverage=1 coverage.info
61+
62+
- name: upload coverage
63+
continue-on-error: true
64+
uses: coverallsapp/github-action@v2
65+
with:
66+
flag-name: run-${{ join(matrix.*, '-') }}
67+
parallel: true
68+
4969
- name: upload results
5070
uses: actions/upload-artifact@v4
5171
if: success() || failure()
5272
with:
5373
name: test-results-${{ matrix.llvm_version }}
5474
path: build/test/results.xml
75+
76+
finalise-coverage:
77+
needs: build-test
78+
if: ${{ always() }}
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: finalise coverage
82+
uses: coverallsapp/github-action@v2
83+
with:
84+
parallel-finished: true
85+
carryforward: "run-15,run-16"
86+

flake.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@
100100
};
101101

102102
mkOidDevShell =
103-
pkg: with pkgs; pkgs.mkShell { buildInputs = [ ] ++ pkg.nativeBuildInputs ++ pkg.buildInputs; };
103+
pkg:
104+
with pkgs;
105+
pkgs.mkShell { buildInputs = [ lcov ] ++ pkg.nativeBuildInputs ++ pkg.buildInputs; };
104106

105107
pkgs = import nixpkgs { inherit system; };
106108
in

0 commit comments

Comments
 (0)