ci: Collect code coverage in tests

This adds the necessary infrastructure to collect
code coverage in CI, which could be useful to look
at munually or track consistently via something like
codecov.

Co-authored-by: Jade Lovelace <lix@jade.fyi>
This commit is contained in:
Sergei Zimmerman
2025-08-04 23:50:02 +03:00
parent 0889960869
commit 4333a9d5a8
6 changed files with 200 additions and 34 deletions

View File

@@ -29,18 +29,21 @@ jobs:
- scenario: on ubuntu
runs-on: ubuntu-24.04
os: linux
sanitizers: false
instrumented: false
primary: true
stdenv: stdenv
- scenario: on macos
runs-on: macos-14
os: darwin
sanitizers: false
instrumented: false
primary: true
- scenario: on ubuntu (with sanitizers)
stdenv: stdenv
- scenario: on ubuntu (with sanitizers / coverage)
runs-on: ubuntu-24.04
os: linux
sanitizers: true
instrumented: true
primary: false
stdenv: clangStdenv
name: tests ${{ matrix.scenario }}
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 60
@@ -63,13 +66,28 @@ jobs:
if: matrix.os == 'linux'
- name: Run component tests
run: |
nix build --file ci/gha/tests componentTests -L \
--arg withSanitizers ${{ matrix.sanitizers }}
nix build --file ci/gha/tests/wrapper.nix componentTests -L \
--arg withInstrumentation ${{ matrix.instrumented }} \
--argstr stdenv "${{ matrix.stdenv }}"
- name: Run flake checks and prepare the installer tarball
run: |
ci/gha/tests/build-checks
ci/gha/tests/prepare-installer-for-github-actions
if: ${{ matrix.primary }}
- name: Collect code coverage
run: |
nix build --file ci/gha/tests/wrapper.nix codeCoverage.coverageReports -L \
--arg withInstrumentation ${{ matrix.instrumented }} \
--argstr stdenv "${{ matrix.stdenv }}" \
--out-link coverage-reports
cat coverage-reports/index.txt >> $GITHUB_STEP_SUMMARY
if: ${{ matrix.instrumented }}
- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: coverage-reports/
if: ${{ matrix.instrumented }}
- name: Upload installer tarball
uses: actions/upload-artifact@v4
with: