cichecks

package
v0.293.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func Names

func Names(c Checks) []string

Names is every check name c holds (statuses and runs), sorted.

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

type Status struct {
	State     string // success, pending, failure, error
	UpdatedAt time.Time
}

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 Summarize

func Summarize(c Checks) Summary

Summarize judges every check c holds.

func (Summary) AllGreen

func (s Summary) AllGreen() bool

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

func (s Summary) Done() bool

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

func (s Summary) FailedNames() []string

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.

func Of

func Of(c Checks, name string) Verdict

Of is the verdict for check name in c.

Jump to

Keyboard shortcuts

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