Documentation
¶
Index ¶
- Constants
- func FileAnchor(path string) string
- func NormalizeRef(ref string) string
- type CustomMetric
- type CustomMetricSet
- type DiffCustomMetric
- type DiffCustomMetricSet
- type DiffReport
- type DiffTestExecutionTime
- type MetadataKV
- type Option
- type Options
- type Report
- func (r *Report) BaseKeys() []string
- func (r *Report) Bytes() []byte
- func (r *Report) CodeToTestRatioRatio() float64
- func (r *Report) CollectCustomMetrics() error
- func (r *Report) Compare(r2 *Report) *DiffReport
- func (r *Report) CountMeasured() int
- func (r *Report) CoveragePercent() float64
- func (r *Report) CustomMetricsAcceptable(cr config.Reporter) error
- func (r *Report) DefaultBranch() string
- func (r *Report) DetectRef(ctx context.Context) error
- func (r *Report) FileCoveragesTable(files []*gh.PullRequestFile, v *Viewer) string
- func (r *Report) IsCollectedCustomMetrics() bool
- func (r *Report) IsMeasuredCodeToTestRatio() bool
- func (r *Report) IsMeasuredCoverage() bool
- func (r *Report) IsMeasuredTestExecutionTime() bool
- func (r *Report) Key() string
- func (r *Report) Load(path string) error
- func (r *Report) MeasureCodeToTestRatio(root string, code, test []string) error
- func (r *Report) MeasureCoverage(patterns, exclude []string) error
- func (r *Report) MeasureTestExecutionTime(ctx context.Context, stepNames []string) error
- func (r *Report) NormalizeCoveragePaths()
- func (r *Report) Out(w io.Writer) error
- func (r *Report) PatchCoverage(changedFiles map[string][]int) *coverage.PatchCoverage
- func (r *Report) RefKey() string
- func (r *Report) RunRef() string
- func (r *Report) SkippedCoverageReports() error
- func (r *Report) StorePath() string
- func (r *Report) String() string
- func (r *Report) Table(v *Viewer) string
- func (r *Report) TestExecutionTimeNano() float64
- func (r *Report) Title() string
- func (r *Report) UnmarshalJSON(b []byte) error
- func (r *Report) Validate() error
- func (r *Report) ViewerURL() string
- type Viewer
Constants ¶
const Filename = "report.json"
Filename is the name the report is stored under in every datastore.
Variables ¶
This section is empty.
Functions ¶
func FileAnchor ¶ added in v0.81.0
FileAnchor returns the id the page uploaded as an artifact gives the card of the file at path, which is repository relative: `file-` and the path percent-encoded per RFC 3986, keeping the unreserved characters and `/`. It is the rule the page works the id out by, written out because neither url.PathEscape nor url.QueryEscape escapes that exact set.
func NormalizeRef ¶ added in v0.77.0
NormalizeRef expands a bare branch name to its full ref path and drops the /merge and /head suffixes GITHUB_REF carries on pull request events, neither of which identifies a ref of its own.
Types ¶
type CustomMetric ¶ added in v0.51.0
type CustomMetric struct {
Key string `json:"key"`
Name string `json:"name,omitempty"`
Value float64 `json:"value"`
Unit string `json:"unit,omitempty"`
}
func (*CustomMetric) Compare ¶ added in v0.51.0
func (m *CustomMetric) Compare(m2 *CustomMetric) *DiffCustomMetric
type CustomMetricSet ¶ added in v0.51.0
type CustomMetricSet struct {
Key string `json:"key"`
Name string `json:"name,omitempty"`
Metadata []*MetadataKV `json:"metadata,omitempty"`
Metrics []*CustomMetric `json:"metrics"`
Acceptables []string `json:"acceptables,omitempty"`
// contains filtered or unexported fields
}
func (*CustomMetricSet) Compare ¶ added in v0.51.0
func (s *CustomMetricSet) Compare(s2 *CustomMetricSet) *DiffCustomMetricSet
func (*CustomMetricSet) MetadataTable ¶ added in v0.52.0
func (s *CustomMetricSet) MetadataTable(expandDetails bool) string
func (*CustomMetricSet) Table ¶ added in v0.51.0
func (s *CustomMetricSet) Table() string
func (*CustomMetricSet) Validate ¶ added in v0.51.0
func (s *CustomMetricSet) Validate() error
type DiffCustomMetric ¶ added in v0.51.0
type DiffCustomMetricSet ¶ added in v0.51.0
type DiffCustomMetricSet struct {
Key string `json:"key"`
Name string `json:"name,omitempty"`
A *CustomMetricSet `json:"a"`
B *CustomMetricSet `json:"b"`
Metrics []*DiffCustomMetric `json:"metrics"`
}
func (*DiffCustomMetricSet) MetadataTable ¶ added in v0.52.0
func (d *DiffCustomMetricSet) MetadataTable(expandDetails bool) string
func (*DiffCustomMetricSet) Table ¶ added in v0.51.0
func (d *DiffCustomMetricSet) Table() string
type DiffReport ¶ added in v0.20.0
type DiffReport struct {
RepositoryA string `json:"repository_a"`
RepositoryB string `json:"repository_b"`
RefA string `json:"ref_a"`
RefB string `json:"ref_b"`
CommitA string `json:"commit_a"`
CommitB string `json:"commit_b"`
Coverage *coverage.DiffCoverage `json:"coverage,omitempty"`
CodeToTestRatio *ratio.DiffRatio `json:"code_to_test_ratio,omitempty"`
TestExecutionTime *DiffTestExecutionTime `json:"test_execution_time,omitempty"`
CustomMetrics []*DiffCustomMetricSet `json:"custom_metrics,omitempty"`
TimestampA time.Time `json:"timestamp_a"`
TimestampB time.Time `json:"timestamp_b"`
ReportA *Report `json:"-"`
ReportB *Report `json:"-"`
}
func (*DiffReport) FileCoveragesTable ¶ added in v0.58.1
func (d *DiffReport) FileCoveragesTable(files []*gh.PullRequestFile, relWd string, v *Viewer) string
func (*DiffReport) Out ¶ added in v0.20.0
func (d *DiffReport) Out(w io.Writer)
func (*DiffReport) Table ¶ added in v0.20.0
func (d *DiffReport) Table(cur, prev *Viewer, expandDetails bool) string
Table renders the comparison. cur views the report being described and prev the one it is compared against, which is a viewer of its own because a comparison can be read from somewhere the pages do not serve. expandDetails renders the breakdown already open.
type DiffTestExecutionTime ¶ added in v0.20.0
type MetadataKV ¶ added in v0.52.0
type Report ¶
type Report struct {
Repository string `json:"repository"`
Ref string `json:"ref"`
Commit string `json:"commit"`
PullRequest int `json:"pull_request,omitempty"`
BaseRef string `json:"base_ref,omitempty"`
Coverage *coverage.Coverage `json:"coverage,omitempty"`
CodeToTestRatio *ratio.Ratio `json:"code_to_test_ratio,omitempty"`
TestExecutionTime *float64 `json:"test_execution_time,omitempty"`
Timestamp time.Time `json:"timestamp"`
CustomMetrics []*CustomMetricSet `json:"custom_metrics,omitempty"`
// contains filtered or unexported fields
}
func (*Report) BaseKeys ¶ added in v0.81.0
BaseKeys returns the keys, as RefKey gives them, of the reports this one is compared against, the more preferred first. A pull request is compared against its base branch, which leaves out whatever the base branch and the default branch differ by, and against the default branch where the base branch has stored no report, as in a repository that reports only from the default branch. Any other run is compared against the default branch, which is the empty key.
Where the default branch is not known, the key of the base branch is given even if the base is the default branch, whose report is stored under the empty key instead, since asking for the default branch would take a request on every run, where a read that misses costs one only where a comparison is made.
func (*Report) CodeToTestRatioRatio ¶ added in v0.6.0
func (*Report) CollectCustomMetrics ¶ added in v0.51.0
CollectCustomMetrics collects custom metrics from env.
func (*Report) Compare ¶ added in v0.20.0
func (r *Report) Compare(r2 *Report) *DiffReport
func (*Report) CountMeasured ¶ added in v0.12.0
func (*Report) CoveragePercent ¶
func (*Report) CustomMetricsAcceptable ¶ added in v0.72.0
func (*Report) DefaultBranch ¶ added in v0.81.0
DefaultBranch returns the ref of the default branch where the run knows it without asking the API, and "" otherwise.
func (*Report) DetectRef ¶ added in v0.77.0
DetectRef fills in the pull request number and the base ref of the current run. Both are recorded in the report. They decide where a datastore storing by path puts it and which ref an artifact datastore stores its metadata for, so that a report of a ref other than the default branch is not read as the one that comparisons and the central mode are after.
func (*Report) FileCoveragesTable ¶ added in v0.58.1
func (r *Report) FileCoveragesTable(files []*gh.PullRequestFile, v *Viewer) string
func (*Report) IsCollectedCustomMetrics ¶ added in v0.51.0
func (*Report) IsMeasuredCodeToTestRatio ¶ added in v0.12.0
func (*Report) IsMeasuredCoverage ¶ added in v0.12.0
func (*Report) IsMeasuredTestExecutionTime ¶ added in v0.12.0
func (*Report) MeasureCodeToTestRatio ¶ added in v0.6.0
func (*Report) MeasureCoverage ¶
func (*Report) MeasureTestExecutionTime ¶ added in v0.7.0
func (*Report) NormalizeCoveragePaths ¶ added in v0.75.0
func (r *Report) NormalizeCoveragePaths()
NormalizeCoveragePaths normalizes coverage file paths relative to git root. This is used for reports loaded from datastores that may not have NormalizedPath set.
func (*Report) PatchCoverage ¶ added in v0.76.0
func (r *Report) PatchCoverage(changedFiles map[string][]int) *coverage.PatchCoverage
PatchCoverage calculates the coverage of the given changed lines (e.g. lines changed in a pull request). changedFiles maps a file path to the line numbers changed in that file.
func (*Report) RefKey ¶ added in v0.77.0
RefKey returns the key that separates this report from the reports of other refs in a datastore. The default branch keeps the empty key, which is the single location every report was stored at before refs were separated, so reports already stored there stay the ones that comparisons are made against. A report that predates BaseRef carries no way to tell its ref apart from the default branch, so it keeps the empty key too rather than being moved somewhere its readers do not look.
func (*Report) RunRef ¶ added in v0.81.0
RunRef returns the ref the run that took the report was on, the pull request where it was one and the branch or the tag otherwise. Unlike RefKey it names the default branch as well, since it is what the metadata of a report stored as an artifact is looked up by, and the default branch is the ref looked up most. It is empty when the run carried no ref.
func (*Report) SkippedCoverageReports ¶ added in v0.83.4
SkippedCoverageReports returns why some of the coverage reports matched by the last MeasureCoverage could not be parsed while the others were measured, or nil if none was left out.
func (*Report) StorePath ¶ added in v0.77.0
StorePath returns the path of the report file within a datastore.
func (*Report) TestExecutionTimeNano ¶ added in v0.29.0
func (*Report) UnmarshalJSON ¶ added in v0.51.0
func (*Report) ViewerURL ¶ added in v0.79.0
ViewerURL returns the octocov.dev page that browses this report. That page is routed by the ref rather than by the artifact name, and the ref key is what says which one, so the report of the default branch is the repository itself and every other ref has a page beside it. It is empty when the report has no page there at all.
type Viewer ¶ added in v0.77.0
type Viewer struct {
// contains filtered or unexported fields
}
Viewer turns the values of the rendered tables into links to the pages that show the report behind them. Each kind of value has a link of its own, and a kind a viewer does not link is rendered as plain text.
A nil Viewer renders every value as plain text, which lets a caller with nowhere to link to pass nil rather than branch at each cell.
func NewArtifactViewer ¶ added in v0.81.0
NewArtifactViewer returns the viewer linking to the page of HTML uploaded as an artifact at pageURL, or nil when there is no such page. A file is linked to its card on the page, by the anchor the page gives it, which is worked out from the path alone. anchors holds the cards the page drew, and a file it drew no card for is linked to the page itself, since the renderer stops drawing cards at its own budgets.
func NewCustomViewer ¶ added in v0.81.0
func NewCustomViewer(links *config.CustomLinks, isBase bool) *Viewer
NewCustomViewer returns the viewer linking to where the expressions of `viewer.links:` say, or nil when there are none. isBase says the viewer renders the compared column.
func NewOctocovDevRefViewer ¶ added in v0.81.0
func NewOctocovDevRefViewer() *Viewer
NewOctocovDevRefViewer returns the viewer linking a report as a whole to its octocov.dev page, which is routed by the ref and so needs no artifact name. Files are not linked, since their pages are addressed by one.
func NewOctocovDevViewer ¶ added in v0.81.0
NewOctocovDevViewer returns the viewer linking to the octocov.dev pages of the report whose metadata is stored under metadataName, or nil when the name is empty. A file is addressed there by the metadata of the ref its report was stored for, while the report as a whole is routed by its ref, which is why Report.ViewerURL answers for it without a Viewer at all.
func (*Viewer) CodeToTestRatioURL ¶ added in v0.81.0
CodeToTestRatioURL returns the link of the code to test ratio of r.
func (*Viewer) CoverageURL ¶ added in v0.81.0
CoverageURL returns the link of the overall coverage of r.
func (*Viewer) Err ¶ added in v0.81.0
Err returns the first link that could not be worked out while rendering.
func (*Viewer) ReadsArtifacts ¶ added in v0.81.0
ReadsArtifacts reports whether the pages linked to read the report out of the artifacts of the repository it describes, so that a report read from anywhere else has no page.
func (*Viewer) TestExecutionTimeURL ¶ added in v0.81.0
TestExecutionTimeURL returns the link of the test execution time of r.