cesr-rs 0.4.0

CESR + KERI primitives for Rust as a single feature-gated, no_std-capable crate
Documentation
name: Coverage

# Runs AFTER a PR merges (push to main) — not on PRs, since coverage
# instrumentation recompiles the whole crate and would slow the gate.
# Produces the browsable llvm-cov HTML report as an artifact (and a GitHub
# Pages deploy) so coverage of `main` is visible after every merge.
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` so the report can be published to the `gh-pages`
      # branch (deployed to GitHub Pages).
      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

      # `.#coverage` is the llvm-cov engine (crane's `cargoLlvmCov`, wired in
      # flake.nix `packages`), instrumented with `--all-features` so every
      # feature-gated module (`b64`, `core`, `crypto`, `stream`, `keri`,
      # `serder`) is built and its tests run. `-L` streams full logs.
      - name: Build coverage report
        run: nix build .#coverage -L

      # Normalise llvm-cov's `result/html/` out of the read-only nix store.
      - 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

      # Publish to the `gh-pages` branch under /coverage/ for a stable browsable
      # URL. `keep_files: true` + `destination_dir: coverage` so it owns ONLY
      # the /coverage/ subtree.
      - 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"