diff --git a/modules/mesh-build-go/cmd/mesh-build-go/versions.go b/modules/mesh-build-go/cmd/mesh-build-go/versions.go index 726319b6..9e050788 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/versions.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/versions.go @@ -10,7 +10,11 @@ package main // written beside it, which go mod verify then checks the downloaded module against; // - a commit Go cannot fetch (the head of a group's pull request) is found among the forge's pull request heads and // placed beside the workspace, and the modfile replaces the package by it, as a pin on a head is (pins.go); -// - a version go.mod names is the oldest the module accepts: one newer than the asked is built, and said loudly. +// - a version go.mod names is the oldest the module accepts: one newer than the asked is built, and said loudly; +// - a semantic version (a delivery group's tagged version, `v0.1.15-feat-x.2`: novox/hq ADR 0607 §3, §5, design 51 +// *Tagged versions*) is fetched by that version through the Go seat and built whatever go.mod names, since the +// group's check is of that version; one the Go seat does not hold fails the fetch naming it, and is never looked for +// among the pull request heads. // // Each package's outcome is named in the module's log and in the fetch's answer (FetchResult.Packages). @@ -98,10 +102,16 @@ func (m *Module) takeVersion(ctx context.Context, root, dir string, tv *TakenVer return err } pinsDir := filepath.Dir(modfile) + tagged := delivery.PackageSemver.MatchString(tv.Asked) r := m.Run(ctx, m.goEnv(), "go", "-C", pinsDir, "mod", "download", "-json", tv.Package+"@"+tv.Asked) var info downloadInfo _ = json.Unmarshal([]byte(r.Stdout), &info) - if r.Status != 0 || r.Err != "" || info.Version == "" || info.Error != "" { + failed := r.Status != 0 || r.Err != "" || info.Version == "" || info.Error != "" + if failed && tagged { + failure := strings.TrimSpace(info.Error + "\n" + r.Err + "\n" + r.Stderr) + return fmt.Errorf("downloading the group's tagged version %s of %s through the Go seat failed (a download failure that may be retaken): %s", tv.Asked, tv.Package, causeLine(failure)) + } + if failed { // Not a commit Go can fetch: the head of a group's pull request (ADR 0573 §4), placed from the forge's heads. // Whether it is one is the forge's fact (placePin), whatever go said. failure := strings.TrimSpace(info.Error + "\n" + r.Err + "\n" + r.Stderr) @@ -125,7 +135,9 @@ func (m *Module) takeVersion(ctx context.Context, root, dir string, tv *TakenVer tv.Built, tv.Said = tv.Asked, "Go cannot fetch it: placed from the pull request's head, which has no checksum" return nil } - if compareVersions(tv.Named, info.Version) > 0 { + if tagged && compareVersions(tv.Named, info.Version) > 0 { + tv.Said = fmt.Sprintf("go.mod names %s, newer than the group's tagged version %s, which is built: the group's check is of its tagged version (ADR 0607 §3)", tv.Named, info.Version) + } else if compareVersions(tv.Named, info.Version) > 0 { // A version go.mod names is the oldest the module accepts (ADR 0573 §2): said loudly, and go.mod's is built. tv.Built = tv.Named tv.Said = fmt.Sprintf("go.mod names %s, newer than the asked %s, so go.mod's is built (a version a repository names is the oldest it accepts, ADR 0573 §2)", tv.Named, info.Version) diff --git a/modules/mesh-build-go/cmd/mesh-build-go/versions_test.go b/modules/mesh-build-go/cmd/mesh-build-go/versions_test.go index 3d28eafd..7ba2633f 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/versions_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/versions_test.go @@ -50,6 +50,16 @@ func TestAnAskedVersionIsWrittenIntoTheModfileWhateverGoModNames(t *testing.T) { {name: "a forge that cannot be listed is retaken", asked: commitSHA, failing: true, forgeDown: true, failsWith: "unable to access the forge", answer: `{"Path":"` + sdk + `","Error":"invalid version: unknown revision ` + pinShort + `"}`}, + // ADR 0607 §3, §5 (design 51 *Tagged versions*): a group's tagged version is fetched by that version and built + // whatever go.mod names; one the Go seat lacks fails naming it, never looked for among the pull request heads. + {name: "a group's tagged version", asked: "v0.1.15-feat-x.2", + answer: `{"Path":"` + sdk + `","Version":"v0.1.15-feat-x.2","Sum":"h1:zip=","GoModSum":"h1:mod="}`, + built: "v0.1.15-feat-x.2", edit: "-require=" + sdk + "@v0.1.15-feat-x.2"}, + {name: "a group's tagged version older than go.mod's", asked: "v0.1.14-feat-x.2", + answer: `{"Path":"` + sdk + `","Version":"v0.1.14-feat-x.2","Sum":"h1:zip=","GoModSum":"h1:mod="}`, + built: "v0.1.14-feat-x.2", said: "the group's tagged version", edit: "-require=" + sdk + "@v0.1.14-feat-x.2"}, + {name: "a tagged version the Go seat lacks", asked: "v0.1.15-feat-x.3", failing: true, failsWith: "the group's tagged version v0.1.15-feat-x.3", + answer: `{"Path":"` + sdk + `","Error":"` + sdk + `@v0.1.15-feat-x.3: reading https://seat/go/@v/v0.1.15-feat-x.3.info: 404 Not Found"}`}, {name: "a refused connection is no pin", asked: offHead, failing: true, failsWith: "connection refused", answer: `{"Path":"` + sdk + `","Error":"git ls-remote -q origin in /tmp/gopath: dial tcp 10.10.0.1:443: connect: connection refused"}`}, } {