Documentation
¶
Index ¶
- func Blue(enabled bool, text string) string
- func Bold(enabled bool, text string) string
- func BoldCyan(enabled bool, text string) string
- func ColorEnabledForWriter(w io.Writer) bool
- func Cyan(enabled bool, text string) string
- func Dim(enabled bool, text string) string
- func Green(enabled bool, text string) string
- func IsGitHubActions() bool
- func IsInteractiveWriter(w io.Writer) bool
- func Magenta(enabled bool, text string) string
- func Red(enabled bool, text string) string
- func RenderProgressBar(pct, width int) string
- func Style(enabled bool, text string, codes ...string) string
- func Yellow(enabled bool, text string) string
- type GHAJobBuffer
- func (b *GHAJobBuffer) Annotation(level, msg string, props map[string]string)
- func (b *GHAJobBuffer) CloseGroup()
- func (b *GHAJobBuffer) OpenGroup(title string)
- func (b *GHAJobBuffer) PrintBlock(lines []string)
- func (b *GHAJobBuffer) Println(line string)
- func (b *GHAJobBuffer) Write(p []byte) (int, error)
- type GHARenderer
- func (g *GHARenderer) Error(msg string)
- func (g *GHARenderer) FlushJob(jobID string)
- func (g *GHARenderer) FlushStep(jobID string)
- func (g *GHARenderer) JobBuffer(jobID string) *GHAJobBuffer
- func (g *GHARenderer) Notice(msg string)
- func (g *GHARenderer) Print(line string)
- func (g *GHARenderer) PrintBlock(lines []string)
- func (g *GHARenderer) Warning(msg string)
- type LiveRegion
- func (l *LiveRegion) Print(line string)
- func (l *LiveRegion) PrintBlock(lines []string)
- func (l *LiveRegion) RemoveRow(key string)
- func (l *LiveRegion) RowCount() int
- func (l *LiveRegion) SetHeaderFunc(fn func(activeRows int) []string)
- func (l *LiveRegion) SetRow(key, label string)
- func (l *LiveRegion) SetRowDetail(key, group, label, tail string)
- func (l *LiveRegion) SetWindowMax(n int)
- func (l *LiveRegion) Start()
- func (l *LiveRegion) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorEnabledForWriter ¶
func IsGitHubActions ¶
func IsGitHubActions() bool
IsGitHubActions reports whether the current process is executing inside a GitHub Actions runner. The runner sets GITHUB_ACTIONS=true for every step.
func IsInteractiveWriter ¶
func RenderProgressBar ¶
RenderProgressBar draws a fixed-width unicode progress bar.
Types ¶
type GHAJobBuffer ¶
type GHAJobBuffer struct {
// contains filtered or unexported fields
}
GHAJobBuffer collects output for a single job. It implements io.Writer so it can be plugged into existing Fprintf-style call sites unchanged.
func (*GHAJobBuffer) Annotation ¶
func (b *GHAJobBuffer) Annotation(level, msg string, props map[string]string)
Annotation writes a workflow-command annotation into the buffer so it is flushed in-order with the surrounding job logs.
func (*GHAJobBuffer) CloseGroup ¶
func (b *GHAJobBuffer) CloseGroup()
CloseGroup writes a matching ::endgroup:: marker.
func (*GHAJobBuffer) OpenGroup ¶
func (b *GHAJobBuffer) OpenGroup(title string)
OpenGroup writes a ::group:: marker into the buffer. GHA does not nest groups; a depth counter is tracked so a Step group inside an already-open Job context degrades gracefully (the inner group becomes a heading line).
func (*GHAJobBuffer) PrintBlock ¶
func (b *GHAJobBuffer) PrintBlock(lines []string)
PrintBlock appends multiple lines to the buffer.
func (*GHAJobBuffer) Println ¶
func (b *GHAJobBuffer) Println(line string)
Println appends a line to the buffer.
type GHARenderer ¶
type GHARenderer struct {
// contains filtered or unexported fields
}
GHARenderer emits GitHub Actions-aware output: collapsible log groups, workflow-command annotations, and per-job output buffering so that concurrently executing jobs render as clean, non-interleaved sections in the GitHub Actions log viewer.
Lifecycle:
- JobBuffer(jobID) returns a per-job sink that callers write into freely.
- Group(buf, title, fn) wraps fn's writes in ::group::/::endgroup::.
- FlushStep(jobID) emits and clears the buffer mid-job so each step's output appears live without waiting for the whole job to finish.
- FlushJob(jobID) atomically copies the remaining buffered job output to the underlying writer, guaranteeing groups never interleave across jobs.
Color/ANSI is intentionally disabled inside groups: the GHA log viewer renders ANSI but it is noisier than necessary for CI archives.
func NewGHARenderer ¶
func NewGHARenderer(w io.Writer) *GHARenderer
NewGHARenderer constructs a renderer that writes to w. Pass an os.Stdout-like writer; the renderer takes a write lock around every Flush so callers can share the underlying stream safely.
func (*GHARenderer) Error ¶
func (g *GHARenderer) Error(msg string)
func (*GHARenderer) FlushJob ¶
func (g *GHARenderer) FlushJob(jobID string)
FlushJob writes the job buffer's accumulated content to the underlying writer in a single locked operation, then drops the buffer. Safe to call from concurrent goroutines.
func (*GHARenderer) FlushStep ¶ added in v1.12.7
func (g *GHARenderer) FlushStep(jobID string)
FlushStep writes and clears the job buffer's current content without removing the buffer from the renderer. Called after each step's ::endgroup:: so that step output appears live in the GHA log viewer rather than batching until the entire job completes.
func (*GHARenderer) JobBuffer ¶
func (g *GHARenderer) JobBuffer(jobID string) *GHAJobBuffer
JobBuffer returns the per-job output buffer, lazily creating it on first access. Buffers are isolated per jobID so concurrent jobs do not intermix lines until the explicit FlushJob call.
func (*GHARenderer) Notice ¶
func (g *GHARenderer) Notice(msg string)
Notice/Warning/Error emit GHA workflow-command annotations that surface in the PR check summary and the file-based annotation panel.
func (*GHARenderer) Print ¶
func (g *GHARenderer) Print(line string)
Print writes a top-level (non-grouped) line directly to the underlying writer, locked so it cannot tear with concurrent FlushJob calls.
func (*GHARenderer) PrintBlock ¶
func (g *GHARenderer) PrintBlock(lines []string)
PrintBlock writes multiple top-level lines atomically.
func (*GHARenderer) Warning ¶
func (g *GHARenderer) Warning(msg string)
type LiveRegion ¶
type LiveRegion struct {
// contains filtered or unexported fields
}
LiveRegion renders a transient block below the cursor while still allowing persistent lines to be printed above. The block can show a sticky "header" (status counts, progress) plus a windowed list of in-flight rows grouped by component. On non-TTY writers it degrades to plain append-only output: SetRow/RemoveRow become no-ops and Print just writes a line.
func NewLiveRegion ¶
func NewLiveRegion(w io.Writer, tty, color bool) *LiveRegion
NewLiveRegion constructs a live region.
func (*LiveRegion) Print ¶
func (l *LiveRegion) Print(line string)
Print writes a persistent line above the live region.
func (*LiveRegion) PrintBlock ¶
func (l *LiveRegion) PrintBlock(lines []string)
PrintBlock writes multiple persistent lines above the live region.
func (*LiveRegion) RemoveRow ¶
func (l *LiveRegion) RemoveRow(key string)
RemoveRow drops a row from the live region.
func (*LiveRegion) RowCount ¶
func (l *LiveRegion) RowCount() int
RowCount returns the current number of in-flight rows.
func (*LiveRegion) SetHeaderFunc ¶
func (l *LiveRegion) SetHeaderFunc(fn func(activeRows int) []string)
SetHeaderFunc registers a callback that returns sticky header lines drawn above the active rows on every frame. The callback receives the current number of active rows so callers do not need to call RowCount (which would deadlock because draw holds the mutex). Pass nil to clear.
func (*LiveRegion) SetRow ¶
func (l *LiveRegion) SetRow(key, label string)
SetRow inserts or updates a row by key (no group). For component grouping use SetRowDetail instead.
func (*LiveRegion) SetRowDetail ¶
func (l *LiveRegion) SetRowDetail(key, group, label, tail string)
SetRowDetail upserts a row with optional group label and trailing breadcrumb. Empty group/tail leaves the prior values intact when updating.
func (*LiveRegion) SetWindowMax ¶
func (l *LiveRegion) SetWindowMax(n int)
SetWindowMax caps the number of lines used by the active section.
func (*LiveRegion) Start ¶
func (l *LiveRegion) Start()
Start begins the spinner render goroutine. No-op for non-TTY.
func (*LiveRegion) Stop ¶
func (l *LiveRegion) Stop()
Stop ends the render goroutine and clears the live region.