package check import ( "context" "errors" "maps" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/grouppackages" ) // **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) and the heads of the case's pull requests. Nil for none. func (st *state) packagesOf(repository string) buildstep.PackageVersions { return packagesFor(st.j.Published, st.c, repository) } // packagesFor is packagesOf for a case and the published versions: 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. 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, repository string) buildstep.PackageVersions { latest := buildstep.PackageVersions{} if published != nil { maps.Copy(latest, published.LatestPackages()) } heads := map[string]string{} for _, m := range c.Pulls { heads[m.Repository] = m.Head } versions := grouppackages.Heads(latest, heads, repository) 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 }