check
The check command runs tests with coverage instrumentation, evaluates coverage per domain, and enforces policy thresholds.
coverctl check [flags]Alias: coverctl c
Configuration
Section titled “Configuration”| Flag | Description | Default |
|---|---|---|
-c, --config | Config file path | .coverctl.yaml |
-p, --profile | Coverage profile output path | .cover/coverage.out |
--from-profile | Use existing coverage profile instead of running tests | false |
-d, --domain | Filter to specific domain (repeatable) | all domains |
-o, --output | Output format: text, json, html | text |
Policy Enforcement
Section titled “Policy Enforcement”| Flag | Description |
|---|---|
--fail-under N | Fail if overall coverage is below N percent |
--ratchet | Fail if coverage decreases from previous recorded value |
--validate | Validate config file without running tests |
--show-delta | Show coverage change from previous run |
--history | History file path for delta display |
Build/Test Flags
Section titled “Build/Test Flags”| Flag | Description |
|---|---|
--tags | Build tags (e.g., integration,e2e) |
--race | Enable race detector |
--short | Skip long-running tests |
-v | Verbose test output |
--run | Run only tests matching pattern |
--timeout | Test timeout (e.g., 10m, 1h) |
--test-arg | Additional go test argument (repeatable) |
Incremental Mode
Section titled “Incremental Mode”| Flag | Description | Default |
|---|---|---|
--incremental | Only test packages with changed files | false |
--incremental-ref | Git ref to compare against | HEAD~1 |
Incremental mode speeds up CI by only testing packages that have changed.
Examples
Section titled “Examples”Basic Usage
Section titled “Basic Usage”# Run coverage check with default configcoverctl check
# Use custom config filecoverctl check -c my-config.yaml
# Check specific domainscoverctl check -d core -d apiCI Pipeline
Section titled “CI Pipeline”# Fail if coverage below 80%coverctl check --fail-under 80
# Prevent coverage regressioncoverctl check --ratchet
# JSON output for parsingcoverctl check -o json --ciIntegration Tests
Section titled “Integration Tests”# Run with integration build tagcoverctl check --tags integration
# Extended timeout for slow testscoverctl check --tags integration --timeout 30m
# With race detectorcoverctl check --race --timeout 20mIncremental Mode
Section titled “Incremental Mode”# Only test changed packages (faster CI)coverctl check --incremental
# Compare against specific branchcoverctl check --incremental --incremental-ref origin/main
# Combine with other flagscoverctl check --incremental --fail-under 80 --ciValidation Only
Section titled “Validation Only”# Check config syntax without running testscoverctl check --validateUse Existing Profile
Section titled “Use Existing Profile”# Evaluate an existing profile without running testscoverctl check --from-profile --profile coverage.outNote:
--from-profileonly skips running tests; policy evaluation still runs against every configured domain. If you re-use a profile that already falls below a domain’smin, the check will keep failing. To unblock, regenerate a fresh profile withcoverctl run/coverctl check, lower the domain thresholds or remove/adjust the matching rules, or scope the evaluation via--domainso that the enforced domains actually meet your coverage targets.
Output
Section titled “Output”Text Output (default)
Section titled “Text Output (default)”Domain Coverage Required Status─────────────────────────────────────core 87.3% 85% PASSapi 81.2% 80% PASScli 76.4% 75% PASS─────────────────────────────────────Overall 82.1% 75% PASSJSON Output
Section titled “JSON Output”{ "passed": true, "domains": [ { "name": "core", "covered": 1234, "total": 1414, "percent": 87.3, "required": 85, "status": "pass" } ]}Troubleshooting
Section titled “Troubleshooting”If coverctl check disagrees with previously recorded history, make sure the history profile was produced by coverctl run or coverctl check. Profiles generated with plain go test -coverprofile can omit -coverpkg instrumentation, which makes history and policy checks diverge.
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | All policy checks passed |
1 | Policy violation (coverage below threshold) |
2 | Invalid configuration or arguments |
3 | Test execution failed |
See Also
Section titled “See Also”- run - Run coverage without policy enforcement
- report - Analyze existing coverage profile
- Configuration - Configure coverage policies