reporter

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package reporter formats engine events for the user. Two sinks are provided: pretty (human, default) and json (one event per line, for scripting).

Index

Constants

View Source
const (
	StatusSucceeded   = "succeeded"
	StatusFailed      = "failed"
	StatusInfraFailed = "infrafailed"
	StatusSkipped     = "skipped"
	StatusNotRun      = "not-run"
	StatusTimeout     = "timeout"
)

Status values that can appear on task-end. Existing values are unchanged; "timeout" is new in v1.2.

Variables

This section is empty.

Functions

func ResolveColor added in v1.2.0

func ResolveColor(mode ColorMode, isTerminal bool, env func(string) (string, bool)) bool

ResolveColor decides whether to emit ANSI codes.

Precedence (highest first):

  1. mode = Always or Never — explicit user choice wins.
  2. NO_COLOR env (any non-empty value) — disables color, per https://no-color.org.
  3. FORCE_COLOR or CLICOLOR_FORCE (any non-empty value) — enables color.
  4. mode = Auto — color iff isTerminal.

env is the lookup function (typically os.LookupEnv) so this can be tested without touching process state.

Types

type ColorMode added in v1.2.0

type ColorMode int

ColorMode is how the user requested coloring be decided.

const (
	ColorAuto   ColorMode = iota // honor TTY + env
	ColorAlways                  // always emit ANSI
	ColorNever                   // never emit ANSI
)

func ParseColorMode added in v1.2.0

func ParseColorMode(s string) (ColorMode, error)

ParseColorMode accepts auto|always|never (case-insensitive). Empty string maps to ColorAuto.

type Event

type Event struct {
	Kind     EventKind     `json:"kind"`
	Time     time.Time     `json:"time"`
	RunID    string        `json:"runId,omitempty"`
	Pipeline string        `json:"pipeline,omitempty"`
	Task     string        `json:"task,omitempty"`
	Step     string        `json:"step,omitempty"`
	Stream   string        `json:"stream,omitempty"` // stdout|stderr
	Line     string        `json:"line,omitempty"`
	Status   string        `json:"status,omitempty"`
	ExitCode int           `json:"exitCode,omitempty"`
	Duration time.Duration `json:"durationMs,omitempty"`
	Message  string        `json:"message,omitempty"`
	// Attempt is 1-based and present on task-retry (the attempt that just
	// failed) and on task-end (the attempt that produced the final outcome).
	Attempt int `json:"attempt,omitempty"`
}

type EventKind

type EventKind string
const (
	EvtRunStart  EventKind = "run-start"
	EvtRunEnd    EventKind = "run-end"
	EvtTaskStart EventKind = "task-start"
	EvtTaskEnd   EventKind = "task-end"
	EvtTaskSkip  EventKind = "task-skip"
	EvtTaskRetry EventKind = "task-retry"
	EvtStepStart EventKind = "step-start"
	EvtStepEnd   EventKind = "step-end"
	EvtStepLog   EventKind = "step-log"
	EvtError     EventKind = "error"
)

type LogSink

type LogSink struct {
	// contains filtered or unexported fields
}

LogSink is the engine-facing log forwarder; reporters expose this so the backend interface stays decoupled from the reporter type.

func NewLogSink

func NewLogSink(r Reporter) *LogSink

func (*LogSink) StepLog

func (s *LogSink) StepLog(taskName, stepName, stream, line string)

type PrettyOptions added in v1.2.0

type PrettyOptions struct {
	Color     bool      // already resolved via ResolveColor
	Verbosity Verbosity // Quiet | Normal | Verbose
}

PrettyOptions configures NewPretty.

type Reporter

type Reporter interface {
	Emit(e Event)
	Close() error
}

Reporter consumes events.

func NewJSON

func NewJSON(w io.Writer) Reporter

func NewPretty

func NewPretty(w io.Writer, opt PrettyOptions) Reporter

NewPretty returns a Reporter that prints human-readable, live-ordered output. Step logs stream as they arrive, prefixed with their task and step names so parallel runs remain readable.

type Tee

type Tee struct {
	// contains filtered or unexported fields
}

Tee writes each event to all underlying reporters.

func NewTee

func NewTee(rs ...Reporter) *Tee

func (*Tee) Close

func (t *Tee) Close() error

func (*Tee) Emit

func (t *Tee) Emit(e Event)

type Verbosity added in v1.2.0

type Verbosity int

Verbosity controls how much the pretty reporter prints.

Quiet  → final task + run summaries only
Normal → pipeline header + live step logs + task/run summaries (default)
Verbose → adds step-start/step-end markers
const (
	Quiet   Verbosity = -1
	Normal  Verbosity = 0
	Verbose Verbosity = 1
)

Jump to

Keyboard shortcuts

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