config

package
v0.83.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LinkCoverage          = "coverage"
	LinkCoverageFile      = "coverageFile"
	LinkCodeToTestRatio   = "codeToTestRatio"
	LinkTestExecutionTime = "testExecutionTime"
)

The keys of `viewer.links:`, one for each kind of value a table can link.

Variables

Functions

func Generate added in v0.36.0

func Generate(ctx context.Context, lang string, wr io.Writer) error

Types

type Badge added in v0.80.0

type Badge struct {
	Path       string       `yaml:"path,omitempty"`
	Label      string       `yaml:"label,omitempty"`
	LabelColor string       `yaml:"labelColor,omitempty"`
	Icon       string       `yaml:"icon,omitempty"`
	Colors     []BadgeColor `yaml:"colors,omitempty"`
	// contains filtered or unexported fields
}

Badge is the configuration of a report badge.

func (*Badge) CodeToTestRatioColor added in v0.80.0

func (b *Badge) CodeToTestRatioColor(ratio float64) (string, error)

CodeToTestRatioColor returns the message color of the code to test ratio badge.

func (*Badge) CoverageColor added in v0.80.0

func (b *Badge) CoverageColor(cover float64) (string, error)

CoverageColor returns the message color of the coverage badge.

func (*Badge) RenderCodeToTestRatio added in v0.80.0

func (b *Badge) RenderCodeToTestRatio(w io.Writer, ratio float64) error

RenderCodeToTestRatio renders the badge of a measured code to test ratio to w.

func (*Badge) RenderCoverage added in v0.80.0

func (b *Badge) RenderCoverage(w io.Writer, cover float64) error

RenderCoverage renders the badge of a measured coverage to w.

func (*Badge) RenderTestExecutionTime added in v0.80.0

func (b *Badge) RenderTestExecutionTime(w io.Writer, nano float64) error

RenderTestExecutionTime renders the badge of a measured test execution time, in nanoseconds, to w.

func (*Badge) TestExecutionTimeColor added in v0.80.0

func (b *Badge) TestExecutionTimeColor(d time.Duration) (string, error)

TestExecutionTimeColor returns the message color of the test execution time badge.

func (*Badge) Validate added in v0.80.0

func (b *Badge) Validate(normalize func(string) (string, error)) error

Validate validates the whole badge configuration, the conditions and the icon included, without a measured value. It is the up-front check of a central mode run, where a badge that cannot be rendered is worth hearing about before every datastore has been walked rather than after. normalize reads a condition the way the metric this badge belongs to writes one.

type BadgeColor added in v0.80.0

type BadgeColor struct {
	If    string `yaml:"if,omitempty"`
	Color string `yaml:"color"`
}

BadgeColor is a message color of a badge and the condition it is picked by.

type Body added in v0.49.0

type Body struct {
	HideFooterLink bool `yaml:"hideFooterLink"`
	// HideCoverageLink is removed in favor of `viewer: none`, and read only to say so.
	HideCoverageLink bool   `yaml:"hideCoverageLink"`
	ExpandDetails    bool   `yaml:"expandDetails"`
	Message          string `yaml:"message,omitempty"`
	If               string `yaml:"if,omitempty"`
}

type Central added in v0.49.0

type Central struct {
	Root     string         `yaml:"root"`
	Reports  CentralReports `yaml:"reports"`
	Badges   CentralBadges  `yaml:"badges"`
	Push     *Push          `yaml:"push,omitempty"`
	ReReport *Report        `yaml:"reReport,omitempty"`
	If       string         `yaml:"if,omitempty"`
}

func (*Central) UnmarshalYAML added in v0.49.0

func (c *Central) UnmarshalYAML(data []byte) error

type CentralBadges added in v0.49.0

type CentralBadges struct {
	Datastores        []string `yaml:"datastores"`
	Coverage          *Badge   `yaml:"coverage,omitempty"`
	CodeToTestRatio   *Badge   `yaml:"codeToTestRatio,omitempty"`
	TestExecutionTime *Badge   `yaml:"testExecutionTime,omitempty"`
}

type CentralReports added in v0.49.0

type CentralReports struct {
	Datastores []string `yaml:"datastores"`
}

type CodeToTestRatio added in v0.49.0

type CodeToTestRatio struct {
	Code       []string `yaml:"code"`
	Test       []string `yaml:"test"`
	Badge      Badge    `yaml:"badge,omitempty"`
	Acceptable string   `yaml:"acceptable,omitempty"`
	If         string   `yaml:"if,omitempty"`
}

type Comment added in v0.49.0

type Comment struct {
	HideFooterLink bool `yaml:"hideFooterLink"`
	// HideCoverageLink is removed in favor of `viewer: none`, and read only to say so.
	HideCoverageLink bool   `yaml:"hideCoverageLink"`
	ExpandDetails    bool   `yaml:"expandDetails"`
	DeletePrevious   bool   `yaml:"deletePrevious"`
	UpdatePrevious   bool   `yaml:"updatePrevious"`
	Message          string `yaml:"message,omitempty"`
	If               string `yaml:"if,omitempty"`
}

type Config

type Config struct {
	Repository        string             `yaml:"repository"`
	Coverage          *Coverage          `yaml:"coverage"`
	CodeToTestRatio   *CodeToTestRatio   `yaml:"codeToTestRatio,omitempty"`
	TestExecutionTime *TestExecutionTime `yaml:"testExecutionTime,omitempty"`
	Report            *Report            `yaml:"report,omitempty"`
	Central           *Central           `yaml:"central,omitempty"`
	Push              *Push              `yaml:"push,omitempty"`
	Comment           *Comment           `yaml:"comment,omitempty"`
	Summary           *Summary           `yaml:"summary,omitempty"`
	Body              *Body              `yaml:"body,omitempty"`
	Diff              *Diff              `yaml:"diff,omitempty"`
	Viewer            *Viewer            `yaml:"viewer,omitempty"`
	Timeout           time.Duration      `yaml:"timeout,omitempty"`
	Locale            *language.Tag      `yaml:"locale,omitempty"`
	GitRoot           string             `yaml:"-"`
	// contains filtered or unexported fields
}

func New

func New() *Config

func (*Config) Acceptable added in v0.8.0

func (c *Config) Acceptable(r, rPrev Reporter, pc *cov.PatchCoverage) error

Acceptable checks r (and rPrev, for comparison) against the configured acceptable conditions. pc is the already measured patch coverage, used for the `patch` variable of `coverage.acceptable:`. Pass nil if it could not be measured; `patch` then falls back to defaultPatchCoverage, and the condition is still evaluated.

Patch coverage is passed in already measured rather than computed here, because it is derived from the block coverages, which the caller shrinks away once the report has been stored.

func (*Config) BodyConfigReady added in v0.43.0

func (c *Config) BodyConfigReady() error

func (*Config) Build

func (c *Config) Build()

func (*Config) CentralConfigReady added in v0.2.0

func (c *Config) CentralConfigReady() error

func (*Config) CentralPushConfigReady added in v0.9.0

func (c *Config) CentralPushConfigReady() error

func (*Config) CentralReReportReady added in v0.45.0

func (c *Config) CentralReReportReady() error

func (*Config) CheckIf added in v0.27.0

func (c *Config) CheckIf(cond string) (bool, error)

func (*Config) CodeToTestRatioBadgeConfigReady added in v0.6.0

func (c *Config) CodeToTestRatioBadgeConfigReady() error

func (*Config) CodeToTestRatioColor added in v0.6.0

func (c *Config) CodeToTestRatioColor(ratio float64) string

CodeToTestRatioColor returns the color of a measured code to test ratio by the built-in thresholds.

func (*Config) CodeToTestRatioConfigReady added in v0.12.0

func (c *Config) CodeToTestRatioConfigReady() error

func (*Config) CommentConfigReady added in v0.11.0

func (c *Config) CommentConfigReady() error

func (*Config) CoverageBadgeConfigReady added in v0.6.0

func (c *Config) CoverageBadgeConfigReady() error

func (*Config) CoverageColor added in v0.2.0

func (c *Config) CoverageColor(cover float64) string

CoverageColor returns the color of a measured coverage by the built-in thresholds. It is the color of the metric itself rather than of a badge, which is what `octocov ls-files` paints a listing with. A badge resolves its own color through Badge.CoverageColor, since `colors:` describes one badge rather than what a coverage figure means.

func (*Config) CoverageConfigReady added in v0.12.0

func (c *Config) CoverageConfigReady() error

func (*Config) CoverageConfigReadyOnLocal added in v0.59.0

func (c *Config) CoverageConfigReadyOnLocal() error
func (c *Config) CustomLinks() (*CustomLinks, error)

CustomLinks returns the expressions of `viewer.links:` bound to the variables `if:` has, or nil when the viewer is not a custom one.

func (*Config) DiffConfigReady added in v0.20.0

func (c *Config) DiffConfigReady() error

func (*Config) Load

func (c *Config) Load(path string) error

func (*Config) Loaded added in v0.2.0

func (c *Config) Loaded() bool

func (*Config) PushConfigReady added in v0.9.0

func (c *Config) PushConfigReady() error

func (*Config) ReportConfigReady added in v0.14.0

func (c *Config) ReportConfigReady() error

func (*Config) ReportConfigTargetReady added in v0.20.1

func (c *Config) ReportConfigTargetReady() error

func (*Config) ResolveCentralViewer added in v0.81.0

func (c *Config) ResolveCentralViewer(ctx context.Context) ViewerType

ResolveCentralViewer returns the viewer the badges of the central mode link to. The reports it collects are named by the central repository, so its visibility stands in for theirs when `viewer:` is not set.

func (*Config) ResolveViewer added in v0.81.0

func (c *Config) ResolveViewer(ctx context.Context) ViewerType

ResolveViewer returns the viewer the tables link to. When `viewer:` is not set, a public repository on github.com whose report is stored in an artifact links to octocov.dev, since there it asks nothing of a reader, and everything else links to the page rendered into an artifact.

func (*Config) Root added in v0.2.0

func (c *Config) Root() string

func (*Config) Setwd added in v0.5.0

func (c *Config) Setwd(path string)

func (*Config) SummaryConfigReady added in v0.42.0

func (c *Config) SummaryConfigReady() error

func (*Config) TestExecutionTimeBadgeConfigReady added in v0.7.0

func (c *Config) TestExecutionTimeBadgeConfigReady() error

func (*Config) TestExecutionTimeColor added in v0.7.0

func (c *Config) TestExecutionTimeColor(d time.Duration) string

TestExecutionTimeColor returns the color of a measured test execution time by the built-in thresholds.

func (*Config) TestExecutionTimeConfigReady added in v0.12.0

func (c *Config) TestExecutionTimeConfigReady() error

func (*Config) UnmarshalYAML added in v0.38.0

func (c *Config) UnmarshalYAML(data []byte) error

func (*Config) Wd added in v0.53.0

func (c *Config) Wd() string

type Coverage added in v0.49.0

type Coverage struct {
	Path       string   `yaml:"path,omitempty"`
	Paths      []string `yaml:"paths,omitempty"`
	Exclude    []string `yaml:"exclude,omitempty"`
	Badge      Badge    `yaml:"badge,omitempty"`
	Acceptable string   `yaml:"acceptable,omitempty"`
	If         string   `yaml:"if,omitempty"`
}

func (*Coverage) AcceptableReferencesPatch added in v0.76.0

func (c *Coverage) AcceptableReferencesPatch() bool

AcceptableReferencesPatch reports whether the `coverage.acceptable:` condition references the `patch` variable.

type CustomLinks struct {
	// contains filtered or unexported fields
}

CustomLinks evaluates the expressions of `viewer.links:`.

func (l *CustomLinks) Link(key string, vars map[string]any) (string, error)

Link evaluates the expression of key with vars joined to the variables `if:` has, and returns the link it answers, or an empty string when there is none.

type Diff added in v0.49.0

type Diff struct {
	Path       string   `yaml:"path,omitempty"`
	Datastores []string `yaml:"datastores,omitempty"`
	If         string   `yaml:"if,omitempty"`
}

type Push added in v0.49.0

type Push struct {
	If      string `yaml:"if,omitempty"`
	Message string `yaml:"message,omitempty"`
}

type Report added in v0.49.0

type Report struct {
	If         string   `yaml:"if,omitempty"`
	Path       string   `yaml:"path,omitempty"`
	Datastores []string `yaml:"datastores,omitempty"`
}

type Reporter added in v0.56.0

type Reporter interface {
	CoveragePercent() float64
	IsMeasuredCoverage() bool
	CodeToTestRatioRatio() float64
	TestExecutionTimeNano() float64
	IsMeasuredTestExecutionTime() bool
	CustomMetricsAcceptable(Reporter) error
}

type Summary added in v0.49.0

type Summary struct {
	HideFooterLink bool `yaml:"hideFooterLink"`
	// HideCoverageLink is removed in favor of `viewer: none`, and read only to say so.
	HideCoverageLink bool   `yaml:"hideCoverageLink"`
	ExpandDetails    bool   `yaml:"expandDetails"`
	Message          string `yaml:"message,omitempty"`
	If               string `yaml:"if,omitempty"`
}

type TestExecutionTime added in v0.49.0

type TestExecutionTime struct {
	Badge      Badge    `yaml:"badge,omitempty"`
	Acceptable string   `yaml:"acceptable,omitempty"`
	Steps      []string `yaml:"steps,omitempty"`
	If         string   `yaml:"if,omitempty"`
}

type Viewer added in v0.81.0

type Viewer struct {
	Type  ViewerType   `yaml:"type"`
	Links *ViewerLinks `yaml:"links,omitempty"`
	// contains filtered or unexported fields
}

Viewer says where the values in the tables link to.

func (v *Viewer) CustomLinks(vars map[string]any) *CustomLinks

CustomLinks returns the expressions of `viewer.links:` bound to vars.

func (*Viewer) UnmarshalYAML added in v0.81.0

func (v *Viewer) UnmarshalYAML(data []byte) error

UnmarshalYAML reads a viewer written as its type alone, which is shorthand for a map holding only `type`.

type ViewerLinks struct {
	Coverage          string `yaml:"coverage,omitempty"`
	CoverageFile      string `yaml:"coverageFile,omitempty"`
	CodeToTestRatio   string `yaml:"codeToTestRatio,omitempty"`
	TestExecutionTime string `yaml:"testExecutionTime,omitempty"`
}

type ViewerType added in v0.81.0

type ViewerType string
const (
	ViewerOctocovDev ViewerType = "octocov.dev"
	ViewerArtifact   ViewerType = "artifact"
	ViewerNone       ViewerType = "none"
	ViewerCustom     ViewerType = "custom"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址