Documentation
¶
Overview ¶
Package suite builds the gate of a suite-backed command from data: a types.Suite selects entries of a catalog (tool runs, guards, procedures and registered steps) by flag, and runs one decorated job per entry in the suite's phases.
Index ¶
- Constants
- func Build(env Env, verb, name, group string, run job.Run) interfaces.AnyJob
- func Tools(s types.Suite, catalog []Entry, flags []string) ([]string, error)
- type Composite
- type Entry
- func Guards(gs []interfaces.Guard, cb interfaces.Codebase) []Entry
- func Procedures(eng interfaces.ProcedureRunner, procs []types.Procedure, verb string, ...) []Entry
- func Runs(tools interfaces.ToolRunner, cb interfaces.Codebase, runs []types.ToolRun) []Entry
- func Select(s types.Suite, catalog []Entry, flags []string) ([]Entry, error)
- func Steps(steps map[string]Step) []Entry
- type Env
- type Gate
- type PlannedPhase
- type Step
- type StepEnv
Constants ¶
const KindGuard = "guard"
KindGuard marks a guard entry.
const KindProcedure = "procedure"
KindProcedure marks a procedure entry.
const KindRun = "run"
KindRun marks a tool-run entry.
const KindStep = "step"
KindStep marks a registered-step entry: the suite runs it only when its Steps list names it.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Composite ¶ added in v0.0.20
type Composite struct {
// Obs receives the gate's progress (may be nil).
Obs interfaces.ExecutionObserver
// Suites builds a suite reference's jobs: the product's suite gate under the
// reference's flags, selection and strictness. A nil Suites makes every reference
// one failing job.
Suites func(ref types.SuiteRef) []interfaces.AnyJob
// Jobs maps the names a phase's Jobs may carry to their builders; a builder
// returning nil withholds its job (a phase the run's options skip). An unknown name
// is one failing job, so a typo in the data fails the gate rather than dropping a
// check.
Jobs map[string]func() interfaces.AnyJob
// Decs decorates the gate.
Decs decorate.Decorations
// Spec is the composite definition.
Spec types.Composite
}
Composite composes a gate from a types.Composite: each phase's suites' jobs (Suites builds them per reference) then its named jobs (Jobs builds them), in the spec's order. A product's preflight is one Composite per level, so its phase order, the suites each level unions and the flags they run under are data.
type Entry ¶
type Entry struct {
// Job builds the entry's job under env.
Job func(env Env) interfaces.AnyJob
// Name identifies the entry; selections match it.
Name string
// Verb is the command that owns the entry (lint, check); selections match it.
Verb string
// Group is the phase the entry runs in.
Group string
// Kind is the entry's source (run, guard, procedure, step).
Kind string
// Tags are the labels selections match.
Tags []string
// Tools are the binaries the entry shells (a run's tool, a guard's, a step's).
Tools []string
}
Entry is one catalog item a suite can select.
func Guards ¶
func Guards(gs []interfaces.Guard, cb interfaces.Codebase) []Entry
Guards returns one entry per guard, each run over cb as one step: a failing verdict's findings, one per line, are the step's error and its detail the verdict's. Under strict run options a skipped guard (its tool absent) fails; a cached skip never does.
func Procedures ¶
func Procedures( eng interfaces.ProcedureRunner, procs []types.Procedure, verb string, input map[string]any, ) []Entry
Procedures returns one entry per procedure, run by eng with input; verb is the command that owns them. A procedure's group is its Group, else its Name.
func Runs ¶
func Runs( tools interfaces.ToolRunner, cb interfaces.Codebase, runs []types.ToolRun, ) []Entry
Runs returns one entry per tool-run row, run by tools over cb. A row's group is its Group, else its Verb; a tool-runner error is one failed step named after the row, so a row that cannot run fails its own step instead of the gate.
func Select ¶
Select returns the catalog entries the flags select, in catalog order: the union of the set selector flags (the suite's Select when none is set), narrowed by every set modifier flag, without the entries whose gated tag's flag is unset, and without the step entries the suite's Steps does not name. A flag the suite does not declare, or a listed step the catalog lacks, is CodeInvalidInput.
type Env ¶
type Env struct {
// Decs decorates each job.
Decs decorate.Decorations
// Snapshot memoizes per-invocation work the jobs share.
Snapshot *codebase.Snapshot
// Component prefixes each job's decoration component (<component>.<verb>.<name>).
Component string
// Opts are the run options every entry runs under.
Opts types.RunOptions
}
Env is what every entry's job is built against.
type Gate ¶
type Gate struct {
// Obs receives the gate's progress (may be nil).
Obs interfaces.ExecutionObserver
// Err is a composition failure (no such suite, no codebase): the gate is one failing
// job reporting it.
Err error
// Env is what every entry's job is built against; a nil Snapshot gets a fresh one.
Env Env
// Suite is the suite definition.
Suite types.Suite
// Catalog is every entry the suite may select.
Catalog []Entry
// Flags are the set selector and modifier flag names.
Flags []string
}
Gate composes one suite's gate.
func (Gate) Gate ¶
Gate builds the suite's gate: one job per selected entry, in phase order; a Serial phase runs its jobs one at a time. A suite that cannot be planned is one failing job.
func (Gate) Jobs ¶
func (g Gate) Jobs() []interfaces.AnyJob
Jobs returns every job of the suite's gate in phase order, for a caller that folds the suite into a phase of its own; a suite that cannot be planned is one failing job.
type PlannedPhase ¶
type PlannedPhase struct {
// Group is the phase name.
Group string
// Entries are the phase's entries, in catalog order.
Entries []Entry
// Serial runs them one at a time.
Serial bool
}
PlannedPhase is a suite phase with the selected entries it runs.
type Step ¶
type Step struct {
// Run is the step's work.
Run func(ctx context.Context, env StepEnv) (types.StepResults, error)
// Group is the phase the step runs in.
Group string
// Tags are matched against the suite's selection like a row's.
Tags []string
// Tools are the binaries the step shells, for provisioning.
Tools []string
}
Step is Go work a suite runs beside its rows, selected like a row by its verb (the prefix of its name before the first dot) and tags.
type StepEnv ¶
type StepEnv struct {
// Runner runs the step's commands (the gate's runner).
Runner interfaces.CommandRunner
// Env is the suite environment.
Env
// Root is the repository root (the gate's root).
Root string
}
StepEnv is what a registered step runs against.