Documentation
¶
Index ¶
- Constants
- func BuildReport(name, description string, rs *Result, order []string, ...) *report.Report
- func Guide(topic string) (string, error)
- func GuideIndex() string
- func InstallSkill(dir string) (string, error)
- func Skill() string
- type ActionRunner
- type BufferedReporter
- type CheckOptions
- type Config
- type ErrorType
- type Executor
- type ExitStatus
- type Finding
- type GuideTopic
- type Interval
- type Iteration
- type Job
- type JobContext
- type JobResult
- type JobRun
- type NameTakenError
- type OutputMode
- type Outputs
- type PluginActionRunner
- type Printer
- func (p *Printer) AddSpinnerSuffix(txt string)
- func (p *Printer) Fprint(w io.Writer, a ...any)
- func (p *Printer) Fprintf(w io.Writer, f string, a ...any)
- func (p *Printer) Fprintln(w io.Writer, a ...any)
- func (p *Printer) LogDebug(format string, args ...any)
- func (p *Printer) LogError(format string, args ...any)
- func (p *Printer) LogWarn(format string, args ...any)
- func (p *Printer) Masker() *mask.Masker
- func (p *Printer) PrintEchoContent(content string)
- func (p *Printer) PrintError(format string, args ...any)
- func (p *Printer) PrintGivenRequest(stepIdx int, stepName string, with map[string]any)
- func (p *Printer) PrintMapData(data map[string]any)
- func (p *Printer) PrintRequestResponse(stepIdx int, stepName string, req, res map[string]any, rt string)
- func (p *Printer) PrintSeparator()
- func (p *Printer) PrintTestResult(success bool, testExpr string, context any)
- func (p *Printer) PrintVerbose(format string, args ...any)
- func (p *Printer) SetMasker(m *mask.Masker)
- func (p *Printer) StartSpinner()
- func (p *Printer) StopSpinner()
- type Probe
- type ProbeError
- func NewConfigurationError(operation, message string, cause error) *ProbeError
- func NewExecutionError(operation, message string, cause error) *ProbeError
- func NewFileError(operation, message string, cause error) *ProbeError
- func NewProbeError(errorType ErrorType, operation, message string, cause error) *ProbeError
- type Repeat
- type RepeatTestResult
- type Reporter
- type ResponseTime
- type Result
- type RunOptions
- type StandaloneOption
- func WithActionRunner(r ActionRunner) StandaloneOption
- func WithActions(names map[string]string) StandaloneOption
- func WithBuiltinActions(names []string) StandaloneOption
- func WithCleanups(c *actionrpc.Cleanups) StandaloneOption
- func WithGuard(guard actionrpc.Guard) StandaloneOption
- func WithNeedsNoCheck(names []string) StandaloneOption
- func WithRunID(id string) StandaloneOption
- type StatusType
- type Step
- type StepContext
- type StepFailure
- type StepRepeatCounter
- type StepResult
- type StepRetry
- type StreamReporter
- type Workflow
Constants ¶
const ( // SeverityError is a finding that stops the workflow from running as it // is written, or that makes a step read what is never there. SeverityError = "error" // SeverityWarning is a finding that the workflow may run with, but that // leaves it checking less than it seems to. SeverityWarning = "warning" )
Severities of a Finding.
const ( // ExitOK means every job succeeded. ExitOK = 0 // ExitTestFailed means a test did not hold: it evaluated to false, could // not be evaluated, or did not evaluate to a boolean; or a request or a // response broke the contract an action checked it against. ExitTestFailed = 1 // ExitConfigError means the workflow or the command line was wrong, a // step asked for what the guard of the run does not allow, or a report // file could not be written, so the run could not do what it was asked // to. ExitConfigError = 2 // ExitActionError means an action returned an error, such as a refused // connection or a timeout, so a test could not be checked at all. ExitActionError = 3 )
Exit codes of a probe run. They tell apart what a caller such as CI or cron has to do about a failure: a failed test points at the system under test, a configuration error at the workflow or the command line, and an action error at the environment, such as a target that cannot be reached.
const ( // DefaultMaxRepeatCount is the default upper limit for repeat count DefaultMaxRepeatCount = 10000 // DefaultMaxAttempts is the default upper limit for max attempts DefaultMaxAttempts = 10000 // EnvMaxRepeatCount is the environment variable name for overriding max repeat count EnvMaxRepeatCount = "PROBE_MAX_REPEAT_COUNT" // EnvMaxAttempts is the environment variable name for overriding max attempts EnvMaxAttempts = "PROBE_MAX_ATTEMPTS" )
const ( FailureAssertion = report.FailureAssertion FailureTestError = report.FailureTestError FailureTestType = report.FailureTestType FailureAction = report.FailureAction FailureTemplate = report.FailureTemplate FailureContractResponse = report.FailureContractResponse FailureContractRequest = report.FailureContractRequest FailureRefused = report.FailureRefused )
Failure kinds recorded on a StepFailure. They are the kinds a report carries, so they are defined there.
const ( IconSuccess = "✓ " IconError = "✗ " IconTriangle = "△ " IconCircle = "⏺" IconWait = "🕐︎" IconSkip = "⏭ " IconRetry = "⟳" )
Icon constants
const DefaultSkillDir = ".claude/skills/probe"
DefaultSkillDir is where probe skill install puts the skill when no directory is given: the project-level skills directory of Claude Code.
const ( // DefaultStepTimeout is the default timeout for action execution DefaultStepTimeout = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func BuildReport ¶
func BuildReport(name, description string, rs *Result, order []string, startedAt, finishedAt time.Time) *report.Report
BuildReport assembles a Report from the results of a run. Jobs are listed in the given order, which is the order they are declared in the workflow.
func Guide ¶
Guide returns the Markdown page for a topic. An action's page can also be asked for as actions/<name>.
func GuideIndex ¶
func GuideIndex() string
GuideIndex renders the list of topics probe guide prints without one.
func InstallSkill ¶
InstallSkill writes SKILL.md into dir, creating it, and returns the path it wrote. An existing SKILL.md is replaced, so running it again after an upgrade brings the skill up to date.
The default directory is inside the project, which the user may have checked out from anywhere, so the file is written through safefile.Replace: a symlink at SKILL.md, or at .claude or another directory on the way, cannot redirect it to a file elsewhere.
Types ¶
type ActionRunner ¶
type ActionRunner interface {
Run(name string, call actionrpc.Call, opts RunOptions) (result, newState map[string]any, err error)
}
ActionRunner runs the action of a step: the action named name, as the step writes it in uses, with what call tells it about the step and the state the action left in the job. It returns what the action returned and the state it leaves, nil to keep the one there was.
Run is called concurrently, from the steps of the jobs that run at once and of the runs of an async job, and is to return once opts.Context() is done: the step has given up on the action by then, and what Run returns after is not used. The actions that clean up once the run is over are told so by PluginActionRunner alone, so a runner of its own takes part in that only by running the action with PluginActionRunner and opts as it was given them.
type BufferedReporter ¶
type BufferedReporter struct {
// contains filtered or unexported fields
}
BufferedReporter keeps the original behaviour: a spinner during the run and the complete report at the end.
func (*BufferedReporter) Finish ¶
func (r *BufferedReporter) Finish(rs *Result)
func (*BufferedReporter) JobDone ¶
func (r *BufferedReporter) JobDone(jobID string, jr *JobResult)
func (*BufferedReporter) Start ¶
func (r *BufferedReporter) Start(name, description string)
func (*BufferedReporter) StepDone ¶
func (r *BufferedReporter) StepDone(jobID string, sr StepResult)
func (*BufferedReporter) StepStart ¶
func (r *BufferedReporter) StepStart(jobID, stepName string)
type CheckOptions ¶
type CheckOptions struct {
// Actions are the names of the actions a step may use, besides the
// external ones it names by a path or a repository. When it is empty,
// the names are not checked.
Actions []string
// Params are the keys each action takes in with, by its name. The with
// of an action it does not name, which may take any key, is not
// checked.
Params map[string][]string
// Contracts are the keys of with that ask each action to check a step
// against a contract, which checks it as a test does, by its name: as
// openapi asks the http action. A step with such a key and no test is
// not warned of as unchecked.
Contracts map[string][]string
// ReqFields and ResFields are the top-level fields of the req and the
// res each action returns, by its name, so that a test, an echo or an
// output that reads another is reported. What a step reads of the req
// or the res of an action they do not name is not checked.
ReqFields map[string][]string
ResFields map[string][]string
// ReqTypes and ResTypes are the kinds of the fields of the req and the
// res each action returns, by its name and then the field's: number,
// string, bool, map or list. An expression that does with a field what
// its kind does not allow is reported, as res.code == "200 OK" is, which
// is never true of a number. A field of another kind or none, a field
// they leave out, and a field of an action they do not name, may hold
// anything, as may every field of an external action.
ReqTypes map[string]map[string]string
ResTypes map[string]map[string]string
// WithFields are the actions whose req and res hold the keys of the
// step's with too, besides the fields they are named with, as an action
// that returns what it is given does.
WithFields []string
// NeedsNoCheck are the actions whose steps pass without a test, as
// Config.NeedsNoCheck says. A step of one that has no test is not warned
// of as unchecked.
NeedsNoCheck []string
// Required are the keys of with each action cannot run without, by its
// name, each as the keys that stand for one another, of which one is
// enough: as get stands for method in the http action.
Required map[string][][]string
// Manifest reads the action.yml of an external action, a local one
// relative to baseDir, so that its with is checked against the params
// it declares, and what a step reads of its res against the fields of
// res it declares. When it is nil, neither is checked, and nothing is
// read from the network.
Manifest func(uses, baseDir string) (*actionref.Manifest, error)
}
CheckOptions tunes Check. actions.CheckOptions gives what it is to know of the built-in actions.
type Config ¶
type Config struct {
// Warn is where what is found as the workflow is loaded, and does not
// keep it from running, is written; nil for nowhere.
Warn io.Writer
Verbose bool
// Trace, with Verbose, also shows how each action's process is
// started, called and stopped, and the records an action logs at trace
// level, for debugging an action.
Trace bool
Timing bool
// Output selects how the report is delivered while jobs run.
Output OutputMode
// Reports lists the report files written once the run has finished.
Reports []report.Target
// Baseline is the report of an earlier run, which the reports compare
// the response times of the repeated steps to; nil for none.
Baseline *report.Report
// Guard is what the run allows its actions to do, such as only reading,
// and only from some hosts. Each step's action is told it, and a step
// whose action does not keep to it is refused unless it is allowed.
Guard actionrpc.Guard
// Env are environment variables read from files, by name, for the vars
// of the workflow to read where the environment has none of the name.
// They are given to the vars alone: Probe reads none of its own
// settings from them, and the actions do not have them in their
// environment.
Env map[string]string
// Vars are values for the vars of the workflow, by name, given by the
// person running it. Each is taken as it is, in place of what the
// workflow writes for the var, and the other vars read it.
Vars map[string]string
// Actions are the names of the actions of Probe, which a workflow
// cannot give to an external action under actions. When it is empty,
// the names a workflow gives are not checked against them.
Actions []string
// Jobs narrows the run to the jobs of these ids or names, with the jobs
// they need and those that always run after them; all jobs when it is
// empty.
Jobs []string
// NeedsNoCheck are the names of the actions whose steps pass without a
// test, as those of an action that does nothing that could fail: such
// a step is there for its echo, or to publish what it is given, and is
// not counted as untested. A step of any other action that nothing
// checks is. The engine knows no action by itself: actions.Configure
// sets this and Actions for the built-in ones.
NeedsNoCheck []string
// ActionRunner runs the action of each step. When it is nil, each runs
// in a process of its own, as PluginActionRunner runs it.
ActionRunner ActionRunner
}
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor runs a job: once, or as many times as its repeat says, and then records what the runs came to on the job's result.
func NewExecutor ¶
NewExecutor returns an Executor that runs job.
func (*Executor) Run ¶ added in v1.30.0
func (e *Executor) Run(ctx JobContext) bool
Run runs the job and records its result, and reports whether it passed. A job that did not pass is the caller's to fail the workflow for.
type ExitStatus ¶
type ExitStatus int
ExitStatus represents the unified status across all actions
const ( ExitStatusSuccess ExitStatus = 0 // Action succeeded ExitStatusFailure ExitStatus = 1 // Action failed )
func (ExitStatus) Int ¶
func (e ExitStatus) Int() int
Int returns the ExitStatus as an int for comparison
func (ExitStatus) String ¶
func (e ExitStatus) String() string
String returns the ExitStatus as a string
type Finding ¶
type Finding struct {
Severity string
File string // the file it is in; empty when it cannot be told
Line int // the line it is on; 0 when it cannot be told
Where string // the job and step it is in, such as job "Users", step 1 "Create"
Message string
}
Finding is one thing Check found in a workflow.
func Check ¶
func Check(path string, opts CheckOptions) ([]Finding, error)
Check reads the workflow at path, as a run reads it, and returns what is wrong with it or weak in it, without running anything: keys a workflow does not take, what a run would refuse to load, actions that do not exist, needs that cannot be met, expressions and templates that do not parse, that read a name that is not there to read, or that do with a value what its kind does not allow, and outputs read before or without being published, as errors; and steps that nothing checks, tests that read nothing, and vars that nothing defines, as warnings.
The error it returns is for a workflow that cannot be read at all, such as a file that does not exist.
type GuideTopic ¶
type GuideTopic struct {
Name string // what to pass to probe guide
Group string // the heading it is listed under
Title string // the page's first heading
// contains filtered or unexported fields
}
GuideTopic is one page probe guide can print.
func GuideTopics ¶
func GuideTopics() []GuideTopic
GuideTopics lists every topic, references first, then one per action, then the concepts.
type Interval ¶
Interval is a duration written in a workflow, as duration.Parse reads it: a duration string such as "1m30s", or a number of seconds, which may have a fraction. It is used for the interval of a repeat or a retry, the delay before a retry and a step's timeout, and cannot be negative.
func (Interval) MarshalYAML ¶
MarshalYAML implements custom YAML marshaling for Interval
type Iteration ¶
type Iteration struct {
// Entries is the list written in the workflow.
Entries []map[string]any
// Expr is the template that gives the list, as "{{ outputs.users.rows }}".
// It is empty when the list is written in the workflow.
Expr string
}
Iteration is what a step runs once for each entry of, with the entry's keys as vars: a list written in the workflow, or a template that gives one when the step is reached, such as the cases read from a file or the rows an earlier step published.
func (Iteration) MarshalYAML ¶
MarshalYAML writes the iteration as it is written in a workflow.
type Job ¶
type Job struct {
Name string `yaml:"name" validate:"required"`
ID string `yaml:"id,omitempty"`
Needs []string `yaml:"needs,omitempty"`
// Always runs the job once the jobs it needs are over, whether or not
// they succeeded, as a job that removes what they made has to.
Always bool `yaml:"always,omitempty"`
Steps []*Step `yaml:"steps" validate:"required"`
// FailFast skips the steps after one that failed, as steps that only
// work on what an earlier one made would fail for its reason.
FailFast bool `yaml:"fail_fast,omitempty"`
Repeat *Repeat `yaml:"repeat"`
Defaults any `yaml:"defaults"`
SkipIf string `yaml:"skipif,omitempty"`
}
func ReadJobFile ¶ added in v1.30.0
ReadJobFile reads the job file at path, as the embedded action runs it: by names, the names the workflow that embeds it gives its external actions, and with the job's defaults applied to its steps. A nil names reads each uses as it is written.
func (*Job) ApplyDefaults ¶
func (j *Job) ApplyDefaults()
ApplyDefaults merges the job's defaults into the with of every step that uses the action they are keyed by. A value the step sets itself wins, and nested objects are merged key by key.
func (*Job) RunStandalone ¶
func (j *Job) RunStandalone(vars map[string]any, printer *Printer, jobID, baseDir string, opts ...StandaloneOption) JobRun
RunStandalone runs the job outside a workflow, as an embedded job is run. A local action is resolved relative to baseDir, the directory of the file the job comes from, or to the working directory when baseDir is empty.
func (*Job) UseActions ¶
UseActions reads the job by names, the names a workflow gives its external actions: a uses or a key of the defaults that is one of them becomes the action it stands for. The embedded action does so for the job it runs, with the names of the workflow that embeds it, before ApplyDefaults.
type JobContext ¶
type JobContext struct {
Vars map[string]any `expr:"vars"`
// Outputs are those the run reads and writes (accessible via expressions
// as "outputs"): the workflow's, or a store of the run's own in front of
// them for a run that overlaps others.
Outputs *Outputs `expr:"outputs"`
Failed bool
// Current job ID for this context
CurrentJobID string
// RepeatCurrent is the index of the run, from 0, warmup runs included.
RepeatCurrent int
// contains filtered or unexported fields
}
JobContext is what a run of a job runs with. It is copied for each run, and holds by value only what is the run's own; what the jobs of the workflow share is in runEnv, and what the runs of a repeated job share in jobRepeat, which a copy points to as the context it was copied from does.
func (*JobContext) SetFailed ¶
func (j *JobContext) SetFailed()
SetFailed marks the job context as failed
type JobResult ¶
type JobResult struct {
JobName string
JobID string
// Status is how the job ended: StatusSuccess, StatusError or
// StatusSkipped, which a job skipped by its skipif or by a job it needs
// is. It is StatusSuccess while the job runs.
Status StatusType
StartTime time.Time
EndTime time.Time
StepResults []StepResult // Store all step results for this job
// RepeatTest is the outcome of the test of a repeated job over its
// runs; nil when it has none.
RepeatTest *RepeatTestResult
// BaselineTest is the outcome of the test of a repeated job against the
// run compared to; nil when it has none.
BaselineTest *RepeatTestResult
// contains filtered or unexported fields
}
JobResult stores execution results for a job
type JobRun ¶
type JobRun struct {
// Success is true when every step passed or the job was skipped.
Success bool
// Outputs are the outputs the job's steps published.
Outputs map[string]any
// Report is the report of the job's steps.
Report string
// Err is set when the job could not run as it was written, such as when
// a step is invalid or an action cannot be resolved. A step that fails
// leaves it nil and Success false.
Err error
// Refused is set when the guard the job ran under refused a step, the
// first one, so that the step that embeds the job is refused as well
// rather than failing as a job whose test was false.
Refused *actionrpc.Refused
// Duration is how long the job took.
Duration time.Duration
}
JobRun is the outcome of a job run on its own with RunStandalone.
type NameTakenError ¶
type NameTakenError struct {
// contains filtered or unexported fields
}
NameTakenError reports an output whose name was taken before it was published, so that outputs.<name> holds something else. It is a warning: the step's value is kept under its id when that can be.
func (*NameTakenError) Error ¶
func (e *NameTakenError) Error() string
type OutputMode ¶
type OutputMode int
OutputMode selects how a workflow run delivers its report.
const ( // OutputModeAuto picks spinner on an interactive terminal and stream otherwise. OutputModeAuto OutputMode = iota // OutputModeSpinner shows a spinner while running and prints the whole // report once every job has finished. OutputModeSpinner // OutputModeStream prints each job block as soon as it is final and logs // step progress to stderr while jobs are still running. OutputModeStream )
func ParseOutputMode ¶
func ParseOutputMode(s string) (OutputMode, error)
ParseOutputMode converts a user supplied name into an OutputMode.
func (OutputMode) String ¶
func (m OutputMode) String() string
type Outputs ¶
type Outputs struct {
// contains filtered or unexported fields
}
Outputs manages step outputs across the entire workflow
func (*Outputs) GetAll ¶
GetAll returns all outputs (safe copy for expression evaluation). A run's own outputs stand in front of its parent's.
type PluginActionRunner ¶
type PluginActionRunner struct{}
PluginActionRunner is the ActionRunner a run uses unless it is given another: it runs each action in a process of its own, a built-in one served by the probe executable and an external one by its own.
func (*PluginActionRunner) Run ¶ added in v1.30.0
func (p *PluginActionRunner) Run(name string, call actionrpc.Call, opts RunOptions) (map[string]any, map[string]any, error)
Run runs the action for a step in a process of its own, telling it about the step, giving it the state it left in the job and returning the state it leaves.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer implements PrintWriter for console print
func NewPrinter ¶
NewPrinter creates a new console print writer. Its output is colored whatever it is written to when FORCE_COLOR or PROBE_TTY is 1: the CLI sets PROBE_TTY when its standard output is a terminal, for the printer of an embedded job: that one runs in the process of an action, whose standard output is not the terminal, and what it writes is printed by the run.
func (*Printer) AddSpinnerSuffix ¶
func (*Printer) LogWarn ¶
LogWarn prints a warning to the error writer: something the user should know about that does not make the run fail.
func (*Printer) Masker ¶
Masker returns the masker the printer applies. It is nil when none was installed, and on a nil Printer, which some contexts run without.
func (*Printer) PrintEchoContent ¶
PrintEchoContent prints echo content with proper indentation in verbose mode
func (*Printer) PrintError ¶
PrintError prints an error message
func (*Printer) PrintGivenRequest ¶ added in v1.30.0
PrintGivenRequest prints, for a step whose action failed without returning the request it made, the parameters the step gave the action, its templates evaluated, in place of the request and the response.
func (*Printer) PrintMapData ¶
PrintMapData prints map data in verbose mode as YAML-like lines, its keys sorted, and all of it, as it is: nothing is cut or left out.
func (*Printer) PrintRequestResponse ¶
func (p *Printer) PrintRequestResponse(stepIdx int, stepName string, req, res map[string]any, rt string)
PrintRequestResponse prints request and response data with proper formatting
func (*Printer) PrintSeparator ¶
func (p *Printer) PrintSeparator()
PrintSeparator prints a separator line for verbose output
func (*Printer) PrintTestResult ¶
PrintTestResult prints test result in verbose mode
func (*Printer) PrintVerbose ¶
PrintVerbose prints verbose output (only if verbose mode is enabled)
func (*Printer) StartSpinner ¶
func (p *Printer) StartSpinner()
func (*Printer) StopSpinner ¶
func (p *Printer) StopSpinner()
type Probe ¶
func (*Probe) DagAscii ¶
DagAscii returns the ASCII art representation of the workflow job dependencies with steps
func (*Probe) DagMermaid ¶
DagMermaid returns the Mermaid format representation of the workflow job dependencies
func (*Probe) ExitStatus ¶
type ProbeError ¶
ProbeError is the base error type, telling the operation that failed
func NewConfigurationError ¶
func NewConfigurationError(operation, message string, cause error) *ProbeError
func NewExecutionError ¶
func NewExecutionError(operation, message string, cause error) *ProbeError
func NewFileError ¶
func NewFileError(operation, message string, cause error) *ProbeError
func NewProbeError ¶
func NewProbeError(errorType ErrorType, operation, message string, cause error) *ProbeError
NewProbeError creates a new ProbeError
func (*ProbeError) Error ¶
func (e *ProbeError) Error() string
func (*ProbeError) Is ¶
func (e *ProbeError) Is(target error) bool
func (*ProbeError) Unwrap ¶
func (e *ProbeError) Unwrap() error
type Repeat ¶
type Repeat struct {
Count int `yaml:"count" validate:"required,gte=0"`
Interval Interval `yaml:"interval"`
Async bool `yaml:"async,omitempty"`
// Warmup is the number of runs before the count, which are run as any
// other but counted in neither the results nor the times, and do not
// fail the job.
Warmup int `yaml:"warmup,omitempty" validate:"gte=0"`
// Test is checked once every run is over, against the runs of the
// steps, and decides alone whether the job passed: a run in which a
// step failed is then counted, and fails nothing by itself.
Test string `yaml:"test,omitempty"`
// BaselineTest is checked once every run is over too, against the runs
// of the steps and those of the run compared to, under baseline. It is
// checked only when that run has the steps it reads, and then the job
// passes only when it holds. It leaves how a failed run is taken to Test.
BaselineTest string `yaml:"baseline_test,omitempty"`
}
Repeat defines the repeat configuration for jobs
type RepeatTestResult ¶ added in v1.29.0
type RepeatTestResult struct {
Test string
Passed bool
// Failure is why the test failed; nil when it passed.
Failure *StepFailure
// Skipped is why the test was not checked, which a test against the run
// compared to is not when there is nothing to compare to; empty when it
// was checked.
Skipped string
}
RepeatTestResult is the outcome of the test of a repeated job.
type Reporter ¶
type Reporter interface {
Start(name, description string)
StepStart(jobID, stepName string)
StepDone(jobID string, sr StepResult)
JobDone(jobID string, jr *JobResult)
Finish(rs *Result)
}
Reporter decides when the parts of a workflow report reach the user. Jobs run concurrently, so implementations are called from several goroutines and must serialize their own writes.
type ResponseTime ¶
ResponseTime provides response time information for expressions
type Result ¶
Result manages execution results for multiple jobs
func (*Result) AddStepResult ¶
func (rs *Result) AddStepResult(jobID string, stepResult StepResult)
AddStepResult adds a StepResult to the specified job result
func (*Result) SetReporter ¶
SetReporter installs the reporter told when steps start and when steps and jobs finish.
type RunOptions ¶
type RunOptions struct {
// Verbose raises the action's log level to debug.
Verbose bool
// Trace, with Verbose, raises it to trace, to show how the action's
// process is started, called and stopped as well.
Trace bool
// Quiet silences the action's own log records. It is set for a retry
// attempt that still has another attempt left: actions have no notion of
// being retried, so a failure there would otherwise be reported at error
// level even though the step goes on to succeed.
Quiet bool
// Masker hides the workflow's secrets in the action's log records.
Masker *mask.Masker
// BaseDir is the directory a local action's path is relative to: the
// directory of the workflow file. The working directory is used when it
// is empty.
BaseDir string
// contains filtered or unexported fields
}
RunOptions controls how a single action invocation is run and logged.
func (RunOptions) Context ¶ added in v1.30.0
func (o RunOptions) Context() context.Context
Context returns the context the action runs in, which is done once the step gives up on the action, as it does when the step times out. It is never nil: without one, the action runs until it returns.
type StandaloneOption ¶
type StandaloneOption func(*standaloneConfig)
StandaloneOption changes how RunStandalone runs a job.
func WithActionRunner ¶ added in v1.30.0
func WithActionRunner(r ActionRunner) StandaloneOption
WithActionRunner runs the actions of the job's steps with r, as Config.ActionRunner does those of a workflow.
func WithActions ¶
func WithActions(names map[string]string) StandaloneOption
WithActions tells the steps of the job the names a workflow gives its external actions, such as those of the workflow that embeds it, for a job the job itself embeds to be read by. The job's own steps are read by them with UseActions.
func WithBuiltinActions ¶
func WithBuiltinActions(names []string) StandaloneOption
WithBuiltinActions tells the job the names of the actions of Probe, so that a uses that names no action stops the job before any step runs. Without it, such a step fails when it is run.
func WithCleanups ¶ added in v1.27.0
func WithCleanups(c *actionrpc.Cleanups) StandaloneOption
WithCleanups runs the job as part of a run that cleans up once it is over, such as the run of the step that embeds it: the actions the job would have had clean up when it ended are named in c instead, and what its steps left behind stays for the rest of that run. Without it, or with a nil c, the job cleans up after itself.
func WithGuard ¶
func WithGuard(guard actionrpc.Guard) StandaloneOption
WithGuard runs the job under guard, such as the guard of the run of the step that embeds it, so that a workflow cannot get round its guard by embedding a job.
func WithNeedsNoCheck ¶ added in v1.30.0
func WithNeedsNoCheck(names []string) StandaloneOption
WithNeedsNoCheck tells the job the names of the actions whose steps pass without a test, as Config.NeedsNoCheck tells a workflow. Without it, a step that nothing checks is counted as untested whatever its action.
func WithRunID ¶
func WithRunID(id string) StandaloneOption
WithRunID runs the job as part of the run id names, such as the run of the step that embeds it, so that its actions are told the same run. Without it the job is a run of its own.
type StatusType ¶
type StatusType int
StatusType represents the status of execution
const ( StatusSuccess StatusType = iota StatusError StatusWarning StatusSkipped )
type Step ¶
type Step struct {
Name string `yaml:"name"`
ID string `yaml:"id,omitempty"`
Uses string `yaml:"uses" validate:"required"`
With map[string]any `yaml:"with"`
Test string `yaml:"test"`
Echo string `yaml:"echo"`
Vars map[string]any `yaml:"vars"`
Iteration Iteration `yaml:"iteration"`
Wait string `yaml:"wait,omitempty"`
SkipIf string `yaml:"skipif,omitempty"`
Outputs map[string]string `yaml:"outputs,omitempty"`
Retry *StepRetry `yaml:"retry,omitempty"`
Timeout Interval `yaml:"timeout,omitempty"`
}
type StepContext ¶
type StepContext struct {
Vars map[string]any `expr:"vars"`
Res map[string]any `expr:"res"`
Req map[string]any `expr:"req"`
RT ResponseTime `expr:"rt"`
Report string `expr:"report"`
Outputs map[string]any `expr:"outputs"`
Status int `expr:"status"`
RepeatIndex int `expr:"repeat_index"`
}
StepContext provides context data for step expression evaluation
type StepFailure ¶
type StepFailure struct {
Kind string
Message string
// Request and Response are what the action sent and received. They are left
// nil when the action asked not to be dumped (res.dump: false).
Request map[string]any
Response map[string]any
// Violations are what broke the contract, when Kind is a contract's.
Violations []report.Violation
// contains filtered or unexported fields
}
StepFailure describes a failed step without terminal formatting, so that reports can serialize it.
type StepRepeatCounter ¶
type StepRepeatCounter struct {
// ID is the id of the step, by which the test of the repeated job reads
// its runs.
ID string
SuccessCount int
FailureCount int
// SkippedCount is the runs in which the step was not run: an earlier
// step of the run failed in a job with fail_fast, or its iteration
// came to no entry. They are neither successes nor failures of the
// step.
SkippedCount int
Name string
// Test is the test of the step the counter is of, empty when it has
// none. The counter is kept by the index of the step as it ran, which
// an iteration makes another than its index in the job, so what the
// step's result needs of the step is kept here.
Test string
LastResult bool
RepeatTotal int // Total number of times the step should be repeated
// Echoes are what the step's echo came to in each run, as it is.
Echoes []string
// RTs is the time in seconds the action took in each run that it
// returned one in, whether or not the step's test held.
RTs []float64
// Warmup is the number of runs before those counted, which the counts
// and the times leave out.
Warmup int
// Tested is whether the job has a test over its runs, which decides
// whether it passed in place of the runs of its steps.
Tested bool
// Failure is why the first iteration that failed did, so that the step's
// result keeps the kind of failure, such as an action error, rather than
// only the count.
Failure *StepFailure
// Checked is whether an action checked a response against a contract,
// which checks the step as a test does, or the step is one that passes
// without being checked, as one of the hello action does.
Checked bool
// Contract is what the first iteration's response was matched to in
// its contract.
Contract *report.Contract
}
StepRepeatCounter tracks the execution results of repeated steps
type StepResult ¶
type StepResult struct {
Index int
// ID is the id of the step, or step_ and where it is written in the job
// when it has none; see Step.repeatID.
ID string
Name string
Status StatusType
StartedAt time.Time
RT string
RTSec float64
WaitTime string
// Echo is what the step's echo came to, as it is: the report indents
// and colors it. HasEcho is whether the step has an echo, which may
// come to nothing.
Echo string
HasEcho bool
Report string
HasTest bool
RetryAttempt int // Number of attempts made (0 = retry not performed, 1 = succeeded first try)
RetryMax int // Maximum retry attempts configured
RepeatCounter *StepRepeatCounter // For repeat execution information
// The fields below feed the report files. Unlike StartedAt and RT they are
// recorded whether or not --timing is set, and they carry no terminal styling.
Test string // The test expression, empty when the step has none
Elapsed time.Duration // Wall time from the action's start to the result
Failure *StepFailure // Why the step failed; nil unless Status is StatusError
// Contract is what the response was matched to in the contract the
// action checked it against; nil when it checked none.
Contract *report.Contract
}
StepResult represents the result of a step execution
type StepRetry ¶
type StepRetry struct {
MaxAttempts int `yaml:"max_attempts" validate:"required,gte=1"`
Interval Interval `yaml:"interval"`
InitialDelay Interval `yaml:"initial_delay,omitempty"`
}
StepRetry defines the retry configuration for steps until success (status 0)
type StreamReporter ¶
type StreamReporter struct {
// contains filtered or unexported fields
}
StreamReporter prints the report incrementally.
A job block is only printed once the job is final, which keeps blocks from interleaving even though jobs run concurrently. Blocks are held back until every earlier job in workflow order has been printed, so the finished report is identical to the buffered one. Step level progress goes to stderr, which is what keeps a CI log alive while the first job is still running.
func (*StreamReporter) Finish ¶
func (r *StreamReporter) Finish(rs *Result)
func (*StreamReporter) JobDone ¶
func (r *StreamReporter) JobDone(jobID string, jr *JobResult)
func (*StreamReporter) Start ¶
func (r *StreamReporter) Start(name, description string)
func (*StreamReporter) StepDone ¶
func (r *StreamReporter) StepDone(jobID string, sr StepResult)
func (*StreamReporter) StepStart ¶
func (r *StreamReporter) StepStart(jobID, stepName string)
type Workflow ¶
type Workflow struct {
Name string `yaml:"name" validate:"required"`
Description string `yaml:"description,omitempty"`
Jobs []Job `yaml:"jobs" validate:"required"`
Vars map[string]any `yaml:"vars"`
// Defaults are the with of each action, by its uses, for the steps of
// every job. A job's own defaults come before them, and a step's with
// before both.
Defaults any `yaml:"defaults"`
// Actions gives names to external actions, for the steps and the
// defaults of the jobs to name them by. Load writes the action in place
// of each name, so nothing that runs the workflow sees one.
Actions map[string]string `yaml:"actions,omitempty"`
// Secrets names environment variables whose values must not appear in
// anything Probe prints or writes.
Secrets []string `yaml:"secrets,omitempty"`
// contains filtered or unexported fields
}
func (*Workflow) Env ¶
Env returns the workflow's own environment, which the vars of every run read: the process's, as it was when Env was first called, unless the workflow was given one. What a run is given in Config.Env is that run's alone, and is not in it.
func (*Workflow) Graph ¶
Graph returns the jobs and steps of the workflow in the form the DAG renderers draw. The steps of an embedded job are read from its file, at the path its `with.path` names after the workflow's vars are expanded, relative to the working directory.
func (*Workflow) RunID ¶
RunID returns the ID of the last run Start began, which every action of the run is told about, or an empty string before Start.
func (*Workflow) Start ¶
Start runs the workflow with the given configuration. It prepares the run, which refuses the workflow for what keeps it from running before any job starts, executes the jobs of the run, and writes the report files the run was asked for. What a run decides and finds out is its own, so the workflow is left as it was for the next Start, but for the exit status and the ID of the last run.
Source Files
¶
- actionresult.go
- actions.go
- aliases.go
- check.go
- check_actions.go
- check_exprs.go
- check_names.go
- check_needs.go
- check_outputs.go
- check_problems.go
- check_repeat.go
- check_types.go
- check_untested.go
- check_yaml.go
- cleanup.go
- context.go
- detail.go
- embedded.go
- error.go
- executor.go
- exitcode.go
- graph.go
- guide.go
- include.go
- iteration.go
- job.go
- joblabel.go
- maps.go
- outputs.go
- printer.go
- probe.go
- problems.go
- render.go
- repeat.go
- repeattest.go
- report.go
- reporter.go
- result.go
- select.go
- skill.go
- step.go
- style.go
- validate.go
- where.go
- workflow.go
- workflowfiles.go
- workflowrun.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package actionref resolves an action that a step's `uses` names outside Probe to the executable that serves it.
|
Package actionref resolves an action that a step's `uses` names outside Probe to the executable that serves it. |
|
Package actionrpc is the protocol between the workflow runner and its actions.
|
Package actionrpc is the protocol between the workflow runner and its actions. |
|
Package actions maps the action names usable in a step's `uses` to the built-in plugins that implement them.
|
Package actions maps the action names usable in a step's `uses` to the built-in plugins that implement them. |
|
dns
Package dns is the dns action: it asks a DNS server for the records of a name, and returns what the server answered.
|
Package dns is the dns action: it asks a DNS server for the records of a name, and returns what the server answered. |
|
grpc/testserver
command
|
|
|
smtp/testserver
command
|
|
|
cmd
|
|
|
probe
command
|
|
|
Package dag provides generic graph algorithms that work with any data structure, and the renderers that draw a workflow's jobs as a graph.
|
Package dag provides generic graph algorithms that work with any data structure, and the renderers that draw a workflow's jobs as a graph. |
|
e2e
|
|
|
dns-server
command
Command dns-server answers DNS queries for a few records of example.test, over UDP and TCP.
|
Command dns-server answers DNS queries for a few records of example.test, over UDP and TCP. |
|
echo-server
command
Command echo-server echoes a POSTed JSON body back as the data of the response, with the request headers.
|
Command echo-server echoes a POSTed JSON body back as the data of the response, with the request headers. |
|
internal
|
|
|
actionlog
Package actionlog shows the records of an action's process, those the action logs and those go-plugin logs of running it, as the verbose output of a step is laid out, with the secrets of the run hidden.
|
Package actionlog shows the records of an action's process, those the action logs and those go-plugin logs of running it, as the verbose output of a step is laid out, with the secrets of the run hidden. |
|
actionspec
Package actionspec declares what Probe knows of a built-in action: how to serve it, the guards it keeps to, and what probe check knows of the keys it takes and the fields it returns.
|
Package actionspec declares what Probe knows of a built-in action: how to serve it, the guards it keeps to, and what probe check knows of the keys it takes and the fields it returns. |
|
actiontest
Package actiontest helps the tests of the built-in actions keep what each declares of itself to what it does.
|
Package actiontest helps the tests of the built-in actions keep what each declares of itself to what it does. |
|
body
Package body reads a response body by its Content-Type: a body of a textual type is kept as text, and any other body, such as an image or a PDF, is written to a temporary file.
|
Package body reads a response body by its Content-Type: a body of a textual type is kept as text, and any other body, such as an image or a PDF, is written to a temporary file. |
|
contractcheck
Package contractcheck holds what the actions that check a step against a contract, the http action's OpenAPI document and the grpc action's .proto files, share: reading the flags of the contract option, the shape of a violation, and handing the result to the runner and to res.
|
Package contractcheck holds what the actions that check a step against a contract, the http action's OpenAPI document and the grpc action's .proto files, share: reading the flags of the contract option, the shape of a violation, and handing the result to the runner and to res. |
|
dump
Package dump lays out the data an action returned, such as the request and the response of a step, as YAML-like lines to be read by a person:
|
Package dump lays out the data an action returned, such as the request and the response of a step, as YAML-like lines to be read by a person: |
|
duration
Package duration reads the durations a workflow is written with: a step's timeout and wait, the interval of a repeat or a retry, and the timeout an action takes.
|
Package duration reads the durations a workflow is written with: a step's timeout and wait, the interval of a repeat or a retry, and the timeout an action takes. |
|
envfile
Package envfile reads files of environment variables, one NAME=value a line, as the .env files many tools keep beside a project.
|
Package envfile reads files of environment variables, one NAME=value a line, as the .env files many tools keep beside a project. |
|
expr
Package expr evaluates the expressions and {{ }} templates of a workflow.
|
Package expr evaluates the expressions and {{ }} templates of a workflow. |
|
fielderr
Package fielderr rewrites the paths of the *expr.FieldError joined into an error, so that a path names the value from where the error is reported.
|
Package fielderr rewrites the paths of the *expr.FieldError joined into an error, so that a path names the value from where the error is reported. |
|
hostport
Package hostport completes an address an action connects to with the port it is taken at when it names none, so that the guard of a run checks the same host and port the action dials.
|
Package hostport completes an address an action connects to with the port it is taken at when it names none, so that the guard of a run checks the same host and port the action dials. |
|
jsonutil
Package jsonutil decodes and compares the JSON values that actions return.
|
Package jsonutil decodes and compares the JSON values that actions return. |
|
kind
Package kind names the kinds of value an action returns, as an expression reads them once the runner has received them, so that probe check can tell what an expression does with a field before the workflow runs.
|
Package kind names the kinds of value an action returns, as an expression reads them once the runner has received them, so that probe check can tell what an expression does with a field before the workflow runs. |
|
mapping
Package mapping converts between untyped action parameter maps and tagged Go structs.
|
Package mapping converts between untyped action parameter maps and tagged Go structs. |
|
procgroup
Package procgroup stops the process groups that steps leave running in the background once the workflow that started them is over.
|
Package procgroup stops the process groups that steps leave running in the background once the workflow that started them is over. |
|
protocoverage
Package protocoverage counts which methods of a .proto file the steps of a run called, for probe coverage; the grpc action names its calls the same way.
|
Package protocoverage counts which methods of a .proto file the steps of a run called, for probe coverage; the grpc action names its calls the same way. |
|
safefile
Package safefile writes files that a symlink planted in the current directory must not redirect.
|
Package safefile writes files that a symlink planted in the current directory must not redirect. |
|
scalar
Package scalar writes a scalar value, such as a number or a bool, as the text a workflow compares or passes on.
|
Package scalar writes a scalar value, such as a number or a bool, as the text a workflow compares or passes on. |
|
schedule
Package schedule tells which jobs of a run can start, from the jobs each one needs and how those ended.
|
Package schedule tells which jobs of a run can start, from the jobs each one needs and how those ended. |
|
smtptest
Package smtptest provides an SMTP server for trying the smtp action against: it accepts every message, offers STARTTLS when it has a certificate, and logs each line it reads and writes.
|
Package smtptest provides an SMTP server for trying the smtp action against: it accepts every message, offers STARTTLS when it has a certificate, and logs each line it reads and writes. |
|
suggest
Package suggest finds the name that was likely meant by one that is not known, so that an error can ask "did you mean" it.
|
Package suggest finds the name that was likely meant by one that is not known, so that an error can ask "did you mean" it. |
|
textwidth
Package textwidth measures text by the columns it takes in a terminal, and cuts it to them, so that what is written beside it lines up whatever characters it has.
|
Package textwidth measures text by the columns it takes in a terminal, and cuts it to them, so that what is written beside it lines up whatever characters it has. |
|
thirdparty
Package thirdparty collects the licenses of what is built into the probe executable: the modules it links, and the Go standard library.
|
Package thirdparty collects the licenses of what is built into the probe executable: the modules it links, and the Go standard library. |
|
thirdparty/gen
command
Command gen writes the licenses of what is built into the probe executable to a file, for a release archive to carry:
|
Command gen writes the licenses of what is built into the probe executable to a file, for a release archive to carry: |
|
truncate
Package truncate shortens long values before they are logged or printed, marking where they were cut.
|
Package truncate shortens long values before they are logged or printed, marking where they were cut. |
|
vareval
Package vareval evaluates the templates in vars, those of a workflow and those of a step.
|
Package vareval evaluates the templates in vars, those of a workflow and those of a step. |
|
yamlfmt
Package yamlfmt formats the YAML of a workflow, as gofmt formats Go: there is one way a workflow is laid out, and nothing to configure.
|
Package yamlfmt formats the YAML of a workflow, as gofmt formats Go: there is one way a workflow is laid out, and nothing to configure. |
|
Package mask hides secret values in everything Probe prints or writes.
|
Package mask hides secret values in everything Probe prints or writes. |
|
misc
|
|
|
demo/server
command
Command server is the sign-up service the demo in misc/demo runs Probe against: an HTTP API that keeps its users in a SQLite file, so that a workflow can call an endpoint and then query the row it wrote.
|
Command server is the sign-up service the demo in misc/demo runs Probe against: an HTTP API that keeps its users in a SQLite file, so that a workflow can call an endpoint and then query the row it wrote. |
|
Package report renders the result of a workflow run as files for machines and for people: JSON, JUnit XML, Markdown and the GitHub Actions job summary.
|
Package report renders the result of a workflow run as files for machines and for people: JSON, JUnit XML, Markdown and the GitHub Actions job summary. |