Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Code Coverage

on:
pull_request:
branches: [main]

push:
branches: [main]

workflow_dispatch:

permissions:
contents: read
pull-requests: write

defaults:
run:
shell: bash

jobs:
coverage:
name: Generate code coverage with cargo-llvm-cov
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

Comment thread
vmarcella marked this conversation as resolved.
- name: Cache cargo builds
uses: Swatinem/rust-cache@v2

- name: Install Rust toolchain with llvm-tools-preview
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Install Linux deps for winit/wgpu
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config libx11-dev libxcb1-dev libxcb-render0-dev \
libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev \
libwayland-dev libudev-dev \
libvulkan-dev libvulkan1 mesa-vulkan-drivers vulkan-tools

- name: Install Linux deps for audio
run: |
sudo apt-get install -y libasound2-dev
Comment thread
vmarcella marked this conversation as resolved.

- name: Configure Vulkan (Ubuntu)
run: |
echo "WGPU_BACKEND=vulkan" >> "$GITHUB_ENV"
# Prefer Mesa's software Vulkan (lavapipe) for headless availability
Comment thread
vmarcella marked this conversation as resolved.
echo "VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json" >> "$GITHUB_ENV"
vulkaninfo --summary || true

- name: Generate coverage JSON (summary only)
run: |
cargo llvm-cov --workspace \
--features lambda-rs/with-vulkan,lambda-rs/audio-output-device \
--json --summary-only \
--output-path coverage.json

- name: Extract total line coverage percentage
id: cov
run: |
pct=$(jq -r '(.data[0].totals.lines.percent // 0)' coverage.json)
covered=$(jq -r '(.data[0].totals.lines.covered // 0)' coverage.json)
total=$(jq -r '(.data[0].totals.lines.count // 0)' coverage.json)
echo "pct=$pct" >> "$GITHUB_OUTPUT"
echo "covered=$covered" >> "$GITHUB_OUTPUT"
echo "total=$total" >> "$GITHUB_OUTPUT"

- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const pct = `${{ steps.cov.outputs.pct }}`;
const covered = `${{ steps.cov.outputs.covered }}`;
const total = `${{ steps.cov.outputs.total }}`;

const body = [
'### ✅ Coverage Report',
'',
'| Metric | Value |',
'|--------|-------|',
`| **Total Line Coverage** | ${pct}% |`,
`| **Lines Covered** | ${covered} / ${total} |`,
'',
'*Generated by [cargo-llvm-cov](https://github.com/taiki-e/cargo-llvm-cov)*'
].join('\n');

const { owner, repo } = context.repo;
const issue_number = context.issue.number;
await github.rest.issues.createComment({ owner, repo, issue_number, body });
Comment thread
vmarcella marked this conversation as resolved.
Outdated

- name: Upload coverage JSON as artifact
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.json
retention-days: 30
Loading