Documentation
¶
Overview ¶
Package coveragegate enforces per-package minimum statement-coverage floors against a standard Go coverprofile and fails closed on any drop.
Packages are never merged: every required package is compared on its own against its own floor, so a high result in one package can never offset a drop in another. Statements are attributed to packages by their module prefix, which the caller resolves from go.mod.
The floors recorded in the manifest are a temporary no-regression guard pinned to a measured baseline. They are not the product coverage goal; the 85% pkg goal in PRODUCT.md stays unchanged and unmet by this gate.
Index ¶
Constants ¶
const SupportedSchemaVersion = 1
SupportedSchemaVersion is the only manifest schema this checker accepts.
Variables ¶
This section is empty.
Functions ¶
func FormatTenths ¶
FormatTenths renders tenths of a percent as a fixed one-decimal string.
func ReadModulePath ¶
ReadModulePath extracts the module path from a go.mod file.
Types ¶
type Manifest ¶
type Manifest struct {
// The camelCase JSON names are fixed by the TASK-267 card's manifest
// contract, not a style choice.
SchemaVersion int `json:"schemaVersion"` //nolint:tagliatelle // card-mandated manifest field name
Purpose string `json:"purpose"`
Packages []PackageFloor `json:"packages"`
}
Manifest is the on-disk record of the critical coverage floors.
func LoadManifest ¶
LoadManifest reads and validates a floors manifest from disk.
type PackageFloor ¶
type PackageFloor struct {
Package string `json:"package"`
MinimumPercent float64 `json:"minimumPercent"` //nolint:tagliatelle // card-mandated manifest field name
BaselineCoveredStatements int64 `json:"baselineCoveredStatements"` //nolint:tagliatelle // card-mandated manifest field name
BaselineTotalStatements int64 `json:"baselineTotalStatements"` //nolint:tagliatelle // card-mandated manifest field name
BaselineCommit string `json:"baselineCommit"` //nolint:tagliatelle // card-mandated manifest field name
MeasurementCommand string `json:"measurementCommand"` //nolint:tagliatelle // card-mandated manifest field name
}
PackageFloor pins one package to a minimum coverage percentage and records where that floor was measured.
type Result ¶
type Result struct {
Package string
Covered int64
Total int64
TenthsOfPct int64 // measured coverage in tenths of a percent, rounded half-up
FloorTenths int64 // floor in tenths of a percent
Passed bool
Missing bool // the package had no record in the profile
}
Result reports the measured coverage of one required package.
func Check ¶
Check parses profile (a standard Go coverprofile), attributes its statements to packages under modulePath, and compares every manifest package against its own floor. It returns one result per manifest package and a joined error listing every violation, so a single run reports all drops at once. Exactly meeting a floor passes; anything below it fails.