Documentation
¶
Overview ¶
Package superloop is the supervisor's fixed procedure as a pure function: beekeeper's events, the roster and the tracked pull requests in, the transitions to take out. `beekeeper supervisor loop` gathers the input, runs each action through beekeeper's own commands and logs it under its key, which is what keeps a restarted loop from taking it twice.
Index ¶
- Constants
- func Detail(a Action, what string) string
- func EscalationOptions(head string) []string
- func EscalationQuestion(url, head string) string
- func EventAgent(verb, detail, by string) string
- func Filed(problem string) bool
- func IsPull(on string) bool
- func Overrides(answer string) bool
- func OwnershipOptions(team string) []string
- func OwnershipQuestion(url, team string) string
- func ParkedOn(detail string) (on, waits string)
- func Releases(answer string) bool
- func ReviewedHead(body, commit string) string
- func ReviewerName(ref string, rd int) string
- func Tracked(workers []Worker, taken []Taken, answers []Answer, desk Desk) []string
- func Verbs() []string
- func Verdict(state, body string) string
- type Action
- type Answer
- type Desk
- type Event
- type Input
- type Note
- type Pull
- type Review
- type Taken
- type Worker
Constants ¶
const ( KindReview = "review" KindGo = "go" KindForward = "forward" KindEscalate = "escalate" // KindAnswer tells the worker the person's answer to an escalation // that did not release the pull request. KindAnswer = "answer" // KindDone takes an agent off the roster: one that reported done, or // one the loop retires (a reviewer whose verdict it acted on, the // worker of a pull request it gave the go for that merged). KindDone = "done" KindNext = "next" KindRelease = "release" KindClassify = "classify" KindQuestion = "question" // KindFile hands the problems a done report found and filed nowhere // to the guide's queue, to file in their owning repository. KindFile = "file" // KindEnd ends the tracking of a pull request that merged or closed. KindEnd = "end" // KindLeave says once why the loop leaves a parked pull request alone: // outside the desk's organisations, in supervisor.ownership.never, // parked before the loop's first start, opened by somebody else, or // another team's. KindLeave = "leave" // KindRelay tells the worker parked on another team's pull request // that team's review, word for word. KindRelay = "relay" // KindOwnership asks the guide's person whether the desk takes over a // pull request whose owning team's review blocks its worker; // KindOverride records the person's answer that it does. KindOwnership = "ownership" KindOverride = "override" )
The kinds of action, each logged as "supervisor.<kind>".
const ( VerbDone = "agents.done" VerbIdle = "agents.idle" VerbReport = "agents.report" VerbProblem = "agents.problem" VerbPark = "agents.park" )
The verbs of the events the rules act on.
const ( Approved = "approved" ChangesRequested = "changes requested" )
The verdicts of a review.
const ( Open = "OPEN" Merged = "MERGED" Closed = "CLOSED" )
The states of a pull request, as gh reports them.
Variables ¶
This section is empty.
Functions ¶
func EscalationOptions ¶ added in v0.173.0
EscalationOptions are an escalation's choices: the first releases it.
func EscalationQuestion ¶
EscalationQuestion is the question an escalation asks the guide's person: the pull request, the head it names and why it waits for them.
func EventAgent ¶
EventAgent is the roster name of the agent an event of verb concerns: the name its detail opens with ("<name> done: …", "<name>: …"), which agents idle and agents park write from the roster, else by, the name of the party that logged it (its session's title, which may differ).
func Overrides ¶
Overrides reports whether the person's answer to an ownership decision overrides it. It fails closed, as Releases does: only the first option's label ("Override", its words after it or not) or a bare override does.
func OwnershipOptions ¶
OwnershipOptions are an ownership decision's choices: the first overrides it.
func OwnershipQuestion ¶
OwnershipQuestion is the question the guide's person is asked when the owning team's review of url blocks the desk's work.
func ParkedOn ¶
ParkedOn reads an agents.park detail ("<name>: parked on <on>: <waits>" or "<name>: parked: <waits>"): what it is parked on and what it waits for.
func Releases ¶
Releases reports whether the person's answer to an escalation releases the pull request. It fails closed: only the first option's label ("Merge", its words after it or not) or a bare go to merge (releases) does; any other words, which may ask for fixes first, do not, and go to the worker word for word.
func ReviewedHead ¶
ReviewedHead is the head a review judged: the commit its body names on a "Head reviewed:" line, else the commit GitHub recorded it on.
func ReviewerName ¶
ReviewerName is the roster name of the reviewer of round rd of ref (owner/repo#n): "Review <repo> <n> r<rd>".
func Tracked ¶
Tracked are the pull requests a pass reads: every one an agent is parked on, every one the loop started a review of that it has not seen merged or closed, nor escalated without the person's answer, and every ended one whose worker waits for its retirement. None outside the desk's organisations or in its never list is read, nor one whose park is from before the loop's first start.
Types ¶
type Action ¶
type Action struct {
Key string
Kind string
Ref string // the pull request, when there is one
URL string
Agent string // the worker it concerns
Head string
Round int
// SelfHosted asks for a reviewer on no self-hosted provider.
SelfHosted bool
// Message is what the worker or the guide is told.
Message string
// Question is an escalation's or an ownership decision's question for
// the guide's person; Options an ownership decision's choices.
Question string
Options []string
// Event is the event a done, next or classify action acts on.
Event *Event
// Note is the note a question re-addresses.
Note int
// Version is the release to install.
Version string
}
Action is one transition to take.
type Answer ¶
type Answer struct {
Ref string // owner/repo#n, the answer's about
Note int
Question string // the note's question
Text string // the person's words, an option's label first
By string
At time.Time
}
Answer is a person's answer (answer.recorded) to a note the loop filed.
type Desk ¶
type Desk struct {
// Since is the loop's first start: a park from before it is no request
// for a review.
Since time.Time
// Orgs are github.allowedOrgs: outside them the loop does nothing at
// all. Empty: every owner.
Orgs []string
// Authors are the logins the desk opens its pull requests as; empty:
// anybody's.
Authors []string
// Team is the desk's team as the team files name it; empty: every
// repository in Orgs is the desk's.
Team string
// Review are the repositories (path.Match patterns over owner/name) the
// desk reviews whoever owns them; Never the ones it does no work on,
// whatever Review or an override says.
Review, Never []string
// OwnerWait is how long a worker waits for the owning team's review
// before the person is asked to override it.
OwnerWait time.Duration
// TeamsUnknown says the team files could not be read: only Review and
// the person's overrides say what is the desk's, and nothing else is
// acted on until they are read.
TeamsUnknown bool
}
Desk is whose pull requests the loop acts on: the policy every pull request passes before a review, a go, a forward or an escalation.
type Event ¶
type Event struct {
At time.Time
Verb string
Agent string // the party that logged it
Detail string
}
Event is one line of the event log the loop acts on.
type Input ¶
type Input struct {
Workers []Worker
// Pulls are the tracked pull requests (Tracked) by ref.
Pulls map[string]Pull
// Events are the log's events since the loop's first start.
Events []Event
Notes []Note
// Release is a newer release's version, "" when there is none.
Release string
// Taken are the actions already taken, oldest first.
Taken []Taken
// Rounds is supervisor.reviewRounds.
Rounds int
// Person is the guide's person.
Person string
// Answers are the answers to the notes the loop filed, oldest first.
Answers []Answer
// Desk is whose pull requests the loop acts on; Now is the pass's time.
Desk Desk
Now time.Time
}
Input is everything a pass plans from.
type Pull ¶
type Pull struct {
Ref string // owner/repo#n
URL string
State string
Head string
// Green is every check on Head concluded successfully (none is not
// green: they have not reported yet).
Green bool
Reviews []Review // oldest first
// Author is the login that opened it; Title, Branch (its head branch)
// and Files (the paths it changes, ChangedFiles of them in all, which
// gh may list only in part) are what may name a repository the desk
// does no work on.
Author, Title, Branch string
Files []string
ChangedFiles int
// Team is the team the team files say owns its repository, "" when
// none does.
Team string
}
Pull is a tracked pull request as GitHub reports it.
type Review ¶
type Review struct {
ID string
Author string
// Member is a review by a member or collaborator of the repository's
// owner: only such a review is the owning team's.
Member bool
Head string
Verdict string
Body string
At time.Time
}
Review is one review of a pull request with a verdict.
type Worker ¶
type Worker struct {
Name string
// SelfHosted is a worker whose model a self-hosted provider serves:
// its reviewer runs on none of them.
SelfHosted bool
// ParkedOn is what the agent is parked on (owner/repo#n, #12, …), ""
// when it is not parked; ParkedAt since when.
ParkedOn string
ParkedAt time.Time
// Started is a session beekeeper started: only such a one the loop
// retires; a session its person started stays.
Started bool
// Waking is an open timer that wakes the agent by name (timer add
// --wake): a park on nothing waits for it.
Waking bool
}
Worker is an agent on the roster.