Skip to content

Commit

Permalink
ci: enable coverage in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHillion committed Oct 24, 2024
1 parent e784a16 commit 6a956b5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
34 changes: 33 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: CI
on:
push:
pull_request:
jobs:
lint:
Expand Down Expand Up @@ -27,7 +28,10 @@ jobs:
- name: build (LLVM ${{ matrix.llvm_version }})
# Run the build manually in `nix develop` to keep non-outputs around
run: |
nix develop .#oid-llvm${{ matrix.llvm_version }} --command cmake -B build -G Ninja -DWITH_FLAKY_TESTS=Off -DFORCE_BOOST_STATIC=Off
nix develop .#oid-llvm${{ matrix.llvm_version }} --command cmake -B build -G Ninja \
-DWITH_FLAKY_TESTS=Off \
-DFORCE_BOOST_STATIC=Off \
-DCODE_COVERAGE=On
nix develop .#oid-llvm${{ matrix.llvm_version }} --command ninja -C build
- name: test (LLVM ${{ matrix.llvm_version }})
env:
Expand All @@ -46,9 +50,37 @@ jobs:
--repeat until-pass:3 \
--exclude-from-file ../../.github/workflows/tests_failing_under_nix.txt \
--output-junit results.xml
- name: prepare coverage
run: |
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
# Empirically, extract-then-remove is faster than remove-then-extract
nix develop .#oid-llvm${{ matrix.llvm_version }} --command lcov --extract coverage.info '/tmp/object-introspection/*' --rc lcov_branch_coverage=1 --output-file coverage.info
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
nix develop .#oid-llvm${{ matrix.llvm_version }} --command lcov --list --rc lcov_branch_coverage=1 coverage.info
- name: upload coverage
continue-on-error: true
uses: coverallsapp/github-action@v2
with:
flag-name: run-${{ join(matrix.*, '-') }}
parallel: true

- name: upload results
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test-results-${{ matrix.llvm_version }}
path: build/test/results.xml

finalise-coverage:
needs: build-test
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: finalise coverage
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: "run-15,run-16"

4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
};

mkOidDevShell =
pkg: with pkgs; pkgs.mkShell { buildInputs = [ ] ++ pkg.nativeBuildInputs ++ pkg.buildInputs; };
pkg:
with pkgs;
pkgs.mkShell { buildInputs = [ lcov ] ++ pkg.nativeBuildInputs ++ pkg.buildInputs; };

pkgs = import nixpkgs { inherit system; };
in
Expand Down

0 comments on commit 6a956b5

Please sign in to comment.