Skip to content

Add code coverage

Add code coverage #7

Workflow file for this run

---
on:
pull_request:
name: Code coverage
permissions:
issues: write
pull-requests: write
jobs:
coverage-report:
name: Generate test coverage report
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
extra-experimental-features = nix-command flakes
accept-flake-config = true
- name: Fetch code coverage report
id: fetch-coverage
run: |
COVERAGE_PATH=$(nix build '.#coverage' --print-build-logs --print-out-paths --no-link)
echo "coverage-path=$COVERAGE_PATH" >> "$GITHUB_OUTPUT"
- name: Read coverage summary
id: coverage-summary
uses: juliangruber/read-file-action@v1
with:
path: ${{ steps.fetch-coverage.outputs.coverage-path }}/coverage-summary.txt
- name: Comment with coverage information
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
Code coverage:
```
${{ steps.coverage-summary.outputs.content }}
```
- uses: actions/upload-artifact@v3
with:
name: coverage-report
path: ${{ steps.fetch-coverage.outputs.coverage-path }}/coverage-report