run

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 17 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 run plans a run, collects through connectors, decides verdicts and applies the safeguard state rule.

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.0.1"

Version is set at build time.

Functions

func ApplyState

func ApplyState(o *Outcome, prev *tag.Tag, retired *config.Retired)

ApplyState works out state and what changed from the previous tag. A waiver that just expired on an open safeguard counts as newly open.

func DefaultPhaseTwo

func DefaultPhaseTwo() map[string]bool

DefaultPhaseTwo names the connectors that depend on hosts from others.

func ExitCode

func ExitCode(all []*Outcome, failOn string) int

ExitCode applies the exit rules. failOn is "", "open" or "any".

func SortOutcomes

func SortOutcomes(all []*Outcome)

SortOutcomes orders outcomes by drill and target.

func SortedKeys

func SortedKeys[V any](m map[string]V) []string

SortedKeys returns a map's keys in order.

func TestDir

func TestDir(dir string) (results map[string][]CaseResult, problems map[string]string, err error)

TestDir runs every drill under dir that has a fixtures file, and reports the drills that have none.

func TestPath

func TestPath(drillFile string) string

TestPath returns the fixtures file for a drill file.

Types

type Attention

type Attention struct {
	NewlyOpen        []*Outcome
	NewlyClosed      []*Outcome
	OpenUnverified   []*Outcome
	ClosedUnverified []*Outcome
}

Attention is what leads every output.

func BuildAttention

func BuildAttention(all []*Outcome) Attention

BuildAttention groups outcomes by what changed.

type CaseResult

type CaseResult struct {
	Name, Expect, Got, Reason string
}

CaseResult is one case's outcome.

func RunTests

func RunTests(d *drill.Drill, data []byte) ([]CaseResult, error)

RunTests runs a drill's fixtures. It fails a file that lacks a passing, a failing or a not-applicable case.

func (CaseResult) OK

func (c CaseResult) OK() bool

OK reports whether the case gave the expected verdict.

type Config

type Config struct {
	Project    *config.Project
	Drills     []*drill.Drill
	Connectors []connector.Connector
	Scope      connector.Scope
	Stream     string // local or ci
	RanBy      string
	Records    string // directory holding tags/ and snapshots/
	// WriteRecords is false in a public repo, where only counts may be printed.
	WriteRecords bool
	DryRun       bool
	PhaseTwo     map[string]bool // connectors that read what others wrote
}

Config is one run's inputs.

type Options

type Options struct {
	Now       time.Time
	Available map[string]bool // connectors that can run
	Failures  map[string]string
	Waivers   []config.Waiver
	// Fixture, when set, answers every fetch from these values by alias instead
	// of the graph. It is how drill test files run.
	Fixture map[string]facts.Result
	// Record, when set, receives each fetched fact result by alias.
	Record func(alias string, r facts.Result)
}

Options controls decisions.

type Outcome

type Outcome struct {
	Drill       *drill.Drill
	Target      string
	TargetAttrs map[string]any
	Verdict     string
	Reason      string
	Conditions  []tag.Condition
	Facts       map[string]any
	Read        []graph.ID
	Sources     map[string]string
	Waived      bool
	Waivers     []config.Waiver
	WaivedParts int
	Owner       string
	Prev        string
	State       string
	NewlyOpen   bool
	NewlyClosed bool
	Unverified  string
	Retired     string
}

Outcome is one verdict on one target.

func Decide

func Decide(d *drill.Drill, g graph.Reader, o Options) []*Outcome

Decide evaluates one drill across its targets.

func DecideFixture

func DecideFixture(d *drill.Drill, c TestCase) *Outcome

DecideFixture decides one drill on one target from fixture values.

type Result

type Result struct {
	Outcomes  []*Outcome
	Attention Attention
	Skips     []Skip
	Graph     *graph.Graph
	Calls     []string // printed by --dry-run
	Fatal     string
	Stream    string
	Available map[string]bool
	Failures  map[string]string
}

Result is one run's outputs.

func Run

func Run(ctx context.Context, c Config) (*Result, error)

Run executes the steps: plan, collect, link, decide, record.

type Skip

type Skip struct {
	DrillID string
	Needs   string
}

Skip is one drill waiting for a system.

type TestCase

type TestCase struct {
	Name      string            `yaml:"name"`
	Expect    string            `yaml:"expect"`
	Target    map[string]any    `yaml:"target,omitempty"`
	Facts     map[string]any    `yaml:"facts"`
	Inspected map[string]int    `yaml:"inspected,omitempty"`
	Partial   map[string]string `yaml:"partial,omitempty"`
}

TestCase gives the fact values for one setup and the verdict they must give.

type TestFile

type TestFile struct {
	Firedrill string     `yaml:"firedrill"`
	Drill     string     `yaml:"drill"`
	Cases     []TestCase `yaml:"cases"`
}

TestFile is a drill's test fixtures, <slug>.test.yaml beside the drill.

Jump to

Keyboard shortcuts

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