Documentation
¶
Overview ¶
Package scriptsave is the one gate a managed script's source crosses on every save (#1913), for the manage_script tool and the portal editor alike: the formatter and the lint (internal/platform/scriptlint), the script's tests and the statements they reach (#1939, #1940), and what the new version does differently from the saved one (#1942).
A script is saved only with at least one test, every test passing, at least MinCoverage percent of its statements reached, and its tests reading every output their executions produce (#1952). A script saved before these rules keeps running as it is; its next version is held to all of them (#1965).
A new version of a saved script replays the script's recent recorded runs through both versions and compares what they produced, and compares what each reaches. A difference is a change in what the automation does, and the save then needs a plain-language summary of it and the agent's confirmation that the person the automation runs for agreed. A person approves behavior, never code: there is no second approver.
Index ¶
Constants ¶
const MinCoverage = 80.0
MinCoverage is the share of its statements a script's tests must reach.
const RecentRuns = 5
RecentRuns is how many of a script's latest recorded runs a save replays.
Variables ¶
This section is empty.
Functions ¶
func Readable ¶
Readable reports whether caller may read a recording, under the rules run history is read by: an administrator, and the current owner of existing when it recorded existing. A draft is also its author's, who ran it with their own access; a run is not its former owner's once the script moved.
Types ¶
type Gate ¶
type Gate struct {
// Recordings is where recordings are read from; nil reads none.
Recordings scriptrec.Store
// Destinations is the deployment's bucket destinations, which an export
// a test or a replay reaches resolves against.
Destinations []script.Destination
// MaxMemoryBytes is the memory one test or replay may hold.
MaxMemoryBytes int64
// Contracts is what an answer a test declares is held to (#1953); nil
// checks none.
Contracts scripttest.Contracts
// Libraries is where the libraries a source loads are read from
// (#1941); nil refuses a source that loads any.
Libraries scriptlib.Source
}
Gate holds what a save is checked against. The zero value checks the lint and the tests, with no recording a test names readable.
type Request ¶
type Request struct {
// Existing is the script saved into, nil for a new one.
Existing *script.Script
// Name labels the script in tracebacks.
Name string
Source string
Caller Caller
// ChangeSummary is what the new version does differently, in plain
// language, and Agreed the confirmation that the person the automation
// runs for agreed to it.
ChangeSummary string
Agreed bool
}
Request is one save.
type Result ¶
type Result struct {
// Lint is the formatter's and the lint's result; Lint.Source is what a
// save stores.
Lint scriptlint.Result `json:"-"`
// Tests is the tests' report, nil when the save was refused before they
// ran.
Tests *scripttest.Report `json:"tests,omitempty"`
// Differences is what the new version does differently. Replayed is the
// recorded runs both versions replayed, and NotCompared the ones the
// saved version itself could not replay.
Differences []scriptbehavior.Difference `json:"differences"`
Replayed []string `json:"replayed"`
NotCompared []string `json:"not_compared,omitempty"`
// Refusal is why the save is refused, empty when it goes through.
Refusal string `json:"refusal,omitempty"`
// ChangeNeeded is true when the refusal is only that a behavior change
// needs a summary and the person's agreement.
ChangeNeeded bool `json:"change_needed,omitempty"`
// ChangeSummary and ChangeAgreedBy are what the saved version carries,
// empty when there is nothing.
ChangeSummary string `json:"-"`
ChangeAgreedBy string `json:"-"`
}
Result is what the gate made of a save.