Other Commands
This page covers additional coverctl commands for badges, trends, and coverage analysis.
pr-comment
Section titled “pr-comment”Post coverage reports as comments on GitHub, GitLab, or Bitbucket pull requests/merge requests.
coverctl pr-comment [flags]| Flag | Description | Default |
|---|---|---|
-c, --config | Config file path | .coverctl.yaml |
-p, --profile | Coverage profile path | .cover/coverage.out |
--base-profile | Base coverage profile for comparison | |
--provider | Git provider: github, gitlab, bitbucket, auto | auto |
--pr | PR/MR number | auto-detected |
--owner | Repository owner/namespace | auto-detected |
--repo | Repository name | auto-detected |
--update | Update existing comment instead of creating new | true |
--dry-run | Generate comment without posting | false |
Provider Auto-Detection
Section titled “Provider Auto-Detection”The provider is automatically detected from environment variables:
| Provider | Environment Variables |
|---|---|
| GitHub | GITHUB_TOKEN, GITHUB_REPOSITORY |
| GitLab | GITLAB_TOKEN, CI_JOB_TOKEN, CI_MERGE_REQUEST_IID |
| Bitbucket | BITBUCKET_TOKEN, BITBUCKET_WORKSPACE, BITBUCKET_REPO_SLUG |
Examples
Section titled “Examples”# GitHub Actions (auto-detects everything)coverctl pr-comment --pr ${{ github.event.pull_request.number }}
# GitLab CI (MR number auto-detected from CI_MERGE_REQUEST_IID)coverctl pr-comment
# Bitbucket Pipelines (PR number auto-detected from BITBUCKET_PR_ID)coverctl pr-comment
# With coverage comparison to base branchcoverctl pr-comment --pr 123 --base-profile main-coverage.out
# Explicit providercoverctl pr-comment --provider gitlab --pr 42
# Preview comment without postingcoverctl pr-comment --pr 123 --dry-runComment Format
Section titled “Comment Format”The generated comment includes:
- Overall coverage percentage and change
- Domain-level coverage breakdown with status indicators
- List of changed files with coverage deltas (when base profile provided)
- Pass/fail status based on configured thresholds
compare
Section titled “compare”Compare coverage between two profiles to show improvements and regressions.
coverctl compare [flags]| Flag | Description | Default |
|---|---|---|
-c, --config | Config file path | .coverctl.yaml |
--base | Base coverage profile (required) | |
--head | Head coverage profile | .cover/coverage.out |
-o, --output | Output format: text, json | text |
Examples
Section titled “Examples”# Compare main branch to currentcoverctl compare --base main-coverage.out --head coverage.out
# Compare two saved profilescoverctl compare --base v1.0.out --head v2.0.out
# JSON output for CI parsingcoverctl compare --base main.out -o jsonOutput
Section titled “Output”Coverage Comparison───────────────────Base: 78.5%Head: 82.1%Delta: +3.6%
Improved Files (5): internal/core/validator.go 65.2% → 85.4% (+20.2%) internal/api/handler.go 72.1% → 78.3% (+6.2%) ...
Regressed Files (1): internal/cli/format.go 90.0% → 87.5% (-2.5%)Generate an SVG coverage badge for your README.
coverctl badge [flags]| Flag | Description | Default |
|---|---|---|
-c, --config | Config file path | .coverctl.yaml |
-p, --profile | Coverage profile path | .cover/coverage.out |
-o, --output | Output file path | coverage.svg |
--label | Badge label text | coverage |
--style | Badge style: flat, flat-square | flat |
Examples
Section titled “Examples”# Generate default badgecoverctl badge
# Custom style and labelcoverctl badge --style flat-square --label "test coverage"
# Custom output pathcoverctl badge -o docs/badge.svgShow coverage trends over time using recorded history.
coverctl trend [flags]| Flag | Description | Default |
|---|---|---|
-c, --config | Config file path | .coverctl.yaml |
-p, --profile | Coverage profile path | .cover/coverage.out |
--history | History file path | .cover/history.json |
-o, --output | Output format: text, json | text |
Example
Section titled “Example”# Show coverage trendcoverctl trend
# JSON outputcoverctl trend -o jsonOutput
Section titled “Output”Coverage Trend (last 10 entries)────────────────────────────────Date Commit Coverage Change2024-12-23 abc1234 82.1% +0.5%2024-12-22 def5678 81.6% +1.2%2024-12-21 ghi9012 80.4% -0.3%...record
Section titled “record”Record current coverage to history for trend analysis.
coverctl record [flags]Note: Prefer profiles produced by coverctl run or coverctl check so the history reflects the same -coverpkg instrumentation that policy checks use.
When using --run, pass test selection via --test-run (or --test-arg=-run=...) since --run is reserved to trigger coverage execution.
| Flag | Description | Default |
|---|---|---|
-c, --config | Config file path | .coverctl.yaml |
-p, --profile | Coverage profile path | .cover/coverage.out |
--history | History file path | .cover/history.json |
--commit | Git commit SHA | auto-detected |
--branch | Git branch name | auto-detected |
--run | Run coverage before recording history | false |
-l, --language | Override language detection | auto |
-d, --domain | Filter to specific domain (repeatable) | all domains |
--tags | Build tags (e.g., integration,e2e) | |
--race | Enable race detector | false |
--short | Skip long-running tests | false |
-v | Verbose test output | false |
--test-run | Run only tests matching pattern | |
--timeout | Test timeout (e.g., 10m, 1h) | |
--test-arg | Additional go test argument (repeatable) |
Examples
Section titled “Examples”# Record with auto-detected git infocoverctl record
# Explicit commit and branchcoverctl record --commit abc1234 --branch main
# Run coverage before recording historycoverctl record --run --tags integrationCI Integration
Section titled “CI Integration”- name: Record coverage run: | coverctl check coverctl record --commit ${{ github.sha }} --branch ${{ github.ref_name }}suggest
Section titled “suggest”Suggest optimal coverage thresholds based on current coverage.
coverctl suggest [flags]| Flag | Description | Default |
|---|---|---|
-c, --config | Config file path | .coverctl.yaml |
-p, --profile | Coverage profile path | .cover/coverage.out |
--strategy | Strategy: current, aggressive, conservative | current |
Strategies
Section titled “Strategies”| Strategy | Description |
|---|---|
current | Set thresholds slightly below current coverage |
aggressive | Push for higher thresholds |
conservative | Lower thresholds for gradual improvement |
Example
Section titled “Example”# Get suggestionscoverctl suggest
# Aggressive strategycoverctl suggest --strategy aggressiveOutput
Section titled “Output”Suggested Thresholds────────────────────Domain Current Suggested Reasoncore 87.3% 85% Slightly below current (buffer for variance)api 81.2% 80% Slightly below currentcli 76.4% 75% Slightly below currentShow coverage debt report identifying files that need more tests.
coverctl debt [flags]| Flag | Description | Default |
|---|---|---|
-c, --config | Config file path | .coverctl.yaml |
-p, --profile | Coverage profile path | .cover/coverage.out |
-o, --output | Output format: text, json | text |
Example
Section titled “Example”coverctl debtOutput
Section titled “Output”Coverage Debt Report────────────────────File Current Required Shortfallinternal/core/validator.go 65.2% 85% -19.8%internal/api/handler.go 72.1% 80% -7.9%────────────────────Total Debt: 27.7%Health Score: 73/100ignore
Section titled “ignore”Show configured exclude patterns and ignored files.
coverctl ignore [flags]| Flag | Description | Default |
|---|---|---|
-c, --config | Config file path | .coverctl.yaml |
Example
Section titled “Example”coverctl ignoreOutput
Section titled “Output”Configured Excludes───────────────────- **/generated/**- **/mocks/**- internal/testdata/*
Ignored Files (matching excludes)─────────────────────────────────- internal/generated/proto/api.pb.go- internal/mocks/service_mock.godetect
Section titled “detect”Auto-detect domains and write configuration.
coverctl detect [flags]| Flag | Description | Default |
|---|---|---|
-c, --config | Config file path | .coverctl.yaml |
--dry-run | Preview config without writing | false |
-f, --force | Overwrite existing config | false |
Examples
Section titled “Examples”# Preview detected domainscoverctl detect --dry-run
# Write configcoverctl detect
# Overwrite existingcoverctl detect --forceversion
Section titled “version”Show version information.
coverctl versionOutput
Section titled “Output”coverctl v1.4.0 (abc1234) built 2024-12-23Show help for any command.
coverctl help [command]
# Examplescoverctl helpcoverctl help checkcoverctl check --help