Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AllActions = []Action{ActionClassify, ActionChangelog, ActionApprove, ActionMerge, ActionRefresh, ActionRetry, ActionRemedy, ActionMark}
AllActions lists every action in execution order. changelog comes before approve: the entry is a commit, and a commit pushed after an approval dismisses it wherever the branch protection dismisses stale reviews.
Functions ¶
func ActionNames ¶ added in v0.12.0
func ActionNames() []string
ActionNames lists every action name in execution order.
func DefaultSecurityCheckPatterns ¶
func DefaultSecurityCheckPatterns() []string
DefaultSecurityCheckPatterns returns a fresh copy of the built-in security-check pattern list. Returning a copy guarantees that callers cannot accidentally mutate the package-level default.
func FingerprintPR ¶
func FingerprintPR(ctx context.Context, client *github.Client, owner, repo string, pullReq *github.PullRequest) pr.Fingerprint
FingerprintPR computes the content fingerprint of a PR at its current head: the title-derived change ID always, plus the patch ID from the compare diff (base...head) when GitHub delivers it in full. Fetch errors and truncated diffs leave PatchID empty and never fail the caller -- a fingerprint is corroborating evidence, not a verdict, and pr.Fingerprint falls back to the change ID on its own.
Types ¶
type Action ¶ added in v0.12.0
type Action string
Action is one step of a sweep. The steps run in the order listed and a caller may run any subset.
const ( // ActionClassify reads the PR, its checks and its markers, decides its // state and writes the classification label. It is the read half of // every other action and always runs. ActionClassify Action = "classify" // ActionApprove submits an approving review on a green eligible PR. ActionApprove Action = "approve" // ActionMerge squash-merges a green, eligible, approved PR; a PR behind // its base is brought up to date instead and merges on a later sweep. ActionMerge Action = "merge" // ActionRefresh updates the branch of a stale PR from its base. ActionRefresh Action = "refresh" // ActionRetry retries auto-cancelled CircleCI builds on the PR head. ActionRetry Action = "retry" // ActionRemedy applies the catalogue rule that matches a classified PR, // through the action the rule names and that action's guards. ActionRemedy Action = "remedy" // ActionChangelog commits the team's changelog entry to a PR that will // merge, before anything is approved. A team's policy switches it off. ActionChangelog Action = "changelog" // ActionMark writes markers and evidence comments on the PR. ActionMark Action = "mark" )
type ActionSet ¶ added in v0.12.0
ActionSet is the subset of actions one sweep performs.
func ParseActions ¶ added in v0.12.0
ParseActions reads a comma-separated action list. An empty list selects every action; an unknown name is an error naming the valid ones.
func (ActionSet) ClassifyOnly ¶ added in v0.30.1
ClassifyOnly reports whether the set performs the classify step alone. Together with a dry run that is the read: no label, no marker, no comment and no merge. A nil set performs every action, so it is never this.
type AppWriteAccess ¶ added in v0.19.2
AppWriteAccess reports whether the GitHub App installation the sweep authenticates as may write to the repository. A nil AppWriteAccess is a sweep running under a person's token, where permissions.push on the repository is the answer instead.
type Processor ¶
type Processor struct {
Client *github.Client
DryRun bool
MergeAutoMerge bool
Login string
// SecurityCheckPatterns are appended to DefaultSecurityCheckPatterns.
// The built-in list can be widened, never narrowed.
SecurityCheckPatterns []string
// MergeMaxRetries is the maximum number of merge attempts when the base
// branch is modified between fetch and merge. Zero uses the default (3).
MergeMaxRetries int
// MergeRetryWait is the base wait duration between merge retries.
// Zero uses the default (10s). Actual wait = base * attempt number.
MergeRetryWait time.Duration
// RebaseWait bounds the second pass over the PRs a merge of this sweep
// made dirty (see Revisit). Zero uses the default (3m).
RebaseWait time.Duration
// Actions selects the steps this sweep performs. Nil performs all.
Actions ActionSet
// AppWriteAccess answers the write-access guard when the sweep
// authenticates as the GitHub App. Nil is a person's token.
AppWriteAccess AppWriteAccess
// Rules is the catalogue loaded at the start of the sweep. Nil refuses
// every remedy and leaves classification, approval and merging as they
// are.
Rules *rules.Catalogue
// Remedies is the action vocabulary a rule may name. Nil refuses every
// remedy.
Remedies *remedy.Registry
// Logs reads the excerpt a rule's log signal matches against. Nil leaves
// every log signal unmatched.
Logs *logs.Fetcher
// Policies is the resolved bot PR sweep policy of the scope, read from
// the policy files before the sweep starts. Nil applies the company
// defaults of pr.CompanyDefaults.
Policies *policy.Set
// CheckTimeout bounds how long the sweep waits for pending checks on
// one PR. Zero means no wait: a PR with pending or missing required
// checks is reported as waiting and the next sweep decides.
CheckTimeout time.Duration
// CircleCI looks behind failing "ci/circleci: <job>" commit statuses to
// tell an auto-cancelled build from a real failure (see
// classifyCancelled). Nil disables the lookup and every CircleCI
// failure is taken at face value.
CircleCI *circleci.Client
// SupersededBy maps a PR to the sibling that carries a higher version of
// the same dependency (see pr.FindSuperseded). It is computed once from
// the sweep's PR list before processing starts and only read afterwards,
// so it needs no lock. A nil map supersedes nothing.
SupersededBy pr.SupersededBy
// contains filtered or unexported fields
}
Processor sweeps one PR at a time. Only PRs authored by one of the four trusted bots (see pr.KindOf) are touched; there is no way to widen that set, and the caller's own PRs are not in it.
func NewProcessor ¶
func (*Processor) Revisit ¶ added in v0.23.0
Revisit is the second pass of a sweep. It takes the PRs the sweep's own merges made dirty, waits for the bot to rebase them, and processes each one again. Without it such a PR waits for the next sweep, which is a day later, and every further PR of the repository waits behind it.
It runs after the first pass, so the rest of the sweep already paid part of the wait. RebaseWait bounds the whole pass, not each PR: the wait is for one bot to catch up, and every deferred PR waits on the same bot. A PR the bot has not rebased when the wait runs out keeps its awaiting-rebase classification, and the next sweep decides.