suite

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 13 Imported by: 0

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

View Source
const KindGuard = "guard"

KindGuard marks a guard entry.

View Source
const KindProcedure = "procedure"

KindProcedure marks a procedure entry.

View Source
const KindRun = "run"

KindRun marks a tool-run entry.

View Source
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

func Build

func Build(env Env, verb, name, group string, run job.Run) interfaces.AnyJob

Build decorates run as the job name in group, under the component <env.Component>.<verb>.<name>; a decoration that fails to resolve becomes the job's error. Entry sources use it so every suite job is decorated the same way.

func Tools added in v0.0.20

func Tools(s types.Suite, catalog []Entry, flags []string) ([]string, error)

Tools returns, sorted and unique, the binaries the entries the flags select in s shell: what provisioning installs for the suite to run under those flags.

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.

func (Composite) Gate added in v0.0.20

func (c Composite) Gate() *gate.Gate

Gate builds the composite's gate: one phase per spec phase that builds a job, serial or parallel as the phase says.

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

func Select(s types.Suite, catalog []Entry, flags []string) ([]Entry, error)

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.

func Steps

func Steps(steps map[string]Step) []Entry

Steps returns one entry per registered step, keyed <verb>.<step> (lint.helm). A suite runs a step entry only when its Steps list names it.

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

func (g Gate) Gate() *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.

func Plan

func Plan(s types.Suite, entries []Entry) ([]PlannedPhase, error)

Plan groups entries into the suite's phases, in Phases order, dropping a phase with no entry. An entry whose group names no phase is CodeInvalidInput, so an entry can never silently not run.

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.

Jump to

Keyboard shortcuts

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