test-verdict
v0.6.0
Published
Universal test & code coverage PR decorator and merge gate supporting JaCoCo, Cobertura, LCOV, Istanbul/Jest, Go, and OpenCover.
Maintainers
Readme
Test Verdict
Universal test & code coverage PR decorator and merge gate - available as a GitHub Action, an Azure Pipelines task, and a standalone CLI tool.
test-verdict auto-detects and aggregates coverage reports across many languages, evaluates test coverage thresholds, comments on your PR and can enforce merge gates, blocking PRs until coverage thresholds are met. Use it directly in GitHub Actions workflows, in Azure Pipelines via the native TestVerdict task, or standalone via npx test-verdict.
Interactive setup and configuration guide: steveswinsburg.github.io/test-verdict.
Features
- Format-agnostic auto-detection - parses and merges multiple reports across languages in a single pass.
- Overall & PR diff coverage - gates both total coverage and changed lines in the pull request.
- Sticky PR comment & Job Step Summary - updates a single PR comment in place, with a full breakdown in the workflow summary.
- Branch-protection ready - fails the check on threshold breaches when
enforce: trueso PRs cannot merge until passing. - Fork-PR safe - gracefully degrades to Job Step Summary + exit-code gating if Github token permissions don't allow commenting.
- Azure Pipelines task - native
TestVerdictextension task with sticky Azure DevOps PR comments, Build Summary upload, and output variables. - Standalone CLI tool - zero-dependency CLI you can run locally, in pre-push hooks, or in any CI provider via
npx test-verdict.
Example PR Comment
Test Verdict - ✅ Passed
| Suite | Lines | Branches | Functions | PR Diff | Status | | :--- | ---: | ---: | ---: | ---: | :---: | | Overall | 91.1% (1552/1703) | 70.4% (386/548) | 96.2% (75/78) | 94.4% (34/36) | ✅ Pass |
By default, GitHub attributes PR comments posted with GITHUB_TOKEN to github-actions Bot. See CUSTOM_BOT.md if you want comments posted under a custom bot name and avatar (such as test-verdict Bot).
Supported Formats
| Format | Ecosystems / Tools |
| :--- | :--- |
| LCOV (.info) | JS/TS (Vitest, Jest, c8, Istanbul), Rust (llvm-cov, tarpaulin), Flutter/Dart, C/C++, Ruby, PHP |
| Cobertura XML | Python (pytest-cov, coverage.py), .NET (coverlet), Go (gocover-cobertura), Ruby, PHP |
| JaCoCo XML | Java, Kotlin, Scala, Groovy (Maven & Gradle) |
| Istanbul / Jest JSON | JS/TS (coverage-final.json, coverage-summary.json) |
| Go coverprofile | Go (go test -coverprofile=coverage.out) |
| OpenCover XML | .NET (OpenCover, AltCover) |
See EXAMPLES.md for full recipes covering every report format, GitHub Actions, Azure Pipelines, parameter combinations, and standalone CLI usage.
Quickstart
GitHub Actions
name: Coverage Gate
on:
pull_request:
permissions:
contents: read
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- run: npm test -- --coverage
- uses: steveswinsburg/test-verdict@v0
with:
files: |
**/jacocoTestReport.xml
coverage/lcov.info
coverage.xml
min-line: 80
min-diff-line: 90Enforcing Merge Gates
Set enforce: true (the default) and mark the workflow job as a required status check in your repository's Branch Protection / Rulesets. Any threshold violation fails the check and blocks the PR merge.
Azure Pipelines
trigger:
- main
pr:
- main
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
fetchDepth: 0
# Run your test & coverage command (e.g. ./gradlew test jacocoTestReport, dotnet test, or npm test -- --coverage)
- task: TestVerdict@0
inputs:
files: |
**/jacocoTestReport.xml
coverage/lcov.info
TestResults/**/coverage.cobertura.xml
minLine: '80'
minDiffLine: '90'See AZURE_PIPELINES.md for Java, .NET, and Node.js quickstarts, task inputs, output variables, Build Service permissions, and Branch Policy setup, or EXAMPLES.md for the full set of Azure Pipelines recipes.
Standalone CLI
npx test-verdict \
--files coverage/lcov.info \
--files "**/jacocoTestReport.xml" \
--min-line 80 \
--min-diff-line 90 \
--diff-base origin/mainSee Standalone CLI below for installation and all CLI flags, or EXAMPLES.md for format-specific commands.
Security Hardening
For locked-down organization or reusable workflows:
- Isolate
pull-requests: writeand avoid persisted credentials: Putpull-requests: writeonly on a separate publish job that downloads the coverage artifact, sonpm ci/yarn installlifecycle scripts, lint, and tests only holdcontents: read. Also passpersist-credentials: falsetoactions/checkoutso git credentials are not left on disk. LCOV, Istanbul, and Cobertura work in the publish job without a checkout, whereas JaCoCo package-path resolution benefits from apersist-credentials: falsecheckout. - Guard against missing reports after early failures: Add
if: ${{ !cancelled() && hashFiles('coverage/lcov.info') != '' }}when running Test Verdict after test or build steps that might fail before writing a report, so CI does not add a second noisy red step. - Ignore repo-committed config: Pass
config: noneso a pull request cannot commit.test-verdict.ymlto exclude files or override workflow thresholds. - Count brand-new untested files in PR diff: Pass
include:globs (for examplesrc/**/*.ts) and/or enablecoverage.all: truein your test runner so newly added files absent from the report count as0%diff coverage instead of0/0. - Pin by commit SHA: Pin
steveswinsburg/test-verdict@<full-commit-sha>in high-security pipelines.
Monorepo Coverage Groups
Create an optional .test-verdict.yml at the repository root to evaluate multiple suites or packages with independent thresholds in one step:
title: Monorepo Coverage
exclude:
- "**/*.generated.*"
- "**/__tests__/**"
thresholds:
min-line: 80
min-diff-line: 85
groups:
- name: backend-java
files:
- "services/api/**/jacocoTestReport.xml"
thresholds:
min-line: 85
min-branch: 75
- name: frontend-web
files:
- "apps/web/coverage/lcov.info"
thresholds:
min-line: 80Action Inputs
| Input | Default | Description |
| :--- | :--- | :--- |
| files | - | Newline or comma-separated coverage report globs |
| format | auto | auto | lcov | cobertura | jacoco | istanbul | gocover | opencover |
| config | .test-verdict.yml | Path to optional YAML config file, or none / false to disable |
| include | - | Newline or comma-separated source path inclusion globs (missing diff files count as 0%) |
| exclude | - | Newline or comma-separated source path exclusion globs |
| report-id | default | Identifier for sticky PR comments across multiple steps |
| title | Test Verdict | Heading for PR comments and step summaries |
| min-line | - | Minimum overall line coverage % (0–100) |
| min-branch | - | Minimum overall branch coverage % (0–100) |
| min-function | - | Minimum overall function coverage % (0–100) |
| min-diff-line | - | Minimum PR changed-lines coverage % (0–100) |
| min-diff-branch | - | Minimum PR changed-lines branch coverage % (0–100) |
| enforce | true | Fail the check when thresholds are breached |
| fail-on-empty | true | Fail if no coverage files match or parsed reports contain no measured files |
| comment | true | Post or update sticky PR comment |
| step-summary | true | Write Job Step Summary |
| github-token | ${{ github.token }} | Token used for PR diff and comments |
| working-directory | . | Working directory |
Action Outputs
| Output | Description |
| :--- | :--- |
| line-coverage | Overall line coverage percentage |
| branch-coverage | Overall branch coverage percentage |
| function-coverage | Overall function coverage percentage |
| diff-coverage | PR diff line coverage percentage |
| passed | "true" or "false" |
| summary-json | JSON payload summarizing all groups, metrics, violations, and warnings |
Standalone CLI
Global install:
npm install -g test-verdictOr run without installing via npx:
npx test-verdict --files coverage/lcov.info --min-line 80
npx test-verdict --files coverage/lcov.info --min-line 80 --diff-base origin/main --markdown| Option | Description |
| :--- | :--- |
| -f, --files <glob> | Coverage report glob pattern (repeatable) |
| --format <fmt> | auto | lcov | cobertura | jacoco | istanbul | gocover | opencover |
| -c, --config <path> | Path to .test-verdict.yml (or none / false to disable) |
| --no-config | Disable auto-loading .test-verdict.yml |
| --include <glob> | Source file glob to include (repeatable; missing diff files count as 0%) |
| -e, --exclude <glob> | Source file glob to exclude (repeatable) |
| --report-id <id> | Sticky comment report ID (default: "default") |
| --title <text> | Report title (default: "Test Verdict") |
| --min-line <pct> | Minimum overall line coverage % (0–100) |
| --min-branch <pct> | Minimum overall branch coverage % (0–100) |
| --min-function <pct> | Minimum overall function coverage % (0–100) |
| --min-diff-line <pct> | Minimum PR/git diff line coverage % (0–100) |
| --min-diff-branch <pct> | Minimum PR/git diff branch coverage % (0–100) |
| --diff-base <ref> | Git ref to diff against (e.g. origin/main, HEAD~1) |
| --working-dir <dir> | Working directory (default: .) |
| --enforce / --no-enforce | Exit non-zero on threshold breach (default: true) |
| --fail-on-empty / --no-fail-on-empty | Fail when no reports match or contain no measured files (default: true) |
| --markdown | Print Markdown report to stdout |
| --json | Print JSON summary to stdout |
| -h, --help | Show help message |
| -v, --version | Show version |
Development
npm ci
npm run typecheck
npm run test:coverage
npm run build
npm run package:azure # package Azure Pipelines .vsix into dist/Releasing a New Version
npm version patch --no-git-tag-version # or minor / major
npm run build
git add package.json package-lock.json dist/ azure-pipelines/vss-extension.json azure-pipelines/task/task.json
git commit -m "chore: release v$(node -p "require('./package.json').version")"
git push origin mainOn push to main:
.github/workflows/ci.ymlruns typecheck, tests, coverage,dist/+ Azure extension manifest verification, and dogfoods Test Verdict (both the GitHub Action and standalone CLI)..github/workflows/release.ymlautomatically:- Publishes the new version to npmjs via Trusted Publishing (OIDC) if not already published.
- Creates the
v<version>GitHub Release with auto-generated release notes. - Updates the floating major tag (e.g.
v0forv0.x.x,v1forv1.x.x) for GitHub Action consumers. - Packages the Azure Pipelines
.vsixand attaches it to the GitHub Release for manual upload to the Visual Studio Marketplace.
To list a release on GitHub Actions Marketplace, edit the created GitHub Release and check Publish this Action to the GitHub Marketplace.
Contributing a New Format Parser
- Implement
CoverageParserinsrc/parsers/<format>.ts(id,canParse(filePath, snippet),parse(content, sourceFile)). - Register the parser in
createDefaultParserRegistry()insidesrc/parsers/registry.ts. - Add realistic fixture files under
tests/fixtures/and unit tests undertests/parsers/.
Made with ❤️ for better code everywhere.
