Documentation
¶
Overview ¶
Package display prints a run of a workflow: its report, rendered as text for a terminal, the progress of its jobs, and what a verbose run shows of its steps, with the secrets of the run hidden in all of it.
Index ¶
- Constants
- func ColorDim() *color.Color
- func ColorWarning() *color.Color
- func NewReporter(mode Mode, p *Printer, render *Renderer) outcome.Reporter
- func TestErrorDetail(message string) string
- func TypeMismatchDetail(testExpr string, result any) string
- func TypeMismatchText(testExpr string, result any) string
- func WarnLine(msg string) string
- type BufferedReporter
- func (r *BufferedReporter) Finish(rs *outcome.Run)
- func (r *BufferedReporter) JobDone(jobID string, jr *outcome.Job)
- func (r *BufferedReporter) Start(name, description string)
- func (r *BufferedReporter) StepDone(jobID string, sr outcome.Step)
- func (r *BufferedReporter) StepStart(jobID, stepName string)
- type DebugBlock
- type JobLabeler
- type Mode
- type Printer
- func (p *Printer) AddSpinnerSuffix(txt string)
- func (p *Printer) Err() io.Writer
- 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) LogDebugBlock(b *DebugBlock)
- func (p *Printer) LogError(format string, args ...any)
- func (p *Printer) LogTestError(testExpr string, err error)
- func (p *Printer) LogWarn(format string, args ...any)
- func (p *Printer) Masker() *mask.Masker
- func (p *Printer) Out() io.Writer
- 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, env map[string]any)
- func (p *Printer) PrintVerbose(format string, args ...any)
- func (p *Printer) SetErr(w io.Writer)
- func (p *Printer) SetMasker(m *mask.Masker)
- func (p *Printer) SetOut(w io.Writer)
- func (p *Printer) SetVerbose(v bool)
- func (p *Printer) StartSpinner()
- func (p *Printer) StopSpinner()
- func (p *Printer) Verbose() bool
- type Renderer
- type StreamReporter
- func (r *StreamReporter) Finish(rs *outcome.Run)
- func (r *StreamReporter) JobDone(jobID string, jr *outcome.Job)
- func (r *StreamReporter) LabelJobs(name func(id string) string)
- func (r *StreamReporter) Start(name, description string)
- func (r *StreamReporter) StepDone(jobID string, sr outcome.Step)
- func (r *StreamReporter) StepStart(jobID, stepName string)
Constants ¶
const ( IconSuccess = "✓ " IconError = "✗ " IconTriangle = "△ " IconCircle = "⏺" IconWait = "🕐︎" IconSkip = "⏭ " IconRetry = "⟳" // IconStepStart marks a step that started, in the progress of a run. IconStepStart = "▸" )
Icon constants. Those of the statuses are the icons of the marks of the style package, followed by a space.
Variables ¶
This section is empty.
Functions ¶
func ColorWarning ¶
ColorWarning returns a *color.Color for warnings (yellow)
func NewReporter ¶
NewReporter builds the reporter for the given mode.
func TestErrorDetail ¶
TestErrorDetail formats the error a test could not be evaluated for, by its message.
func TypeMismatchDetail ¶
TypeMismatchDetail formats a test that did not evaluate to a boolean.
func TypeMismatchText ¶
TypeMismatchText is what a test that did not evaluate to a boolean is told by.
Types ¶
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 *outcome.Run)
func (*BufferedReporter) JobDone ¶
func (r *BufferedReporter) JobDone(jobID string, jr *outcome.Job)
func (*BufferedReporter) Start ¶
func (r *BufferedReporter) Start(name, description string)
func (*BufferedReporter) StepDone ¶
func (r *BufferedReporter) StepDone(jobID string, sr outcome.Step)
func (*BufferedReporter) StepStart ¶
func (r *BufferedReporter) StepStart(jobID, stepName string)
type DebugBlock ¶
DebugBlock collects the lines of a block of verbose output, such as the request and the response of a step, so that the block is written at once. Jobs run concurrently, and a block written a line at a time would have the lines of another job land inside it.
func (*DebugBlock) Line ¶
func (b *DebugBlock) Line(format string, args ...any)
Line adds a line to the block, as LogDebug writes it.
type JobLabeler ¶
JobLabeler is a Reporter that labels what it prints by job, and is told the names of the jobs once the vars they are evaluated with are known.
type Mode ¶
type Mode int
Mode selects how a workflow run delivers its report.
const ( // ModeAuto picks spinner on an interactive terminal and stream otherwise. ModeAuto Mode = iota // ModeSpinner shows a spinner while running and prints the whole // report once every job has finished. ModeSpinner // ModeStream prints each job block as soon as it is final and logs // step progress to stderr while jobs are still running. ModeStream )
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 NewPrinterTo ¶
NewPrinterTo returns a printer that writes to out and err and shows no spinner, for a run whose output is captured, as a test captures it.
func (*Printer) AddSpinnerSuffix ¶
func (*Printer) LogDebugBlock ¶
func (p *Printer) LogDebugBlock(b *DebugBlock)
LogDebugBlock writes a block of verbose output in one write, only in verbose mode.
func (*Printer) LogTestError ¶
LogTestError logs, in verbose mode, the error a test could not be evaluated for.
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 ¶
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, in verbose mode, what the test testExpr came to, with env, the names it was evaluated with, when it is not nil.
func (*Printer) PrintVerbose ¶
PrintVerbose prints verbose output (only if verbose mode is enabled)
func (*Printer) SetVerbose ¶
SetVerbose sets whether the printer writes the verbose output of a run.
func (*Printer) StartSpinner ¶
func (p *Printer) StartSpinner()
func (*Printer) StopSpinner ¶
func (p *Printer) StopSpinner()
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer renders the report of a run as text: a block for each job, in the order the workflow writes them, and a footer, and the lines of the progress of a run. What it renders is shown as it is, so the secrets the masker knows are hidden in it. It writes nothing itself: a Reporter tells when what it renders is printed, and where.
Its methods named write* write their part of the report to the builder they are given, and those named *Text return theirs.
func NewRenderer ¶
NewRenderer returns a renderer of the jobs of order, which shows the times of the repeated steps against baseline, when it is not nil.
func (*Renderer) FailureText ¶
FailureText returns why a step, or a test of a repeated job, failed, as it is shown under it: f is its failure and test its test. A test that is false is told by the condition of it that is false and what that compared, then the request and the response; one that could not be evaluated, or did not come to a boolean, by that; a contract that is broken by where, then the request and the response; and an error by its message. It is empty when f is nil.
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 *outcome.Run)
func (*StreamReporter) LabelJobs ¶
func (r *StreamReporter) LabelJobs(name func(id string) string)
LabelJobs labels the progress lines of each job by its name, which name gives for its id. The names are known once the vars they are evaluated with are, which is after Start. Until then a line is labelled by its id.
func (*StreamReporter) Start ¶
func (r *StreamReporter) Start(name, description string)
func (*StreamReporter) StepStart ¶
func (r *StreamReporter) StepStart(jobID, stepName string)