buildrunner

package
v0.1.0-dev7 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

README

Build Runner

Pluggable abstraction for triggering builds against an external Build Runner, querying their status, and cancelling them.

See doc/rfc/submitqueue/build-runner.md for the contract and design rationale. See build_runner.go for the interface itself.

Adding a new backend

  1. Create extension/buildrunner/{backend}/ with a BuildRunner implementation bound to its runner configuration at construction.
  2. Map the base and head change slices onto the backend's build primitives (apply base, apply head, validate the result).
  3. Map the runner's lifecycle states down to the BuildStatus values: Accepted (accepted for execution), Running (executing), and the terminal Succeeded / Failed / Cancelled.
  4. Implement internal reconnect / retry so transient failures surface as plain errors without blocking the caller.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildRunner

type BuildRunner interface {
	// Trigger submits a build that applies base then head, in order, on top
	// of the queue's target branch and validates the resulting tree.
	// Validation is implicit and holistic — it is what the runner does
	// after applying everything, not a per-change action.
	//
	// base contains changes from the dependency batches (an assumed-good
	// prefix). head contains changes from the batch being verified.
	// Splitting them lets a runner cache or short-circuit the base when
	// it has validated the same prefix before, and lets it attribute
	// terminal failure to base vs head in BuildMetadata.
	//
	// metadata carries free-form caller-supplied attributes (e.g. requester,
	// ticket ID, trace ID) that the runner MAY persist or echo back via
	// Status. Implementations MUST NOT depend on any specific key; nil is
	// equivalent to an empty map.
	//
	// Trigger MUST return promptly; runner-side work happens
	// asynchronously. Callers learn the build's progress via Status, not
	// via Trigger.
	//
	// queueName selects the runner-specific job configuration.
	// Returns an error if the request is invalid.
	Trigger(
		ctx context.Context,
		queueName string,
		base []entity.Change,
		head []entity.Change,
		metadata entity.BuildMetadata,
	) (buildID entity.BuildID, err error)

	// Status returns the current status and runner-defined metadata
	// (build URL, duration, etc.) for a build. Unlike Trigger, Status MAY be
	// synchronous and lengthy — a runner round trip is typical.
	//
	// Returns an error if the build does not exist.
	Status(
		ctx context.Context,
		buildID entity.BuildID,
	) (entity.BuildStatus, entity.BuildMetadata, error)

	// Cancel requests cancellation and returns once the request has reached
	// the runner; it does not wait for the build to actually stop. A no-op
	// on already-terminal builds. Returns an error if the build does not exist.
	Cancel(ctx context.Context, buildID entity.BuildID) error
}

BuildRunner triggers builds against an external Build Runner, queries their status, and cancels them.

Implementations are long-lived singletons and must:

  • make every method safe for concurrent use by multiple goroutines;
  • recover from transient connectivity failures internally, returning plain errors during the recovery window rather than blocking the caller indefinitely;
  • keep only transient local state (caches, pools) — anything that must survive a restart belongs in Storage;
  • return plain errors and leave classification (user vs infra, retryable or not) to the calling controller, per core/errs.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
Package noop provides a buildrunner.BuildRunner that performs no real work: every triggered build immediately succeeds.
Package noop provides a buildrunner.BuildRunner that performs no real work: every triggered build immediately succeeds.

Jump to

Keyboard shortcuts

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