name: Coverage
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: coverage-${{ github.ref }}
cancel-in-progress: true
jobs:
coverage:
name: llvm-cov HTML report
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Nix
uses: nixbuild/nix-quick-install-action@v30
with:
nix_conf: |
experimental-features = nix-command flakes
accept-flake-config = true
keep-env-derivations = true
keep-outputs = true
- name: Restore and save Nix store
uses: nix-community/cache-nix-action@v6
with:
primary-key: nix-cov-${{ runner.os }}-${{ hashFiles('Cargo.toml', 'flake.nix', 'flake.lock', 'Cargo.lock') }}
restore-prefixes-first-match: nix-cov-${{ runner.os }}-
gc-max-store-size-linux: 1G
purge: true
purge-prefixes: nix-cov-${{ runner.os }}-
purge-created: 0
purge-primary-key: never
- name: Build coverage report
run: nix build .#coverage -L
- name: Stage HTML out of the read-only nix store
run: |
rm -rf coverage-html && mkdir coverage-html
if [ -d result/html ]; then
cp -rL result/html/. coverage-html/
else
cp -rL result/. coverage-html/
fi
chmod -R u+w coverage-html
- name: Upload HTML coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: coverage-html
if-no-files-found: error
- name: Deploy to GitHub Pages (/coverage/)
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: coverage-html
destination_dir: coverage
keep_files: true
user_name: github-actions[bot]
user_email: github-actions[bot]@users.noreply.github.com
commit_message: "coverage for ${{ github.sha }}"
- name: Job summary
run: |
{
echo "## Coverage for \`main\` @ ${GITHUB_SHA:0:7}"
echo ""
echo "Browsable report: https://${GITHUB_REPOSITORY_OWNER}.github.io/${GITHUB_REPOSITORY#*/}/coverage/"
echo "(also the **coverage-html** artifact on this run)."
} >> "$GITHUB_STEP_SUMMARY"