Documentation
¶
Overview ¶
Package gate runs a gate: a list of checks, each a command whose result is read against thresholds decided in advance (docs/spec/gates.md). No model is ever asked whether to pass. On a merge request, the thresholds read only the findings the change adds (ADR-0049): each SARIF check runs again at the merge base, and its results are compared.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Added ¶ added in v0.36.0
type Added struct {
Base string `json:"base"` // the merge base they are counted since
Checks []CheckCount `json:"checks"`
Findings []Finding `json:"findings"`
}
Added is what a gate found a change adds, for what shows it on the merge request (ADR-0049, step 3): each check's count, and the findings themselves, placed and named by a fingerprint.
func RunNew ¶ added in v0.36.0
RunNew runs the gate on a change: the thresholds read only the findings it adds since the merge base of since and HEAD, and a suppression it adds counts as one (ADR-0049). Added is what the change adds, for what shows it on the merge request; nil when the gate did not run.
type Check ¶
type Check struct {
ID string `yaml:"id"`
Run string `yaml:"run"`
Output string `yaml:"output"` // exit | sarif
Max map[string]int `yaml:"max"` // per SARIF level: error, warning, note
Optional bool `yaml:"optional"`
Timeout string `yaml:"timeout"` // e.g. "10m"; default 10 minutes
// New says who tells a merge request's new findings, for a SARIF
// check: rerun (the default), the engine, running it again at the
// merge base; tool, the tool itself, given WORKLINE_BASE.
New string `yaml:"new"`
// BaseTimeout caps the run at the merge base; by default twice the
// head's, a minute at least, the check's timeout at most.
BaseTimeout string `yaml:"base-timeout"`
// Config: the files the tool reads its config from, beside those its
// name tells, the head's copied over the merge base.
Config []string `yaml:"config"`
// Fix is the command that fixes what the check finds, a formatter's:
// said with its findings, which are not shown line by line.
Fix string `yaml:"fix"`
}
Check is one command of a gate.
type CheckCount ¶ added in v0.36.0
type CheckCount struct {
ID string `json:"id"`
Output string `json:"output"` // exit or sarif
New int `json:"new"`
// Before: the findings there before the change, not counted; -1 when
// the tool told the new ones itself, the rest not known, or none were read.
Before int `json:"before"`
Failed bool `json:"failed,omitempty"` // an exit check that did not pass
Error string `json:"error,omitempty"` // the check did not work: nothing it found is known
Fix string `json:"fix,omitempty"` // the command that fixes what it finds: a formatter's
}
CheckCount is how one check of a gate ended on a change.
type Finding ¶ added in v0.36.0
type Finding struct {
Check string `json:"check"`
Tool string `json:"tool,omitempty"`
Rule string `json:"rule,omitempty"`
Level string `json:"level"` // SARIF's: error, warning, note
Path string `json:"path,omitempty"`
Line int `json:"line,omitempty"`
Message string `json:"message,omitempty"`
// Fingerprint holds no line number: the finding's identity, as the
// comparison reads it, and how many alike come before it in its file.
// It stays while the finding only moves (GitLab's Code Quality reads
// it).
Fingerprint string `json:"fingerprint"`
}
Finding is one result a change adds, as the tool wrote it.