grouppackages is the Delivery SDK's (ADR 0634) and imports sdk/buildstep and sdk/trunk, not the deleted mesh-sdk/go/delivery. The checker's packagesFor lays the group's tagged versions (design 51) over grouppackages.Heads, so a heard tag still stands before a member's head; the composer and the trunk's manifest validator are built with no tags. Fetches carry the versions in buildstep.Fetch.Packages, so withPackages is gone; the group's fetch names no beside ref, so the test of the node-engine member beside reads its commit alone. Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
95 lines
4.0 KiB
Go
95 lines
4.0 KiB
Go
package check
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"maps"
|
|
|
|
"git.novox.be/novox/mesh-delivery/sdk/buildstep"
|
|
"git.novox.be/novox/mesh-delivery/sdk/grouppackages"
|
|
"git.novox.be/novox/mesh-delivery/sdk/trunk"
|
|
)
|
|
|
|
// **A check builds against the group's own package heads, not against what a member names** (novox/hq ADR 0573 §2, §4;
|
|
// issue 1585). Every Go check ask carries the version of each mesh package to build against (buildstep.StepAsk.Packages):
|
|
// the head of the group's member that publishes it, else its latest published version as the indexer holds it. The build
|
|
// module writes them into the workspace, whatever version or commit a member's go.mod names, so no member is refused
|
|
// for naming no version of the group's package, an older head of it, a merge commit or a commit on no pull request: that
|
|
// refusal (issue 1624's pin check) was a fault of the check (§4), and is gone.
|
|
|
|
// SDKRepository is the repository of mesh-sdk, and SDKModulePath its Go module.
|
|
const (
|
|
SDKRepository = "novox/mesh-sdk"
|
|
SDKModulePath = "git.novox.be/novox/mesh-sdk/go"
|
|
)
|
|
|
|
// ErrNotFound is what Forge.File wraps when the ref holds no such file (the forge answered 404): a file the ref does not hold,
|
|
// told from a forge that could not be read (issue 1845).
|
|
var ErrNotFound = errors.New("the ref holds no such file")
|
|
|
|
// Forge reads a file of a repository at a ref.
|
|
type Forge interface {
|
|
// File is the text of a file at a ref (a branch, a tag or a commit).
|
|
File(ctx context.Context, repository, path, ref string) (string, error)
|
|
}
|
|
|
|
// packagesOf is the version of each mesh package a Go build of repository (a check ask, the judge, the composer) builds
|
|
// against (ADR 0573 §2, §4, as ADR 0607 §5 changes §4): packagesFor over the latest published version of each package the
|
|
// mesh's modules use (Published), the heads of the case's pull requests and the group's tagged versions the check heard
|
|
// (design 51 *Tagged versions*). Nil for none.
|
|
func (st *state) packagesOf(repository string) buildstep.PackageVersions {
|
|
return packagesFor(st.j.Published, st.c, st.tags.goPackages, repository)
|
|
}
|
|
|
|
// packagesFor is packagesOf for a case, the published versions and the tagged ones: every producer of a build at a group's
|
|
// heads takes its versions from here, so none leaves a member out (issue 1921). grouppackages.Heads names each package at
|
|
// its member's head, also a member that publishes no package yet; then, for a package a member of the case publishes, the
|
|
// group's tagged version of it once heard stands instead of the head, also for a package new in the group, which has no
|
|
// published version yet. A package of repository itself comes with the tree the build fetched, and is left out.
|
|
func packagesFor(published interface {
|
|
LatestPackages() buildstep.PackageVersions
|
|
}, c *Case, tagged buildstep.PackageVersions, repository string) buildstep.PackageVersions {
|
|
latest := buildstep.PackageVersions{}
|
|
if published != nil {
|
|
maps.Copy(latest, published.LatestPackages())
|
|
}
|
|
for pkg := range tagged {
|
|
if _, named := latest[pkg]; !named {
|
|
latest[pkg] = ""
|
|
}
|
|
}
|
|
heads := map[string]string{}
|
|
for _, m := range c.Pulls {
|
|
heads[m.Repository] = m.Head
|
|
}
|
|
versions := grouppackages.Heads(latest, heads, repository)
|
|
for pkg, tag := range tagged {
|
|
repo, _, ok := trunk.PackageRepository(pkg)
|
|
if tag == "" || !ok || trunk.SameRepository(repo, repository) {
|
|
continue
|
|
}
|
|
if versions == nil {
|
|
versions = buildstep.PackageVersions{}
|
|
}
|
|
versions[pkg] = tag
|
|
}
|
|
return versions
|
|
}
|
|
|
|
// unheardWords ends the words of a failed read of the forge that reached nobody: the forge was not heard (UnheardWords).
|
|
func unheardWords(err error) string {
|
|
if isUnheard(err) {
|
|
return " (the forge was " + UnheardWords + ")"
|
|
}
|
|
return ""
|
|
}
|
|
|
|
// forgeMachine is the machine a failed read of the forge is put at: the forge when nobody answered it (no build node is to
|
|
// blame, issue 1820), the build node whose workspace was read otherwise.
|
|
func forgeMachine(err error, node string) string {
|
|
if isUnheard(err) {
|
|
return "forge"
|
|
}
|
|
return node
|
|
}
|