buildrunner

package
v0.3.0-20260805044113-... Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 4 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.

Backends

  • fake: local-development backend; every build succeeds unless a head change URI carries a failure marker (see fake package doc).
  • githubactions: proof-of-architecture backend that dispatches a GitHub Actions workflow. See githubactions/README.md for the workflow inputs and example orchestrator environment variables.
  • buildkite: Buildkite-backed backend. Its HTTP client and Buildkite-specific facts (state vocabulary, metadata env-var round-trip) live in platform/extension/buildrunner/buildkite, shared with stovepipe's own Buildkite backend.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveBatches

func ResolveBatches(ctx context.Context, resolver changeset.Resolver, batches []entity.Batch) ([]change.Change, error)

ResolveBatches resolves each batch's changes through the resolver and concatenates them in order. It is shared by BuildRunner implementations that need a flat change list (e.g. the base, assembled from several dependency batches) so the per-batch resolution loop is not duplicated per backend.

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 is the dependency batches (an assumed-good prefix); head is the
	// batch being verified. The runner resolves each batch's changes itself
	// through an injected changeset resolver. Keeping base and head as
	// separate batch inputs 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.
	//
	// The runner is already bound to its queue's job configuration by the
	// Factory that built it. Returns an error if the request is invalid.
	Trigger(
		ctx context.Context,
		base []entity.Batch,
		head entity.Batch,
		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.

type Config

type Config struct {
	// QueueName identifies the queue this BuildRunner serves.
	QueueName string
}

Config carries the per-queue identity handed to a Factory. The system knows only the queue name; everything an implementation needs (endpoint, pipeline, credentials) is injected at construction by the integrator.

type Factory

type Factory interface {
	// For returns the BuildRunner for the given queue.
	For(cfg Config) (BuildRunner, error)
}

Factory builds the BuildRunner for a queue. Implementations are provided by integrators (and tests) and inject whatever they need at construction.

Directories

Path Synopsis
Package buildkite implements buildrunner.BuildRunner backed by the Buildkite CI platform.
Package buildkite implements buildrunner.BuildRunner backed by the Buildkite CI platform.
Package fake provides a buildrunner.BuildRunner whose outcome is driven by the triggered changes.
Package fake provides a buildrunner.BuildRunner whose outcome is driven by the triggered changes.
Package githubactions implements buildrunner.BuildRunner backed by GitHub Actions workflow_dispatch.
Package githubactions implements buildrunner.BuildRunner backed by GitHub Actions workflow_dispatch.
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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