verify

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package verify runs the gate of an application and reports one record for each step, S16.

`avero verify --json` emits the report, and the MCP tool run_verify returns the same document. The order of the records is the order of the gate, so two runs on one tree give the same order. See AN-3 and AN-4.

Index

Constants

View Source
const (
	// StatusPass marks a step that holds.
	StatusPass = "pass"
	// StatusFail marks a step that does not hold.
	StatusFail = "fail"
)

The status of one record.

View Source
const SchemaID = "https://avero.dev/schema/verify-report/v1"

SchemaID names the schema that a JSON verify report follows. See verify/schema.json.

Variables

View Source
var Schema []byte

Schema holds verify/schema.json. `avero verify --json` emits a document that this schema accepts. See AN-3.

Functions

func Position

func Position(message string) (string, int, int)

Position returns the first position that a message names.

Types

type Record

type Record struct {
	// Name names the step, such as gofmt.
	Name string `json:"name"`
	// Status is pass or fail.
	Status string `json:"status"`
	// DurationMS is the time of the step in milliseconds.
	DurationMS int64 `json:"duration_ms"`
	// Message states the fault. It is empty for a step that passes.
	Message string `json:"message"`
	// File names the file that holds the fault, or the empty string.
	File string `json:"file"`
	// Line names the line that holds the fault, or zero.
	Line int `json:"line"`
	// Column names the column that holds the fault, or zero.
	Column int `json:"column"`
}

Record is one step of the gate.

type Report

type Report struct {
	// OK reports a report with no failed step.
	OK bool `json:"ok"`
	// Records holds one row for each step, in the order of the gate. See
	// AN-4.
	Records []Record `json:"records"`
}

Report is the answer of the gate.

func Run

func Run(ctx context.Context, dir string, steps []Step) *Report

Run performs the gate in dir and returns the report. It returns no error for a failed step, because the report states the failure.

func (*Report) MarshalJSON

func (r *Report) MarshalJSON() ([]byte, error)

MarshalJSON emits the report with a stable schema. See AN-3.

func (*Report) String

func (r *Report) String() string

String returns the table that `avero verify` prints.

type Step

type Step struct {
	// Name names the step.
	Name string
	// Args is the command line, with the program first.
	Args []string
	// Run performs a step that runs no command. It returns the fault, or
	// nil.
	Run func(dir string) error
	// AcceptOutput reports a step that fails when it writes output, although
	// it exits with the code zero. gofmt is such a step.
	AcceptOutput bool
}

Step is one command of the gate. A step with no command runs the function that Run holds for it, so the generated files are proven in this process and the application needs no dependency on the avero binary.

func Steps

func Steps(generate func(dir string) error) []Step

Steps returns the gate of an application, in order. The generate step takes the check of the generated files, which the caller supplies, because the generators live outside this package.

Jump to

Keyboard shortcuts

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