report

package
v0.2.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArtifactKindCommands          = "commands"
	ArtifactKindFailureScreenshot = "failure-screenshot"
	ArtifactKindJUnit             = "junit"
	ArtifactKindManifest          = "manifest"
	ManifestSchemaVersion         = "flowbaton.artifacts/v1"
)
View Source
const CommandsSchemaVersion = "flowbaton.commands/v1"

CommandsSchemaVersion identifies the on-disk commands.json contract.

Variables

This section is empty.

Functions

func MarshalCommands

func MarshalCommands(flow FlowResult) ([]byte, error)

MarshalCommands renders a canonical commands.json document. It sorts copies of sequence-bearing and artifact fields and never mutates the supplied DTO.

func MarshalHTML

func MarshalHTML(options HTMLOptions, flows []FlowResult) ([]byte, error)

MarshalHTML renders the run as a self-contained document.

Self-contained is a requirement, not a choice: a report is opened from a CI artifact bundle, offline, long after the run. Anything fetched over the network renders as a broken page at exactly the moment somebody needs it.

func MarshalJUnit

func MarshalJUnit(options JUnitOptions, flows []FlowResult) ([]byte, error)

MarshalJUnit renders one testcase per flow. Failed flows become failures, skipped and cancelled flows become skipped testcases, and warned flows are successes because optional-command failures do not fail the flow.

func SanitizeFlowName

func SanitizeFlowName(name string) string

SanitizeFlowName returns a portable ASCII path component for flow artifacts.

Types

type Artifact

type Artifact struct {
	Kind string `json:"kind"`
	Path string `json:"path"`
}

Artifact identifies an output-root-relative file produced for a result.

type CommandResult

type CommandResult struct {
	Sequence       int64             `json:"sequence"`
	Depth          int               `json:"depth"`
	Keyword        string            `json:"keyword"`
	Description    string            `json:"description"`
	Status         Status            `json:"status"`
	StartedAt      time.Time         `json:"startedAt"`
	EndedAt        time.Time         `json:"endedAt"`
	DurationMillis int64             `json:"durationMillis"`
	Failure        *Failure          `json:"failure"`
	Metadata       map[string]string `json:"metadata"`
	Artifacts      []Artifact        `json:"artifacts"`
}

CommandResult is the engine-neutral report shape for one executed command.

type Failure

type Failure struct {
	Message string `json:"message"`
	Details string `json:"details"`
}

Failure carries a consumer-safe failure summary and optional detail.

type FlowResult

type FlowResult struct {
	Name string `json:"name"`
	// File is the flow's path relative to the run root, which is what the
	// JUnit report's file= attribute carries. Separate from Description
	// (the absolute path) because the contract reports sub/alpha.yaml, and
	// only the caller that knows the root can work that out.
	File           string            `json:"file,omitempty"`
	Description    string            `json:"description"`
	Status         Status            `json:"status"`
	StartedAt      time.Time         `json:"startedAt"`
	EndedAt        time.Time         `json:"endedAt"`
	DurationMillis int64             `json:"durationMillis"`
	Failure        *Failure          `json:"failure"`
	Metadata       map[string]string `json:"metadata"`
	Artifacts      []Artifact        `json:"artifacts"`
	Commands       []CommandResult   `json:"commands"`
}

FlowResult is the engine-neutral report shape for one executed flow.

func FromEngineFlowResult

func FromEngineFlowResult(result engine.FlowResult, config model.Config) (FlowResult, error)

FromEngineFlowResult converts one immutable engine result into the report v1 DTO without transferring ownership of engine state.

type HTMLOptions

type HTMLOptions struct {
	// SuiteName titles the report. Blank falls back to a generic title.
	SuiteName string
	// Timestamp is the run's own notion of now. Taken from the caller for the
	// same reason JUnitOptions takes one: two identical runs must render
	// identical bytes.
	Timestamp time.Time
	// Detailed selects HTML-DETAILED, which lists each flow's steps. The step
	// list is the whole difference between the two formats.
	Detailed bool
}

HTMLOptions configures one rendered report.

type JUnitOptions

type JUnitOptions struct {
	SuiteName string
	// Device names the device the suite ran on. Empty omits the attribute rather
	// than inventing a value the host did not request from the driver.
	Device    string
	Timestamp time.Time
}

JUnitOptions supplies suite-level values that must remain fixed across repeated renders. MarshalJUnit never reads the wall clock.

type Status

type Status string

Status is the terminal outcome of a flow or command.

const (
	Completed Status = "Completed"
	Skipped   Status = "Skipped"
	Warned    Status = "Warned"
	Failed    Status = "Failed"
	Cancelled Status = "Cancelled"
)

func (Status) Valid

func (status Status) Valid() bool

Valid reports whether status is part of the stable result contract.

type Writer

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

Writer owns report files beneath one injected output root. It records a file only after the write succeeds, and all returned paths are relative to root.

func NewWriter

func NewWriter(root string) (*Writer, error)

NewWriter prepares an output-root-bound artifact writer.

func (*Writer) RegisterArtifact

func (writer *Writer) RegisterArtifact(kind, relativePath string) (Artifact, error)

RegisterArtifact records an already-finalized regular file beneath the output root without rewriting it.

func (*Writer) WriteArtifact

func (writer *Writer) WriteArtifact(kind, relativePath string, data []byte) (Artifact, error)

WriteArtifact writes arbitrary writer-owned bytes beneath the output root and records the resulting artifact for the manifest.

func (*Writer) WriteCommands

func (writer *Writer) WriteCommands(flow FlowResult) (Artifact, error)

WriteCommands creates <sanitized-flow>/commands.json.

func (*Writer) WriteFailureScreenshot

func (writer *Writer) WriteFailureScreenshot(flowName string, sequence int64, data []byte) (Artifact, error)

WriteFailureScreenshot writes the provided bytes unchanged.

func (*Writer) WriteJUnit

func (writer *Writer) WriteJUnit(options JUnitOptions, flows []FlowResult) (Artifact, error)

WriteJUnit creates the suite-wide junit.xml artifact.

func (*Writer) WriteManifest

func (writer *Writer) WriteManifest() (Artifact, error)

WriteManifest creates artifacts.json from writer-created files that still exist as regular files. The manifest intentionally does not list itself.

Jump to

Keyboard shortcuts

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