runner

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package runner is `ward runner`: a check runner that serves the hook of the runner protocol, fetches the exact tree, runs the argv of the check in a sandbox and posts the result to ward.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckoutConfig added in v0.6.0

type CheckoutConfig struct {
	Warm       warm.Config
	MotteURL   string
	EventsFile string
	SyncEvery  time.Duration
}

CheckoutConfig is the setting of the warm checkouts (see package warm).

type Config

type Config struct {
	Listen      string
	Options     Options
	SandboxKind string
	// Pull is true when the runner polls ward for leases and serves no hook.
	Pull bool
	// Checkouts is the setting of the warm checkouts, or nil when WARD_RUNNER_CHECKOUT_DIR is unset.
	Checkouts *CheckoutConfig
}

Config is the configuration of `ward runner`, read from the environment.

func Load

func Load(getenv func(string) string) (Config, error)

Load reads the configuration from getenv and builds the runner options. SandboxKind is gvisor, container or auto. With auto the runner uses gVisor when runsc is on the path and a plain container otherwise.

func (*Config) StartCheckouts added in v0.6.0

func (c *Config) StartCheckouts(ctx context.Context, log *slog.Logger) (wait func(), err error)

StartCheckouts makes the warm fetcher the tree source of c.Options, with the old Fetch as its fallback, and runs its watchers until ctx ends. The returned function waits for them. It does nothing when the checkouts are off.

type MotteFetcher

type MotteFetcher struct {
	URL   string
	Grant func(ctx context.Context) (string, error)
}

MotteFetcher reads trees from motte with a read grant. Grant returns the grant text for each call, so a rotated grant applies at once.

func (MotteFetcher) Fetch

func (m MotteFetcher) Fetch(ctx context.Context, req runnerproto.Request, dir string) error

Fetch writes the files of req.Tree to dir. It reads the commit first and refuses a commit whose tree is another tree.

type Options

type Options struct {
	WardURL string
	// Secret returns the key of the request signature. The runner calls it for each request, so a rotated key applies at once.
	Secret func() ([]byte, error)
	// Token returns a check token for repo.
	Token func(repo string, exp time.Time) (string, error)
	// Fetch writes the files of req.Tree into dir. It must not follow a link that the tree holds.
	Fetch   func(ctx context.Context, req runnerproto.Request, dir string) error
	Sandbox sandbox.Sandbox
	// Concurrency is the most runs at one time. A request over the limit gets 503, and ward sends it again.
	Concurrency int
	WorkDir     string
	// CacheDir is the root of the durable caches. Each repository and env gets a directory under it, so a check sees only
	// the cache of its own repository. Empty means no cache.
	CacheDir string
	// Isolation is the sandbox level that Pull reports to ward, and RunnerToken returns a runner token. Only Pull uses them.
	Isolation   runnerproto.Isolation
	RunnerToken func(exp time.Time) (string, error)
	Clock       check.Clock
	Log         *slog.Logger
	HTTP        *http.Client
}

Options are the parts of a Runner. Every field except Clock, Log, HTTP and WorkDir is required.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner serves the hook. Start it before the first request.

func New

func New(ctx context.Context, o Options) *Runner

New returns a runner. The runs stop when ctx ends.

func (*Runner) Pull

func (r *Runner) Pull(ctx context.Context)

Pull polls ward for leases until ctx ends. It holds at most Concurrency leases. It dials out only, so the runner needs no inbound network. Each lease runs one check, and the runner renews the lease until the check ends.

func (*Runner) ServeHTTP

func (r *Runner) ServeHTTP(w http.ResponseWriter, hr *http.Request)

func (*Runner) Wait

func (r *Runner) Wait()

Wait returns when every run has ended. Call it after the context of New ends.

Directories

Path Synopsis
Package fakerunner is the minimal implementation of runnerproto.Runner for tests.
Package fakerunner is the minimal implementation of runnerproto.Runner for tests.
Package install prepares a Linux host to run `ward runner` in pull mode.
Package install prepares a Linux host to run `ward runner` in pull mode.
Package sandbox is the seam between a check runner and the place where check code runs.
Package sandbox is the seam between a check runner and the place where check code runs.
container
Package container runs a check in an OCI container through the command line of an engine such as docker or podman.
Package container runs a check in an OCI container through the command line of an engine such as docker or podman.
fake
Package fake is the minimal implementation of sandbox.Sandbox for tests.
Package fake is the minimal implementation of sandbox.Sandbox for tests.
gvisor
Package gvisor runs a check in an OCI container under the gVisor runtime runsc, through a container engine.
Package gvisor runs a check in an OCI container under the gVisor runtime runsc, through a container engine.
sandboxtest
Package sandboxtest is the conformance suite of sandbox.Sandbox.
Package sandboxtest is the conformance suite of sandbox.Sandbox.
Package warm serves the tree of a check from a local bare clone of the repository.
Package warm serves the tree of a check from a local bare clone of the repository.
motteevents
Package motteevents is a warm.Watcher that polls the ref events of motte.
Package motteevents is a warm.Watcher that polls the ref events of motte.
periodic
Package periodic is the fallback warm.Watcher: it reports every known repository as changed at a fixed interval.
Package periodic is the fallback warm.Watcher: it reports every known repository as changed at a fixed interval.
warmtest
Package warmtest is the conformance suite of warm.Watcher.
Package warmtest is the conformance suite of warm.Watcher.

Jump to

Keyboard shortcuts

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