Documentation
¶
Overview ¶
Package check finds what keeps a workflow from running, or from checking what it seems to, without running it: probe check.
Index ¶
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.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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
// Replaceable are those of Actions a workflow can give to an external
// action under actions, as they are being replaced by one.
Replaceable []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
// Choices are the values that the keys of with which take only some
// take, by the action's name and then the key's, so that a value
// written that is not one of them is reported, as op: remove is for the
// file action. A value that holds a template, which is known only when
// it runs, and an empty one, which leaves the key to its default, are
// not checked.
Choices map[string]map[string]Choices
// 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. The probe command gives it what it is to know of the built-in actions.
type Choices ¶
type Choices struct {
// Values are the values the key takes.
Values []string
// IgnoreCase says that the key takes a value in any case.
IgnoreCase bool
}
Choices are the values a key of with takes, as CheckOptions.Choices gives them.
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.