diff --git a/cmd/releasekit/source_test.go b/cmd/releasekit/source_test.go index e984166..3f984cc 100644 --- a/cmd/releasekit/source_test.go +++ b/cmd/releasekit/source_test.go @@ -151,3 +151,24 @@ func main() { if len(os.Args) == 2 && os.Args[1] == "version" { fmt.Println("fix t.Fatalf("calendar receipt = %+v, error = %v", receipt, err) } } + +func TestPackagePatternBuildAndReadinessAgree(t *testing.T) { + for _, pattern := range []string{"./...", "example.com/tagged-app/..."} { + t.Run(pattern, func(t *testing.T) { + repo := newDeliveryBuildRepository(t) + profile := fmt.Sprintf(`{"product":"Example Product","build":{"main_package":%q,"binary_name":"helper","targets":[%q]}}`, pattern, runtime.GOOS+"/"+runtime.GOARCH) + writeRepositoryFile(t, repo, "releasekit.json", profile) + cliGitRun(t, repo, "add", "releasekit.json") + cliGitRun(t, repo, "commit", "-m", "configure main package pattern") + var output, diagnostics bytes.Buffer + if code := run(t.Context(), []string{"build", "--repo", repo, "--output", t.TempDir(), "v1.2.3"}, &output, &diagnostics); code != 0 { + t.Fatalf("build code=%d error=%s", code, &diagnostics) + } + output.Reset() + diagnostics.Reset() + if code := run(t.Context(), []string{"validate", "--repo", repo, "--operation", "build", "--offline", "--json"}, &output, &diagnostics); code != 0 || !strings.Contains(output.String(), `"id":"main-package","operation":"build","status":"unchecked"`) { + t.Fatalf("readiness code=%d report=%s error=%s", code, &output, &diagnostics) + } + }) + } +} diff --git a/docs/consumers/readiness.md b/docs/consumers/readiness.md index 65ad7d1..81e6266 100644 --- a/docs/consumers/readiness.md +++ b/docs/consumers/readiness.md @@ -34,6 +34,8 @@ checks readability, not Git authentication. `--assets DIR` selects an existing build receipt and artifacts for identity and digest checks; delivery must be selected. Build outputs are otherwise not required to exist. Dependency-cache completeness and actual build execution remain unchecked. +Go package patterns and external package inputs report resolution as unchecked; +literal local package directories retain their input checks. JSON output is one document with `schema_version: 1`, `command: "validate"`, the working-input scope, selected operations, context, safe credential sources, diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index a45555b..3c2a05c 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -469,6 +469,12 @@ rejection. Assert that production identity and CI routing agree. ## 11. Readiness treats supported Go package patterns as literal directories +**Completed:** Working and committed readers distinguish package patterns from +literal directories and report their resolution as unchecked. Relative and +module-qualified patterns pass readiness and real builds; a captured-pattern +rehearsal reaches dispatch. Missing literal-directory checks remain active. +Focused readiness, builder/CLI, and rehearsal regressions pass. + **Priority:** P2. **Stages:** 7, 12. **Relevant code:** `inspectBuild` and `localMainPackage` in diff --git a/internal/readiness/committed.go b/internal/readiness/committed.go index 499c646..7faf48d 100644 --- a/internal/readiness/committed.go +++ b/internal/readiness/committed.go @@ -35,6 +35,9 @@ func inspectCommittedBuild(ctx context.Context, source releaseidentity.ResolvedS if err := validateBuildSettings(build); err != nil { return err } + if !localMainPackage(source, build.MainPackage) { + return nil + } name := build.MainPackage if name == source.ModulePath { name = "." diff --git a/internal/readiness/committed_test.go b/internal/readiness/committed_test.go index 66d8ebf..727ac78 100644 --- a/internal/readiness/committed_test.go +++ b/internal/readiness/committed_test.go @@ -58,6 +58,24 @@ func TestCommittedReadinessUsesCapturedModuleAndMainPackage(t *testing.T) { t.Fatalf("captured readiness failed: %+v", check) } } + for _, name := range []string{"./...", "example.com/fixture/..."} { + request.Build.MainPackage = name + report := Run(t.Context(), request) + unchecked := false + for _, check := range report.Checks { + if check.Status == "failed" { + t.Fatalf("pattern=%s check=%+v", name, check) + } + if check.ID == "main-package" && check.Status == "unchecked" { + unchecked = true + } + } + if !unchecked { + t.Fatalf("pattern resolution was not identified: %+v", report.Checks) + } + } + request.Build.MainPackage = "." + if err := os.Remove(filepath.Join(repo, "required.txt")); err != nil { t.Fatal(err) } diff --git a/internal/readiness/readiness.go b/internal/readiness/readiness.go index 07e056a..f0b329c 100644 --- a/internal/readiness/readiness.go +++ b/internal/readiness/readiness.go @@ -228,7 +228,7 @@ func Run(ctx context.Context, request Request) Report { buildErr = inspectCommittedBuild(ctx, source, request.Commit, *request.Build) } if report.record("build-inputs", "build", "configuration", buildErr) && !localMainPackage(source, request.Build.MainPackage) { - report.note("main-package", "build", "unchecked", "not_executed", "external package inputs require build execution") + report.note("main-package", "build", "unchecked", "not_executed", "package resolution and build execution were not checked") } } } @@ -315,6 +315,9 @@ func inspectBuild(source releaseidentity.ResolvedSource, build artifact.Settings if err := validateBuildSettings(build); err != nil { return err } + if !localMainPackage(source, build.MainPackage) { + return nil + } name := build.MainPackage if name == source.ModulePath { name = "." @@ -380,7 +383,7 @@ func validateBuildSettings(build artifact.Settings) error { } func localMainPackage(source releaseidentity.ResolvedSource, name string) bool { - return name == "." || strings.HasPrefix(name, "./") || name == source.ModulePath || strings.HasPrefix(name, source.ModulePath+"/") + return !strings.Contains(name, "...") && (name == "." || strings.HasPrefix(name, "./") || name == source.ModulePath || strings.HasPrefix(name, source.ModulePath+"/")) } // CheckCIConfigured validates the declaration independently of job secret injection. diff --git a/internal/rehearsal/coordinator_test.go b/internal/rehearsal/coordinator_test.go index 0312aed..1fceb75 100644 --- a/internal/rehearsal/coordinator_test.go +++ b/internal/rehearsal/coordinator_test.go @@ -17,6 +17,7 @@ import ( "testing" "time" + internalbuild "go.maximumdirect.net/releasekit/internal/build" "go.maximumdirect.net/releasekit/internal/forge" "go.maximumdirect.net/releasekit/internal/git" "go.maximumdirect.net/releasekit/internal/releaseidentity" @@ -333,3 +334,36 @@ func TestStartAmbiguousPushWithUnavailableObservationRetainsEvidence(t *testing. t.Fatalf("local=%v error=%v", local, localErr) } } + +func TestPackagePatternRehearsalReachesDispatch(t *testing.T) { + repo, bare, _ := coordinatorFixture(t) + files := map[string]string{"go.mod": "module example.com/fixture\n\ngo 1.27.0\n", "main.go": "package main\nfunc main() {}\n", "releasekit.json": `{"go":{},"build":{"main_package":"./...","binary_name":"fixture","targets":["linux/amd64"]},"delivery":{"credentials":{"ci":{}}}}`} + for name, body := range files { + if err := os.WriteFile(filepath.Join(repo, name), []byte(body), 0600); err != nil { + t.Fatal(err) + } + } + for _, args := range [][]string{{"add", "."}, {"commit", "-m", "capture Go pattern inputs"}} { + command := exec.Command("git", args...) + command.Dir = repo + if out, err := command.CombinedOutput(); err != nil { + t.Fatalf("git: %v: %s", err, out) + } + } + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/api/repos/42" { + fmt.Fprint(w, `{"id":42}`) + } else { + fmt.Fprint(w, `[]`) + } + })) + defer server.Close() + result, err := Start(t.Context(), StartRequest{RepositoryDir: repo, Product: "Example", Source: &releaseidentity.SourceSpec{GoEnabled: true}, Build: &internalbuild.Spec{MainPackage: "./...", BinaryName: "fixture", Targets: []internalbuild.Target{{OS: "linux", Arch: "amd64"}}}, Backend: readyBackend{}, Woodpecker: woodpecker.Client{BaseURL: server.URL, RepositoryID: 42, Token: "token"}, Workflow: "release", Step: "deliver", CIConfigured: true, ObservationTimeout: 20 * time.Millisecond}) + if !errors.Is(err, context.DeadlineExceeded) || result.Attempt.Outcomes["push"] != "dispatched" { + t.Fatalf("result=%+v error=%v", result, err) + } + command := exec.Command("git", "--git-dir", bare, "rev-parse", "--verify", "refs/tags/"+result.Attempt.Manifest.Tag) + if out, err := command.Output(); err != nil || strings.TrimSpace(string(out)) != result.Attempt.TagObject { + t.Fatalf("dispatch ref=%s error=%v", out, err) + } +}