process

package
v0.25.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

type ActionSet map[Action]bool

ActionSet is the subset of actions one sweep performs.

func ParseActions added in v0.12.0

func ParseActions(csv string) (ActionSet, error)

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) Has added in v0.12.0

func (s ActionSet) Has(a Action) bool

Has reports whether the set performs the action. A nil set performs every action, so a zero Processor behaves like a full sweep.

func (ActionSet) String added in v0.12.0

func (s ActionSet) String() string

String renders the set in execution order.

type AppWriteAccess added in v0.19.2

type AppWriteAccess func(ctx context.Context, owner, repo string) (bool, error)

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 NewProcessor(client *github.Client, dryRun bool, mergeAutoMerge bool, login string) *Processor

func (*Processor) ProcessPR

func (p *Processor) ProcessPR(ctx context.Context, info pr.PRInfo, status *pr.PRStatus, idx int)

func (*Processor) Revisit added in v0.23.0

func (p *Processor) Revisit(ctx context.Context, status *pr.PRStatus)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL