diff --git a/go/delivery/stepasks.go b/go/delivery/stepasks.go index 85da720..110cd21 100644 --- a/go/delivery/stepasks.go +++ b/go/delivery/stepasks.go @@ -266,17 +266,19 @@ type StepAsk struct { } // PackageVersions are the versions of the mesh packages a build or a check builds against, by package (a Go module's -// path), each a full commit (novox/hq ADR 0573 §2). +// path): each a full commit (novox/hq ADR 0573 §2), or a Go semantic version, the form a delivery group's check names the +// group's tagged version in (`v0.1.15-feat-x.2`, ADR 0607 §3, §5; design 51 *Tagged versions*). type PackageVersions map[string]string -// Check refuses a package that is no module path or a version that is no full commit, naming it. +// Check refuses a package that is no module path or a version that is neither a full commit nor a Go semantic version, +// naming it. func (p PackageVersions) Check() error { for pkg, version := range p { if pkg == "" || strings.ContainsAny(pkg, " \t\n@") || strings.HasPrefix(pkg, "/") { return fmt.Errorf("delivery: the package %q is no module path", pkg) } - if !askCommitOK.MatchString(version) { - return fmt.Errorf("delivery: the package %s names the version %q, which is no full commit", pkg, version) + if !askCommitOK.MatchString(version) && !PackageSemver.MatchString(version) { + return fmt.Errorf("delivery: the package %s names the version %q, which is neither a full commit nor a Go semantic version (v0.1.15-feat-x.2)", pkg, version) } } return nil @@ -527,6 +529,10 @@ func (c CheckJob) check(id string) error { var askCommitOK = regexp.MustCompile(`^[0-9a-f]{40}$`) +// PackageSemver is a Go semantic version a package may be named at (PackageVersions): v, three numbers, and an optional +// pre-release of Semantic Versioning's characters (a tagged version's, ADR 0607 §1). +var PackageSemver = regexp.MustCompile(`^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$`) + // checkFetchArgs refuses fetch arguments with no repository or no full commit; the rest is the build module's fetch to // judge, as a direct call's is. func checkFetchArgs(id string, args map[string]any) error { diff --git a/go/delivery/stepasks_test.go b/go/delivery/stepasks_test.go index 0dcc50f..bcdcc41 100644 --- a/go/delivery/stepasks_test.go +++ b/go/delivery/stepasks_test.go @@ -28,7 +28,8 @@ func checkAsk() StepAsk { Check: &CheckJob{Fetch: map[string]any{"repository": "novox/mesh-catalog", "commit": askCommit, "ref": "refs/pull/3/head", "base": askCommit}, Levels: []string{LevelUnit, LevelIntegration}, Kept: true, Runner: "workspace", RunnerWhen: "modules/mesh-build-go/", Run: "", NodeNames: []string{"anchor", "laptop"}}, - Packages: PackageVersions{"git.novox.be/novox/mesh-sdk/go": askCommit, "git.novox.be/novox/mesh-controller/modules/route-proxy/contract": askCommit}} + Packages: PackageVersions{"git.novox.be/novox/mesh-sdk/go": askCommit, "git.novox.be/novox/mesh-controller/modules/route-proxy/contract": askCommit, + "git.novox.be/novox/mesh-contracts/go": "v0.1.15-feat-x.2"}} // ADR 0607 §5: a group's tagged version } // 1887/A1a: an ask encodes and decodes with every field; 1585/S4: the package versions too. @@ -61,9 +62,11 @@ func TestAskRefusesUnknownKindAndLanguage(t *testing.T) { "commit": func(a *StepAsk) { a.Build.Fetch = map[string]any{"repository": "novox/x", "commit": "main"} }, "path": func(a *StepAsk) { a.Build.Path = "" }, "needs": func(a *StepAsk) { a.Needs = []string{NeedNodeBuildNode} }, // issue 890: a build needs no node - // Issue 1585: a package's version is a full commit, of a module path. - "version": func(a *StepAsk) { a.Packages["git.novox.be/novox/mesh-sdk/go"] = "v0.1.7" }, - "package": func(a *StepAsk) { a.Packages["git.novox.be/novox/x y"] = askCommit }, + // Issue 1585, ADR 0607 §5: a package's version is a full commit or a Go semantic version, of a module path. + "version": func(a *StepAsk) { a.Packages["git.novox.be/novox/mesh-sdk/go"] = "main" }, + "no v": func(a *StepAsk) { a.Packages["git.novox.be/novox/mesh-sdk/go"] = "0.1.15-feat-x.2" }, + "pre-chars": func(a *StepAsk) { a.Packages["git.novox.be/novox/mesh-sdk/go"] = "v0.1.15-feat/x.2" }, + "package": func(a *StepAsk) { a.Packages["git.novox.be/novox/x y"] = askCommit }, "compose": func(a *StepAsk) { a.Kind, a.Build = AskCheck, nil a.Compose = &ComposeJob{Fetch: map[string]any{"repository": "novox/mesh-sdk", "commit": askCommit}, Dir: "go", Package: "x", Request: json.RawMessage(`{}`)}