111 lines
4.8 KiB
Go
111 lines
4.8 KiB
Go
package check
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
)
|
|
|
|
// The shapes of what the build modules' steps answer, as their code writes them (mesh-catalog modules/mesh-build-go
|
|
// cmd/mesh-build-go levels.go TestResult, digest.go DigestResult, fetch.go FetchResult; modules/mesh-build-node
|
|
// cmd/mesh-build-node check.go TestResult, fetch.go FetchResult) with the fields the fetch step adds for a merge (ADR 0484
|
|
// clause 3). Only the fields the checker reads are named; the rest is ignored.
|
|
|
|
// MergeTree is what a fetch that merged says of one module directory: the tree sha, the digest of its manifest, the
|
|
// hashes of its lock files by name and the objects of its named paths. A bare string is the tree alone.
|
|
type MergeTree struct {
|
|
Tree string `json:"tree"`
|
|
Manifest string `json:"manifest,omitempty"`
|
|
Locks map[string]string `json:"locks,omitempty"`
|
|
// Paths are, of a module whose every artifact names its paths, each named path's object; Tree is then their named
|
|
// tree (mesh-sdk buildstep.ModuleTree, novox/hq ADR 0499 clause 2).
|
|
Paths map[string]string `json:"paths,omitempty"`
|
|
}
|
|
|
|
// UnmarshalJSON takes a string as the tree alone, or an object.
|
|
func (t *MergeTree) UnmarshalJSON(data []byte) error {
|
|
if s := strings.TrimSpace(string(data)); strings.HasPrefix(s, `"`) {
|
|
return json.Unmarshal(data, &t.Tree)
|
|
}
|
|
type plain MergeTree
|
|
return json.Unmarshal(data, (*plain)(t))
|
|
}
|
|
|
|
// Fetched is the answer of a build module's fetch step.
|
|
type Fetched struct {
|
|
Workspace string `json:"workspace"`
|
|
Commit string `json:"commit"`
|
|
Modules []string `json:"modules"`
|
|
// What a fetch with a base adds: the trunk commit, the merge commit, the files in conflict (a conflict is an answer),
|
|
// the paths the merge changes and the trees of the module directories.
|
|
Base string `json:"base,omitempty"`
|
|
Merge string `json:"merge,omitempty"`
|
|
Conflicts []string `json:"conflicts,omitempty"`
|
|
Changed []string `json:"changed,omitempty"`
|
|
Trees map[string]MergeTree `json:"trees,omitempty"`
|
|
}
|
|
|
|
// GoPackage is one package of a Go test result.
|
|
type GoPackage struct {
|
|
Dir string `json:"dir"`
|
|
Package string `json:"package"`
|
|
Passed bool `json:"passed"`
|
|
Elapsed float64 `json:"elapsed"`
|
|
Tests int `json:"tests"`
|
|
NoTests bool `json:"no_tests,omitempty"`
|
|
}
|
|
|
|
// Failure is a test that failed, or a package that failed with no test to name.
|
|
type Failure struct {
|
|
Package string `json:"package"`
|
|
Test string `json:"test,omitempty"`
|
|
Output string `json:"output,omitempty"`
|
|
// Cause is the first line of what the test reported as its error, when the build module told it apart (issue 1901).
|
|
Cause string `json:"cause,omitempty"`
|
|
}
|
|
|
|
// TestTime is one test and the seconds it took.
|
|
type TestTime struct {
|
|
Package string `json:"package"`
|
|
Test string `json:"test"`
|
|
Elapsed float64 `json:"elapsed"`
|
|
}
|
|
|
|
// Tested is the answer of a test step of either build module (the Go one names packages and counts tests; the Node one
|
|
// names the package directory as Module and counts none).
|
|
type Tested struct {
|
|
Level string `json:"level"`
|
|
Module string `json:"module,omitempty"`
|
|
Passed bool `json:"passed"`
|
|
Why string `json:"why,omitempty"`
|
|
NoTests bool `json:"no_tests,omitempty"`
|
|
Tests int `json:"tests"`
|
|
Skipped int `json:"skipped"`
|
|
Packages []GoPackage `json:"packages,omitempty"`
|
|
Elapsed float64 `json:"elapsed"`
|
|
Setup float64 `json:"setup,omitempty"`
|
|
// Lint is the unit level's gofmt and go vet time, before its tests (mesh-build-go, ADR 0529 §1).
|
|
Lint float64 `json:"lint,omitempty"`
|
|
Bound float64 `json:"bound"`
|
|
SetupBound float64 `json:"setup_bound,omitempty"`
|
|
Slowest []TestTime `json:"slowest,omitempty"`
|
|
Failed []Failure `json:"failed,omitempty"`
|
|
OverBound bool `json:"over_bound"`
|
|
OverWhich string `json:"over_which,omitempty"`
|
|
// JudgedBy is the program that ran the step (ADR 0535 §5): "installed", or "candidate <merge commit>" under runner
|
|
// workspace; absent from a build module that does not take the runner.
|
|
JudgedBy string `json:"judged_by,omitempty"`
|
|
}
|
|
|
|
// Digested is the answer of the Go build module's digest step: one digest per package that has tests at the level, by import
|
|
// path.
|
|
type Digested struct {
|
|
// Beside are the lines `<owner/repo> <commit>` of the siblings the digest folded in (DigestVersion 3, lead decision L5),
|
|
// sorted; absent when the workspace has none or the build module folds none in.
|
|
Beside []string `json:"beside,omitempty"`
|
|
Level string `json:"level"`
|
|
Packages map[string]string `json:"packages"`
|
|
WithoutTests []string `json:"without_tests,omitempty"`
|
|
// JudgedBy is the program that ran the digest, as Tested.JudgedBy says.
|
|
JudgedBy string `json:"judged_by,omitempty"`
|
|
}
|