OpenHuman Code Coverage Requirement: How 80% Diff Coverage is Enforced in CI
OpenHuman enforces a strict minimum 80% line-coverage requirement on all changed code through a dedicated Coverage Gate CI workflow that uses diff-cover to block pull requests falling below the threshold.
The OpenHuman repository maintains high code quality standards by requiring comprehensive test coverage for every contribution. According to the project's CI configuration and documentation, all pull requests must achieve at least 80% coverage on changed lines before they can be merged into the main branch. This requirement is enforced automatically through a multi-stage pipeline that aggregates coverage data from three distinct language stacks.
The 80% Diff Coverage Threshold
Unlike traditional repository-wide coverage metrics, OpenHuman employs a diff coverage strategy. This means the 80% requirement applies specifically to the lines of code modified in a pull request, not the entire codebase. The rule is implemented in the coverage-gate job defined in .github/workflows/coverage.yml.
When a developer opens a PR, the CI system generates coverage reports for the affected code and compares them against the base branch. If the calculated coverage on changed lines falls below 80%, the diff-cover tool exits with a failure status, preventing the merge.
How the Coverage Gate Works
The Coverage Gate workflow orchestrates three parallel jobs to collect coverage data across the project's heterogeneous stack, then aggregates them for final validation.
Frontend Coverage with Vitest
The TypeScript frontend stack executes pnpm test:coverage within the app/ directory. This command generates an lcov.info file containing JavaScript/TypeScript coverage data. Before aggregation, the workflow normalizes the paths in this file to ensure they align with the repository root structure, which is required for accurate comparison by diff-cover.
Rust Core and Tauri Shell
The project generates separate coverage reports for two Rust compilation units:
- Rust core: The workflow runs
cargo llvm-cov --no-fail-fast -p openhuman --lcov --output-path lcov-core.infoagainst the core crate - Tauri shell: It executes
cargo llvm-cov --manifest-path app/src-tauri/Cargo.toml --lcov --output-path lcov-tauri.infofor the desktop application shell
Both commands produce LCOV-compatible files that track line-by-line execution coverage for the Rust codebase.
The diff-cover Enforcement Step
The coverage-gate job downloads all three LCOV artifacts (lcov.info, lcov-core.info, and lcov-tauri.info) and feeds them into diff-cover for analysis. The critical enforcement command includes:
- name: Enforce ≥ 80% coverage on changed lines
run: |
set -euo pipefail
mapfile -t LCOV_FILES < <(find lcov-artifacts -type f -name '*.info' | sort)
diff-cover "${LCOV_FILES[@]}" \
--compare-branch="origin/${{ github.base_ref }}" \
--fail-under=80 \
--html-report diff-coverage.html \
--markdown-report diff-coverage.md
The --fail-under=80 flag institutes the hard minimum. If the coverage percentage on changed lines is 79% or lower, the job fails immediately and blocks the PR from merging. The workflow also generates HTML and markdown reports as downloadable artifacts for debugging.
Where Requirements Are Documented
The 80% coverage requirement is codified in multiple locations to ensure visibility for contributors.
Workflow Configuration
The authoritative implementation resides in .github/workflows/coverage.yml, which defines the coverage-gate job and its dependencies on the three coverage generation steps.
Project Documentation
The AGENTS.md file explicitly states the policy: "PRs need ≥ 80% coverage on changed lines via diff-cover", providing human-readable context for the enforcement mechanism.
Pull Request Template
The .github/PULL_REQUEST_TEMPLATE.md includes a checklist item reminding authors to verify "Diff coverage ≥ 80%" before requesting review, ensuring the requirement remains top-of-mind during the development process.
Running Coverage Checks Locally
Developers can verify coverage compliance before submitting a PR by generating the required LCOV files locally:
# Frontend (Vitest) - generates app/coverage/lcov.info
pnpm test:coverage
# Rust core - generates lcov-core.info
cargo llvm-cov --no-fail-fast -p openhuman --lcov --output-path lcov-core.info
# Tauri shell - generates lcov-tauri.info
cargo llvm-cov --manifest-path app/src-tauri/Cargo.toml --lcov --output-path lcov-tauri.info
After generating these files, run diff-cover locally against your feature branch to verify you meet the 80% threshold before pushing.
Summary
- OpenHuman requires ≥ 80% line coverage on all changed code in every pull request.
- The Coverage Gate workflow in
.github/workflows/coverage.ymlaggregates reports from Vitest (frontend) andcargo llvm-cov(Rust core and Tauri). diff-covercomputes coverage only on modified lines and enforces the threshold via--fail-under=80.- Failures appear in the GitHub Checks UI and block merging until coverage is improved.
- Requirements are documented in the workflow file,
AGENTS.md, and the pull request template.
Frequently Asked Questions
What is the exact code coverage requirement in OpenHuman?
The project mandates a minimum of 80% line coverage specifically on changed lines for every pull request. This diff-coverage approach ensures new code is tested without requiring the entire repository to meet the threshold.
How does the CI system enforce the coverage requirement?
The CI pipeline uses a coverage-gate job that runs diff-cover against three LCOV files generated by Vitest and cargo llvm-cov. The command includes --fail-under=80, which causes the job to fail if changed lines lack sufficient coverage, blocking the merge via GitHub branch protection rules.
Can developers run coverage checks locally before submitting a PR?
Yes. Developers can generate the required LCOV files using pnpm test:coverage for the frontend and cargo llvm-cov commands for the Rust components. Running diff-cover locally with these files allows verification of the 80% threshold before creating a pull request.
What happens if my pull request fails the Coverage Gate?
The GitHub Checks UI will display a failure status for the coverage-gate job, preventing merge until the issue is resolved. You must either add tests to increase coverage on your changed lines to at least 80% or reduce the scope of changes to meet the requirement.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →