Documentation
¶
Index ¶
- func CompressUncoveredLines(w io.Writer, ull []int)
- func Deliver(w io.Writer, output string, cfg OutputConfig)
- func SetGithubActionOutput(totalCoveragePercent int, bestReport string) error
- type BuildInput
- type CSVFormatter
- type CoverageSection
- type DiffSection
- type Format
- type Formatter
- type GithubActionEmitter
- type JSONFormatter
- type MarkdownFormatter
- type OutputConfig
- type Report
- type ShowMode
- type TextFormatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompressUncoveredLines ¶
CompressUncoveredLines writes uncovered line ranges in compressed format (e.g., "1-3 5 7").
func Deliver ¶
func Deliver(w io.Writer, output string, cfg OutputConfig)
Deliver routes formatted output to its target based on config.
func SetGithubActionOutput ¶
SetGithubActionOutput writes total coverage and report to the GITHUB_OUTPUT file.
Types ¶
type BuildInput ¶
type BuildInput struct {
Pass bool
PassCoverage bool
TotalStats coverage.Stats
FileThreshold int
PackageThreshold int
HasFileOverrides bool
HasPackageOverrides bool
FilesBelowThreshold []coverage.Stats
PackagesBelowThreshold []coverage.Stats
FilesWithUncoveredLines []coverage.Stats
FilesWithMissingExplanations []coverage.Stats
HasBaseBreakdown bool
DiffThreshold *float64
MeetsDiffThreshold bool
DiffPercentage float64
Diff []coverage.FileCoverageDiff
}
BuildInput contains all the data needed to build a report. This replaces the direct dependency on check.AnalyzeResult.
type CSVFormatter ¶
type CSVFormatter struct{}
CSVFormatter produces CSV output with multi-section layout. Each section starts with a `# Comment` line, followed by a CSV header and data rows. Sections are separated by blank lines.
func (*CSVFormatter) Format ¶
func (f *CSVFormatter) Format(r Report) string
type CoverageSection ¶
type CoverageSection struct {
Threshold int `json:"threshold"`
HasOverrides bool `json:"hasOverrides,omitempty"`
Pass bool `json:"pass"`
BelowThreshold []coverage.Stats `json:"belowThreshold,omitempty"`
}
CoverageSection holds threshold check results for files or packages.
type DiffSection ¶
type DiffSection struct {
Threshold *float64 `json:"threshold,omitempty"`
MeetsThreshold bool `json:"meetsThreshold"`
Percentage float64 `json:"percentage"`
Changes []coverage.FileCoverageDiff `json:"changes,omitempty"`
}
DiffSection holds coverage difference data between current and base branches.
type Formatter ¶
Formatter produces a report string in a specific format.
func NewFormatter ¶
NewFormatter creates a Formatter for the given format.
type GithubActionEmitter ¶
type GithubActionEmitter struct{}
GithubActionEmitter writes GitHub Actions ::error annotations to the writer.
type JSONFormatter ¶
type JSONFormatter struct{}
JSONFormatter produces JSON output of the Report.
func (*JSONFormatter) Format ¶
func (f *JSONFormatter) Format(r Report) string
type MarkdownFormatter ¶
type MarkdownFormatter struct{}
MarkdownFormatter produces Markdown-formatted output for PR comments.
func (*MarkdownFormatter) Format ¶
func (f *MarkdownFormatter) Format(r Report) string
type OutputConfig ¶
type OutputConfig struct {
Format Format `yaml:"format"`
FileName string `yaml:"file-name"`
ShowFileCoverage ShowMode `yaml:"show-file-coverage"`
ShowPackageCoverage ShowMode `yaml:"show-package-coverage"`
ShowUncoveredLines ShowMode `yaml:"show-uncovered-lines"`
ShowDiff ShowMode `yaml:"show-diff"`
ShowAnnotations ShowMode `yaml:"show-annotations"`
}
OutputConfig controls output format and section visibility.
func (*OutputConfig) ApplyDefaults ¶
func (c *OutputConfig) ApplyDefaults()
ApplyDefaults sets zero-value fields to their defaults.
func (*OutputConfig) Validate ¶
func (c *OutputConfig) Validate() error
Validate checks that all OutputConfig values are valid.
type Report ¶
type Report struct {
Pass bool `json:"pass"`
TotalCoverage coverage.Stats `json:"totalCoverage"`
FileCoverage *CoverageSection `json:"fileCoverage,omitempty"`
PackageCoverage *CoverageSection `json:"packageCoverage,omitempty"`
UncoveredLines []coverage.Stats `json:"uncoveredLines,omitempty"`
Diff *DiffSection `json:"diff,omitempty"`
Annotations []coverage.Stats `json:"annotations,omitempty"`
}
Report is a view model containing only sections that should be displayed. nil pointer fields indicate a section is hidden.
func BuildReport ¶
func BuildReport(input BuildInput, cfg OutputConfig) Report
BuildReport filters BuildInput through OutputConfig to produce a Report containing only sections that should be displayed.
type TextFormatter ¶
type TextFormatter struct{}
TextFormatter produces plain-text output identical to the previous ReportForHuman.
func (*TextFormatter) Format ¶
func (f *TextFormatter) Format(r Report) string