process

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 18 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 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.

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)

Jump to

Keyboard shortcuts

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