Documentation
¶
Overview ¶
Package deployready answers one question for the hub: is the tip of the integration branch safe to deploy, and if not, which commits are in the way. See docs/rnd/factory-shape.md, "(a) The hub deploys itself", and @review's five required changes in docs/backlog/rnd/rd-new-review-ed68cd81.md, which this follows point by point.
It reads git and writes nothing. It never deploys, and nothing here is on a timer that does.
A VERDICT IS A TRAILER ON A REVIEW COMMIT:
Atrium-Verdict: hub-ok <base>..<tip> Atrium-Verdict: room-ok <base>..<tip> Atrium-Verdict: hold <sha>
and what it covers is decided by PATCH, not by SHA. Landings rebase, and the same change reaches the branch under a new SHA, so a verdict is matched to a landed commit by `git patch-id --stable`. A change that was altered on the way gets another patch-id and so has no verdict, which is the safe answer: the code that was read is not the code that landed.
Index ¶
- Constants
- Variables
- func Needs(p string) bool
- func RoomSide(p string) bool
- type Blocker
- type Checker
- func (c *Checker) Check(ctx context.Context, installed string) Report
- func (c *Checker) Coverage(ctx context.Context, base, tip string, alsoOn ...string) (Coverage, error)
- func (c *Checker) Queue(ctx context.Context, hub string, rooms []Live) Queue
- func (c *Checker) Since(ctx context.Context, from, to string) (int, error)
- type Coverage
- type Git
- type Live
- type Queue
- type QueueEntry
- type Report
Constants ¶
const ( WhyNoVerdict = "no-verdict" WhyHold = "hold" WhyNoRoomVerdict = "no-room-verdict" WhyRoomHold = "room-hold" )
Why a commit blocks a deploy.
const ( // StateReady means every commit that needs a verdict has one, and there is something to deploy. StateReady = "ready" // StateBlocked means at least one commit is still in the way. Blocking names them. StateBlocked = "blocked" // StateCurrent means nothing that needs a verdict has landed since the installed build. StateCurrent = "current" // StateUnknown means the check could not be made. Error says why. It is never ready. StateUnknown = "unknown" )
States of a Report.
const ( NeedsHub = "hub" NeedsRoom = "room" NeedsBoth = "both" )
Needs values of a QueueEntry.
const DefaultMaxCommits = 2000
DefaultMaxCommits is well past what lands between two deploys. A range longer than this answers unknown.
const DefaultMaxVerdicts = 1000
DefaultMaxVerdicts is far more review commits than sit between two deploys.
Variables ¶
var ErrNotBehind = fmt.Errorf("that commit is not an ancestor of the tip")
ErrNotBehind is `from` not being an ancestor of `to`: the branch was rebased or reset, so there is no count of commits since.
Functions ¶
Types ¶
type Blocker ¶
type Blocker struct {
SHA string `json:"sha"`
Short string `json:"short"`
Subject string `json:"subject"`
Why string `json:"why"`
// Detail is the sentence the board shows.
Detail string `json:"detail"`
}
Blocker is one commit that keeps the deploy from being ready.
type Checker ¶
type Checker struct {
Git Git
Dir string
Branch string
// MaxVerdicts bounds how many review commits are read. Zero takes DefaultMaxVerdicts.
MaxVerdicts int
// MaxCommits bounds how many commits one range may walk, for the commits since the installed build and for each
// verdict's range. Zero takes DefaultMaxCommits.
MaxCommits int
// contains filtered or unexported fields
}
Checker reads one repository's integration branch. Safe for concurrent use.
func (*Checker) Check ¶
Check is the answer for the branch tip against the build installed, named by its commit.
func (*Checker) Coverage ¶
func (c *Checker) Coverage(ctx context.Context, base, tip string, alsoOn ...string) (Coverage, error)
Coverage reads base..tip and says which commits a verdict clears. Verdicts are read from the Checker's integration branch and from alsoOn, which are refs of the same repository (an item's own branch, as `refs/heads/<name>`).
func (*Checker) Queue ¶
Queue lists the commits on the branch that are not in the hub's running commit, or not in a room's, and that change something the deploy ships. A commit that touches only hub-only code needs the hub. Any other shipped code needs both, because the room restarts on the same binary.
func (*Checker) Since ¶
Since counts the commits after `from` up to `to` that are the work: the verdict commits are left out, because a review landing on the branch after a test is not a change to what was tested. ErrNotBehind says `from` is no longer on the branch's line, which the caller shows as stale with no count.
type Coverage ¶
type Coverage struct {
Base string `json:"base"`
Tip string `json:"tip"`
// Total is the commits a reviewer reads: every commit of the range that carries a change, less the verdict commits
// themselves, which are the review and not the work.
Total int `json:"total"`
// Covered is how many of them have a verdict that clears them: hub-ok, and room-ok too where the commit also runs in the
// room. A hold clears nothing.
Covered int `json:"covered"`
// Held are the commits a verdict holds.
Held []string `json:"held,omitempty"`
// Uncovered are the commits no verdict clears, held ones included, oldest first.
Uncovered []string `json:"uncovered,omitempty"`
// TipCovered is that the newest commit of the range is cleared, which is what a verdict "at the tip" means.
TipCovered bool `json:"tip_covered"`
// Notes are verdicts that were ignored, and why.
Notes []string `json:"notes,omitempty"`
}
Coverage is how much of a range the verdicts cover.
type Git ¶
type Git interface {
Git(ctx context.Context, dir string, op gitexec.Op) (string, error)
GitInput(ctx context.Context, dir string, stdin []byte, op gitexec.Op) (string, error)
}
Git is what a check needs of git. *gitsync.Runner has both methods.
type Live ¶
Live is one process's reported running commit. Commit is empty for one that does not say.
type Queue ¶
type Queue struct {
Branch string `json:"branch"`
Tip string `json:"tip,omitempty"`
Hub string `json:"hub,omitempty"`
Entries []QueueEntry `json:"entries"`
// Unreported are the rooms that did not say a commit. Each is taken as exactly as far behind as the hub, so the
// list over-states what it needs and never hides a commit.
Unreported []string `json:"unreported,omitempty"`
Error string `json:"error,omitempty"`
Line string `json:"line"`
}
Queue is the whole answer.
type QueueEntry ¶
type QueueEntry struct {
SHA string `json:"sha"`
Short string `json:"short"`
Subject string `json:"subject"`
// Item is the backlog item the commit's changelog entry names. Empty when the commit has none.
Item string `json:"item,omitempty"`
Needs string `json:"needs"`
// Rooms are the rooms whose running commit lacks this one. Empty when the commit needs the hub only.
Rooms []string `json:"rooms,omitempty"`
}
QueueEntry is one landed commit still waiting.
type Report ¶
type Report struct {
State string `json:"state"`
Ready bool `json:"ready"`
Branch string `json:"branch,omitempty"`
Tip string `json:"tip,omitempty"`
Installed string `json:"installed,omitempty"`
// Commits is how many commits since the installed build need a verdict.
Commits int `json:"commits"`
Blocking []Blocker `json:"blocking,omitempty"`
// Notes are things that did not stop the check but are worth seeing: a verdict that was ignored and why.
Notes []string `json:"notes,omitempty"`
Error string `json:"error,omitempty"`
// Stale means this is the last answer, handed back because a newer read is still running. Never ready to act on.
Stale bool `json:"stale,omitempty"`
CheckedAt time.Time `json:"checked_at"`
// Line is the one sentence a board puts on the button.
Line string `json:"line"`
}
Report is the answer. Ready is true only in StateReady.