Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AllActions = []Action{ActionClassify, ActionApprove, ActionMerge, ActionRefresh, ActionRetry, ActionRemedy, ActionMark}
AllActions lists every action in execution order.
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" // 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.
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
// Actions selects the steps this sweep performs. Nil performs all.
Actions ActionSet
// 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.