The controller asks no build of anybody (ADR 0501 §5, ADR 0525 clause 6, ADR 0503 §3). Every module of a walk is taken from the builder's done key; a key not done yet waits, named in the plan, and never fails it. - C2b/C2c: internal/builder and cmd/mesh-controller's asks go (askABuild, onlyTheBuildersOwn, buildOneAsked, takeIn from an outcome, buildAgentsOwn, the builder's say and its fallback, the daemon hearing an outcome). The server follows the retired seats' built subjects only to let go of them, because the installer's carried user list names them. - C2d: replay, queue, cancel, clear, kill, pause, resume, delivery-check, check-here and merge-gate are refused by name. - C3: the check queues (CHECKS_READY, CHECKS_OTHER) and their workers, the checks-running and plans-building buckets and their grants, the build queue and its hold (plans_building.go, queue.go, link/holds.go, builds_nats.go, checks_nats.go). - C4: merge_gate*.go, the pull request's repo-check path, the Checked event and its layers; a pull request asks the controller nothing but to tell mesh-config what its head declares. - C5: the builds bucket is written only by key_takein. - C10 (help and refusals): the terminal's help lists only what is served. Integration tests of the plan's tiers, sends, stops and retries now run on a stand-in builder with a done key for every module (walk_keys_scaffold_integration_test.go); the tests of the asks, the queue, the merge gate and the replays are deleted.
112 lines
4.9 KiB
Go
112 lines
4.9 KiB
Go
package link
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/delivery"
|
|
)
|
|
|
|
// The shape of a build's outcome as the retired build seat said it (novox/hq ADR 0121, ADR 0501 §1). Nothing asks a
|
|
// build or hears an outcome any more (R4g): a module is registered from the builder's done key. The shape stays for the
|
|
// tests of what registration judges (who may register a module, from which source, against which list of predefined
|
|
// keys), which hand a build to the controller in this form; it carries nothing of the retired merge check.
|
|
|
|
// NewBuildID is the correlation for a build asked at that moment: `build-<unix nanoseconds>`, and BuildAskedAt reads the
|
|
// moment back (novox/hq 04-ISSUES/219): what orders two builds of one module.
|
|
func NewBuildID(asked time.Time) string {
|
|
return "build-" + strconv.FormatInt(asked.UnixNano(), 10)
|
|
}
|
|
|
|
// BuildAskedAt is when the build with this id was asked, as NewBuildID wrote it; false for an id of any other shape.
|
|
func BuildAskedAt(id string) (time.Time, bool) {
|
|
digits, ok := strings.CutPrefix(id, "build-")
|
|
if !ok || digits == "" {
|
|
return time.Time{}, false
|
|
}
|
|
nanos, err := strconv.ParseInt(digits, 10, 64)
|
|
if err != nil || nanos < time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC).UnixNano() {
|
|
return time.Time{}, false
|
|
}
|
|
return time.Unix(0, nanos).UTC(), true
|
|
}
|
|
|
|
// SourceOnSeat names a repository by the seat whose holder serves it and its path there.
|
|
type SourceOnSeat struct {
|
|
Seat string `json:"seat"`
|
|
Repository string `json:"repository"`
|
|
}
|
|
|
|
// BuildResult is what a builder said back.
|
|
type BuildResult struct {
|
|
ID string `json:"id"`
|
|
Repository string `json:"repository"`
|
|
// Path is echoed back, so what the mesh records as this module's source is what was actually built.
|
|
Path string `json:"path,omitempty"`
|
|
Ref string `json:"ref,omitempty"`
|
|
// On is the machine that did it.
|
|
On string `json:"on"`
|
|
// Module is what was built, read out of the manifest.
|
|
Module string `json:"module,omitempty"`
|
|
// Commit is what was actually built.
|
|
Commit string `json:"commit,omitempty"`
|
|
// Manifest is the module as the mesh should hold it, artifacts resolved to digests.
|
|
Manifest json.RawMessage `json:"manifest,omitempty"`
|
|
// Made is each artifact, for reporting.
|
|
Made []MadeArtifact `json:"made,omitempty"`
|
|
// Against is every pinned image this was built on top of.
|
|
Against []string `json:"against,omitempty"`
|
|
// Mirrored is every base this build copied into the artifact store, as pinned (novox/hq ADR 0257).
|
|
Mirrored []string `json:"mirrored,omitempty"`
|
|
// Read is every repository this build read source from besides the module's own.
|
|
Read []ReadRepository `json:"read,omitempty"`
|
|
// Sources are what the build was made from, as files, per repository (novox/hq ADR 0267).
|
|
Sources []BuildSource `json:"sources,omitempty"`
|
|
// Trunk is the repository's default branch at the build, OnTrunk whether the commit built is on it, and Branches
|
|
// every branch it is on (novox/hq ADR 0238).
|
|
Trunk string `json:"trunk,omitempty"`
|
|
OnTrunk bool `json:"on-trunk,omitempty"`
|
|
Branches []string `json:"branches,omitempty"`
|
|
// SourceFingerprint is what the build was made from, hashed (novox/hq issue 280); SourceInputs what it was computed
|
|
// from (ADR 0437 §5, issue 1215).
|
|
SourceFingerprint string `json:"source-fingerprint,omitempty"`
|
|
SourceInputs *delivery.SourceInputs `json:"source-inputs,omitempty"`
|
|
// Failed is why, when it did.
|
|
Failed string `json:"failed,omitempty"`
|
|
// Predefined is the list of predefined keys at the root of the repository at the commit built (novox/hq ADR 0348 §7).
|
|
Predefined *PredefinedList `json:"predefined,omitempty"`
|
|
// Source is the request's, echoed: the seat form of the repository, for whoever registers.
|
|
Source *SourceOnSeat `json:"source,omitempty"`
|
|
// DryRun is the request's, echoed: an outcome nobody may take in (novox/hq issue 240).
|
|
DryRun bool `json:"dry-run,omitempty"`
|
|
}
|
|
|
|
// PredefinedList is the list of predefined keys a build read (novox/hq ADR 0348 §7): Keys its canonical text, a
|
|
// JSON object of keys, and Generation how many commits the commit built stands on.
|
|
type PredefinedList struct {
|
|
Keys json.RawMessage `json:"keys"`
|
|
Generation int `json:"generation,omitempty"`
|
|
}
|
|
|
|
// ReadRepository is a repository a build read source from besides the module's own, at the ref it read.
|
|
type ReadRepository struct {
|
|
Repository string `json:"repository"`
|
|
Ref string `json:"ref,omitempty"`
|
|
}
|
|
|
|
// BuildSource is the build source a build read in one repository (novox/hq ADR 0267).
|
|
type BuildSource struct {
|
|
Repository string `json:"repository,omitempty"`
|
|
Ref string `json:"ref,omitempty"`
|
|
Paths []string `json:"paths"`
|
|
}
|
|
|
|
// MadeArtifact is one thing a build produced, as a person would want it reported.
|
|
type MadeArtifact struct {
|
|
Name string `json:"name"`
|
|
Kind string `json:"kind"`
|
|
Reference string `json:"reference"`
|
|
}
|