logparser

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanLog

func CleanLog(log string) string

CleanLog applies all cleanup operations to a log.

func FormatFailure

func FormatFailure(f Failure) string

FormatFailure returns a human-readable representation of the failure.

func GroupByName

func GroupByName(failures []Failure) map[string][]Failure

GroupByName groups failures by name (e.g., linter name, test name).

func RegisterParser

func RegisterParser(p Parser)

RegisterParser adds a parser to the registry.

func StripANSI

func StripANSI(log string) string

StripANSI removes ANSI color codes from the log. Input: "=== [31mFAIL[0m: TestName" Output: "=== FAIL: TestName"

func StripJobPrefix

func StripJobPrefix(log string) string

StripJobPrefix removes GitHub Actions job/step prefix from each line. Input: "Test\tRun tests\t2026-01-26... content" Output: "content"

func StripTimestamps

func StripTimestamps(log string) string

StripTimestamps removes CI log timestamp prefixes from each line. Input: "2026-01-26T14:49:40.7760945Z --- FAIL: TestName" Output: "--- FAIL: TestName"

Types

type Failure

type Failure struct {
	Name      string // What failed (test name, lint rule, build target)
	Context   string // Where in codebase (package, module, directory)
	File      string // e.g., "triggered_broadcast_test.go"
	Line      int    // e.g., 203
	Column    int    // e.g., 15 (0 if not applicable)
	Message   string // The error/failure message
	RawOutput string // Relevant log snippet for context
}

Failure represents a parsed CI failure (test, lint, build, etc.).

func ParseFailures

func ParseFailures(logContent string) ([]Failure, error)

ParseFailures attempts to parse failures using all registered parsers.

type GoTestParser

type GoTestParser struct{}

GoTestParser parses Go test output, including testify and gotestsum formats.

func (*GoTestParser) CanParse

func (p *GoTestParser) CanParse(logContent string) bool

CanParse returns true if the log contains Go test output.

func (*GoTestParser) Parse

func (p *GoTestParser) Parse(logContent string) ([]Failure, error)

Parse extracts test failures from Go test output.

type LintParser

type LintParser struct{}

LintParser parses golangci-lint output from GitHub Actions logs.

func (*LintParser) CanParse

func (p *LintParser) CanParse(logContent string) bool

CanParse returns true if the log contains golangci-lint output.

func (*LintParser) Parse

func (p *LintParser) Parse(logContent string) ([]Failure, error)

Parse extracts lint errors from the log content.

type Parser

type Parser interface {
	// CanParse returns true if this parser can handle the given log content.
	CanParse(logContent string) bool
	// Parse extracts failures from the log content.
	Parse(logContent string) ([]Failure, error)
}

Parser interface for language-specific implementations.

Jump to

Keyboard shortcuts

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