Documentation
¶
Overview ¶
Package github is the GitHub source plugin: what its binary serves through the SDK, over its own store in the state directory the host gives it.
Index ¶
- Constants
- Variables
- func PrepareNudge(ctx context.Context, h src.Host, env NudgeEnv, u sdk.Unit, raw json.RawMessage) (json.RawMessage, error)
- type BriefParts
- type Budget
- type Check
- type ChecksQuery
- type Data
- type ExploreQuery
- type NudgeEnv
- type Payload
- type PlanData
- type Plugin
- func (p *Plugin) Action(ctx context.Context, req src.ActionRequest) (json.RawMessage, error)
- func (p *Plugin) ApplyEffect(ctx context.Context, req src.EffectRequest) error
- func (p *Plugin) BriefDescribe(ctx context.Context, in src.BriefInput) (string, error)
- func (p *Plugin) BriefInput(ctx context.Context, u sdk.Unit) (src.BriefInput, error)
- func (p *Plugin) BriefRevision(ctx context.Context, u sdk.Unit) (src.BriefRevision, error)
- func (p *Plugin) BriefStale(_ context.Context, req src.BriefStaleRequest) (bool, error)
- func (p *Plugin) BriefWant(context.Context, sdk.Unit) (bool, error)
- func (p *Plugin) Checkout(ctx context.Context, u sdk.Unit) (src.Checkout, bool, error)
- func (p *Plugin) Health(context.Context) (sdk.Health, error)
- func (p *Plugin) Identity(ctx context.Context) (src.Identity, error)
- func (p *Plugin) Ingest(ctx context.Context, req src.IngestRequest) (src.IngestResult, error)
- func (p *Plugin) Landed(context.Context, src.Draft) (sdk.Unit, bool, error)
- func (p *Plugin) Locate(ctx context.Context, dir string) (sdk.Unit, bool, error)
- func (p *Plugin) Notify(ctx context.Context, units []sdk.Unit, topics []sdk.Topic) error
- func (p *Plugin) Payload(ctx context.Context, req src.PayloadRequest) (src.PayloadResult, error)
- func (p *Plugin) Place(ctx context.Context, d src.Draft) (string, error)
- func (p *Plugin) Placement(context.Context, sdk.Unit, string) (src.Placements, error)
- func (p *Plugin) Plan(ctx context.Context, u sdk.Unit, st src.RoundState) (src.Plan, error)
- func (p *Plugin) Proposals(ctx context.Context, now time.Time) ([]src.Draft, error)
- func (p *Plugin) Publish(ctx context.Context, d src.Draft) (src.Evidence, error)
- func (p *Plugin) Resolve(_ context.Context, address string) (sdk.Unit, bool, error)
- func (p *Plugin) RunCLI(ctx context.Context, req src.CLIRequest, stdout, stderr io.Writer) (int, error)
- func (p *Plugin) Start(ctx context.Context, req src.StartRequest) error
- func (p *Plugin) Stop(context.Context) error
- func (p *Plugin) Track(ctx context.Context, req src.TrackRequest) (src.Tracked, error)
- func (p *Plugin) Untrack(ctx context.Context, u sdk.Unit) error
- func (p *Plugin) Validate(ctx context.Context, d src.Draft) error
- func (p *Plugin) Verify(ctx context.Context, d src.Draft, startedAt time.Time) (src.Evidence, bool, error)
- func (p *Plugin) View(ctx context.Context, req src.ViewRequest) (json.RawMessage, error)
- func (p *Plugin) Where(ctx context.Context, d src.Draft) (string, error)
- func (p *Plugin) WriteState(context.Context, src.StateWrite) (src.Evidence, error)
- type PriorReview
Constants ¶
const ( // ActionBasics reads a pull request's basics: its answer is the // pull request as JSON. ActionBasics = "pr.basics" // ActionRefresh reads a pull request in full into the store and // reports it. ActionRefresh = "pr.refresh" // ActionAdopt takes a pull request over into the loop: the store keeps // it taken over, and the reviews its address rounds covered are // forgotten, so its triage starts from none of them. Its args are the // pull request's basics as the host read them, which the store keeps // until its next read when it holds none of it. ActionAdopt = "pr.adopt" )
The actions the host calls.
const ( EffectReviewed = "pr.reviewed" EffectAddressed = "pr.addressed" )
The effects plugin.toml declares.
const ( JobFast = "fast" JobSlow = "slow" )
The jobs plugin.toml declares, which Ingest runs.
const ( // CommandClone clones a repository: clone <owner>/<name> <path>. CommandClone = "clone" // CommandAuth checks that gh is installed and logged in; it exits // ExitNoGH when gh is not installed. CommandAuth = "auth" // CommandReviewedRepos lists the repositories of the pull requests the // viewer reviewed since a date: reviewed-repos <yyyy-mm-dd>, one // owner/name a line, once per pull request. CommandReviewedRepos = "reviewed-repos" // CommandTeams lists the viewer's teams, one org/slug a line. CommandTeams = "teams" )
const ( ViewExplore = "explore" ViewExploreRecent = "explore.recent" ViewChecks = "checks" ViewBudget = "budget" // ViewCandidate reads one pull request from GitHub as Explore shows // it, in any state; its query is a ChecksQuery. ViewCandidate = "candidate" )
The views the host asks for: a search of GitHub for Explore, the recent searches, the failed steps of a pull request's failing checks and the API's budget.
const ActionNudgePrepare = "nudge.prepare"
ActionNudgePrepare is the nudge's prepare: it refuses a nudge when nobody but the viewer is to be asked or the same wait was nudged already, and fills whom it asks into the call's inputs.
const ExitNoGH = 127
ExitNoGH is the exit of a command that found no gh to run, the shell's "command not found".
Variables ¶
var Commands = []string{CommandClone, CommandAuth, CommandReviewedRepos, CommandTeams}
Commands are the commands the plugin serves in CLI mode.
Functions ¶
func PrepareNudge ¶
func PrepareNudge(ctx context.Context, h src.Host, env NudgeEnv, u sdk.Unit, raw json.RawMessage) (json.RawMessage, error)
PrepareNudge is the nudge's prepare of u with the daemon's args, reading the unit's events and turns from h.
Types ¶
type BriefParts ¶
type BriefParts struct {
ChangedFiles int `json:"changed_files"`
Files []string `json:"files,omitempty"`
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
Issue string `json:"issue,omitempty"`
// Listed are the changed files as the prompt lists them, with their
// additions and deletions.
Listed []string `json:"listed,omitempty"`
// DiffError is why GitHub served no diff; "" with one.
DiffError string `json:"diff_error,omitempty"`
}
BriefParts are a pull request's parts of its brief input: what brief_runs.input stores, and the facts the prompt lays out besides the diff, which is the input's text.
type Budget ¶
type Budget struct {
Low bool `json:"low"`
Remaining int `json:"remaining"`
Limit int `json:"limit"`
ResetAt time.Time `json:"reset_at,omitzero"`
}
Budget is the API's GraphQL bucket, which the searches and the sweeps spend; Low says it refuses background reads.
type Check ¶
type Check struct {
Name string `json:"name"`
URL string `json:"url,omitempty"`
Summary string `json:"summary,omitempty"`
Steps []string `json:"steps,omitempty"`
}
Check is a failing check of a pull request, with the failed steps of its GitHub Actions job when they could be read.
type ChecksQuery ¶
type ChecksQuery struct {
Owner string `json:"owner"`
Repo string `json:"repo"`
Number int `json:"number"`
}
ChecksQuery names the pull request a view reads.
type Data ¶
type Data struct {
PR pr.PR `json:"pr"`
Detail *store.Detail `json:"detail,omitempty"`
DetailVersion int `json:"detail_version,omitempty"`
DetailReadAt time.Time `json:"detail_read_at,omitzero"`
Tracked bool `json:"tracked,omitempty"`
// Row is the source part of the pull request's row payload.
Row *row.Payload `json:"row,omitempty"`
// Adopted says the pull request is taken over into the loop.
Adopted bool `json:"adopted,omitempty"`
// Plan is the planner's part.
Plan *PlanData `json:"plan,omitempty"`
}
Data is a pull request's snapshot data: its row, its detail and whether the user tracks it.
type ExploreQuery ¶
type ExploreQuery struct {
Query string `json:"query"`
}
ExploreQuery is what Explore asks for.
type NudgeEnv ¶
NudgeEnv is what the nudge's prepare reads besides the host: the viewer, who a nudge never mentions, the time and the profile's texts.
type Payload ¶
type Payload struct {
URL, Owner, Repo string
Number int
Title, Author string
State string
Association string
Head, Base string
Labels []string
CrossRepository bool
Visibility string
Prior *PriorReview
ReviewRequested bool
LastReviewVerdict string
}
Payload is the data a turn's templates read of a pull request, under the payload root plugin.toml names: its basics as GitHub reads them now and your prior review, anchored to the head the loop's last record covered.
type PlanData ¶
PlanData is the planner's part of a pull request's snapshot data: where its rounds rank and what the board reads of its workspaces.
type Plugin ¶
type Plugin struct {
// GH nil is gh on the PATH.
GH gh.Runner
// API are the API client's options; the zero value is GitHub's API at
// the host gh names, with gh's token. The plugin sets its meter and
// user agent.
API api.Options
// Now nil is the clock.
Now func() time.Time
// Git nil reads the checkouts with the git binary.
Git plan.Git
// contains filtered or unexported fields
}
Plugin is the GitHub source plugin as the SDK serves it.
func (*Plugin) Action ¶
func (p *Plugin) Action(ctx context.Context, req src.ActionRequest) (json.RawMessage, error)
Action runs one of the actions the host calls.
func (*Plugin) ApplyEffect ¶
ApplyEffect applies an effect of the plugin's turns, and a draft's pr.nudged, which the publisher recorded as it posted.
func (*Plugin) BriefDescribe ¶
BriefDescribe is in, one line, as the prompt's header names it.
func (*Plugin) BriefInput ¶
BriefInput reads what a brief of a pull request reads now: its title, description, first closing issue and changed files, then its diff, under the priority the host's call carries.
func (*Plugin) BriefRevision ¶
BriefRevision is what the stored pull request is at: its head and its description's edit time, its changed files, and the attempt key the brief runs have stored since version 4.
func (*Plugin) BriefStale ¶
BriefStale is the queue's rule: a failed attempt is due when the pull request moved or its backoff passed, a brief when the pull request moved: its description edited a quiet while ago, or a head that added more than a few files.
func (*Plugin) BriefWant ¶
BriefWant is false: the host's queue writes a pull request's brief, not the plugin.
func (*Plugin) Checkout ¶
Checkout is the repository, head and base a pull request's work checks out, as the store last read them.
func (*Plugin) Health ¶
Health is loading until the store is open and every stored pull request was reported.
func (*Plugin) Identity ¶
Identity is the viewer: the login the store keeps, else the one GitHub's API names once started, or gh in CLI mode, which the store then keeps; and the scope teams the viewer is in.
func (*Plugin) Ingest ¶
func (p *Plugin) Ingest(ctx context.Context, req src.IngestRequest) (src.IngestResult, error)
Ingest runs one of the manifest's jobs, then reports what it changed.
func (*Plugin) Locate ¶
Locate is the pull request of the branch the checkout at dir has, as gh reads it.
func (*Plugin) Notify ¶
Notify links the workspaces again when the host's listing moved, reads the configuration again when it changed, and reports again the pull requests whose rows read what changed: their events and turns, the viewer, the configuration.
func (*Plugin) Payload ¶
func (p *Plugin) Payload(ctx context.Context, req src.PayloadRequest) (src.PayloadResult, error)
Payload is a pull request as a turn reads it.
func (*Plugin) Placement ¶
Placement is where a pull request's work runs: the plugin names none, and the host's workspaces place it.
func (*Plugin) Plan ¶
Plan is the rounds the planner plans on u over st, the host's round state of u: each with the marks the host writes when it sends or skips it.
func (*Plugin) Proposals ¶
Proposals are the github-nudge rule's drafts: one per stalled open pull request whose nudge would go now. None before the store knows the viewer.
func (*Plugin) RunCLI ¶
func (p *Plugin) RunCLI(ctx context.Context, req src.CLIRequest, stdout, stderr io.Writer) (int, error)
RunCLI runs one of the commands plugin.toml declares, with gh.
func (*Plugin) Start ¶
Start opens the plugin's store in its state directory, importing what the host exported once, and reports every stored pull request; the plugin is loading until it has.
func (*Plugin) Track ¶
Track reads a pull request in full and follows it once the host, which admitted the read, asks to.
func (*Plugin) View ¶
func (p *Plugin) View(ctx context.Context, req src.ViewRequest) (json.RawMessage, error)
View serves one of the plugin's views.
func (*Plugin) WriteState ¶
type PriorReview ¶
PriorReview is your latest submitted review: the head it covered, when, its newest verdict that is not a comment, and whether you stand behind the loop's record of it.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package github reads pull requests over GitHub's HTTPS API, batching every pull request of a sweep into aliased GraphQL queries.
|
Package github reads pull requests over GitHub's HTTPS API, batching every pull request of a sweep into aliased GraphQL queries. |
|
apitest
Package apitest serves an api.Client from gh fakes, as the plugin's tests write them, and records what it meters.
|
Package apitest serves an api.Client from gh fakes, as the plugin's tests write them, and records what it meters. |
|
Package change holds the rules that decide what a change to a pull request calls for: a follow-up, a triage round, a board move.
|
Package change holds the rules that decide what a change to a pull request calls for: a follow-up, a triage round, a board move. |
|
cmd
|
|
|
wloop-plugin-github
command
Command wloop-plugin-github is the GitHub source plugin's binary, which the host runs as a child process.
|
Command wloop-plugin-github is the GitHub source plugin's binary, which the host runs as a child process. |
|
Package collect keeps the plugin's store in step with GitHub: a cheap fast sweep that reads only what changed and a slow sweep that rebuilds the scope and catches what the searches no longer return.
|
Package collect keeps the plugin's store in step with GitHub: a cheap fast sweep that reads only what changed and a slow sweep that rebuilds the scope and catches what the searches no longer return. |
|
Package explore turns what the user types in Explore into one GitHub search for open pull requests to help on.
|
Package explore turns what the user types in Explore into one GitHub search for open pull requests to help on. |
|
Package gh shells out to the gh command line, which owns GitHub's authentication.
|
Package gh shells out to the gh command line, which owns GitHub's authentication. |
|
Package git reads local checkouts with the git binary, as the planner asks.
|
Package git reads local checkouts with the git binary, as the planner asks. |
|
Package nudge is the GitHub plugin's nudge: whom a nudge asks on a pull request, when it refuses, and the nudge drafts its github-nudge rule proposes on stalled pull requests.
|
Package nudge is the GitHub plugin's nudge: whom a nudge asks on a pull request, when it refuses, and the nudge drafts its github-nudge rule proposes on stalled pull requests. |
|
Package plan is the GitHub plugin's round planner: over the plugin's pull requests and the host's round state, books, events and workspaces, it decides which automatic rounds are due, why, and what each covers.
|
Package plan is the GitHub plugin's round planner: over the plugin's pull requests and the host's round state, books, events and workspaces, it decides which automatic rounds are due, why, and what each covers. |
|
Package pr is the GitHub plugin's pull request: its reference and the row the plugin's store keeps of it.
|
Package pr is the GitHub plugin's pull request: its reference and the row the plugin's store keeps of it. |
|
Package publish posts the GitHub plugin's approved drafts as issue comments on their pull request.
|
Package publish posts the GitHub plugin's approved drafts as issue comments on their pull request. |
|
Package row derives what the plugin reports of a pull request from the pull request and its events alone: its situation, the source part of its row's payload, its views and facets, its card, its items, its link signals and its workflow facts.
|
Package row derives what the plugin reports of a pull request from the pull request and its events alone: its situation, the source part of its row's payload, its views and facets, its card, its items, its link signals and its workflow facts. |
|
Package scope turns the configured sources into the people, teams and repositories the inventory follows, and the searches that find them.
|
Package scope turns the configured sources into the people, teams and repositories the inventory follows, and the searches that find them. |
|
Package situation derives who a pull request is waiting on, and since when, from the pull request and its events alone.
|
Package situation derives who a pull request is waiting on, and since when, from the pull request and its events alone. |
|
Package store is the GitHub plugin's own database, in the state directory the host gives it: the pull requests it reads, their sightings and details, the workspaces' fetches, its meta values and the overrides it keeps of what the user set.
|
Package store is the GitHub plugin's own database, in the state directory the host gives it: the pull requests it reads, their sightings and details, the workspaces' fetches, its meta values and the overrides it keeps of what the user set. |
|
Package workday counts time in working days, Monday to Friday, as the host counts a working-days value.
|
Package workday counts time in working days, Monday to Friday, as the host counts a working-days value. |