Documentation
¶
Overview ¶
Package cichecks is THE ONE reading of a commit's CI: its commit statuses and its check runs, judged by name. Two callers share it — the shipping officer's merge gate (internal/officership gates.go checksGreen, which asks "is every REQUIRED check green?") and the fleet's CI read (internal/api fleet_ci.go, which asks "has every check finished, and how did each end?"). One implementation, so the two never disagree about what green means.
The rule, per check name:
- a commit status of that name (its LATEST state, as GitHub's combined status gives it) decides: success is green; pending is not finished; failure and error are finished and failed;
- with no status of that name, the NEWEST check run of that name (the highest id: a re-run is a new run, so a newer attempt supersedes an older one, whichever way each ended) decides: queued or in_progress is not finished; completed/success is green; completed/neutral or skipped is finished and neither green nor failed; any other conclusion is failed;
- neither: missing.
Index ¶
Constants ¶
const ( Green = "green" Pending = "pending" Failed = "failed" Neutral = "neutral" // finished, neither green nor failed (neutral, skipped) Missing = "missing" )
The verdicts of one check (Verdict.State).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Checks ¶
type Checks struct {
Statuses map[string]Status
Runs []Run
// Truncated: the read stopped at its cap with more left unread, so a
// check not read may still be running — the CI is never done (or green).
Truncated bool
}
Checks is everything muster read of one commit's CI.
type Run ¶
type Run struct {
ID int64
Name string
Status string // queued, in_progress, completed
Conclusion string // success, failure, neutral, skipped, cancelled, timed_out, action_required, stale
CompletedAt time.Time
}
Run is one check run (GitHub's check-runs API).
type Status ¶
Status is one commit status context's latest state (GitHub's combined status), and when it was last set.
type Summary ¶
type Summary struct {
Verdicts []Verdict
// Counts per state.
Green, Pending, Failed, Neutral int
// LastFinished is when the last check to finish finished.
LastFinished time.Time
// Truncated: Checks.Truncated (not every check was read).
Truncated bool
}
Summary is every check of a commit, judged.
func (Summary) AllGreen ¶
AllGreen reports whether CI is green: done, nothing failed, at least one green (a commit whose every check was skipped is not green).
func (Summary) Done ¶
Done reports whether every check finished: at least one check, none pending, and every check read (a truncated read is pending, never done). No checks is not done (there is nothing to have finished).
func (Summary) FailedNames ¶
FailedNames is the failed checks' names, sorted.
type Verdict ¶
type Verdict struct {
Name string
State string
// Detail is the raw state: a status's ("failure") or a run's
// status/conclusion ("completed/failure").
Detail string
// FinishedAt is when it finished (zero while pending or unknown).
FinishedAt time.Time
}
Verdict is one check name's reading.