Distinguish production tags from complete diagnostic tags
This commit is contained in:
@@ -422,7 +422,7 @@ func runCIDelivery(ctx context.Context, invocation cli.Invocation, stdout, stder
|
||||
return 1
|
||||
}
|
||||
|
||||
if strings.HasPrefix(invocation.ExpectedTag, "releasekit-test/") {
|
||||
if releaseidentity.IsDiagnosticTag(invocation.ExpectedTag) {
|
||||
return runDiagnosticDelivery(ctx, invocation, stdout, stderr)
|
||||
}
|
||||
|
||||
|
||||
@@ -49,13 +49,22 @@ func TestMultiModuleSelectorMapsSelectorsAndTags(t *testing.T) {
|
||||
if output := runModuleSelectorError(t, helper, "tag", "feature/v1.2.3", mapPath); !strings.Contains(output, "ambiguous") {
|
||||
t.Fatalf("ambiguous event error = %q", output)
|
||||
}
|
||||
if output := runModuleSelectorError(t, helper, "tag", "releasekit-test/ckconfig/invalid", ""); !strings.Contains(output, "invalid diagnostic") {
|
||||
if output := runModuleSelectorError(t, helper, "tag", "releasekit-test/ckconfig/invalid", ""); !strings.Contains(output, "no module map row") {
|
||||
t.Fatalf("malformed diagnostic error=%q", output)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(mapPath, []byte("space\tfeature/*\tintegrations/ck config\tprofiles/core release.json\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
reservedMap := filepath.Join(t.TempDir(), "production.tsv")
|
||||
if err := os.WriteFile(reservedMap, []byte("product\treleasekit-test/product/*\t-\treleasekit.json\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, tag := range []string{"releasekit-test/product/v1.2.3", "releasekit-test/product/2026-12-01"} {
|
||||
if got := runModuleSelector(t, helper, "tag", tag, reservedMap); !strings.HasPrefix(got, "product\t") {
|
||||
t.Fatalf("production tag=%s mapping=%q", tag, got)
|
||||
}
|
||||
}
|
||||
got := runModuleSelector(t, helper, "tag", "feature/v1.2.3", mapPath)
|
||||
want := "space\tfeature/*\tintegrations/ck config\tprofiles/core release.json"
|
||||
if strings.TrimSpace(got) != want {
|
||||
|
||||
@@ -57,6 +57,39 @@ func TestCIDeliveryChecksFullCalendarTagAgainstProfile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCIDeliveryProductionTagsMayUseDiagnosticPrefix(t *testing.T) {
|
||||
for _, legacy := range []bool{false, true} {
|
||||
t.Run(fmt.Sprintf("legacy=%t", legacy), func(t *testing.T) {
|
||||
repo := newCLIRepository(t)
|
||||
version, tag := "2026-12-01", "releasekit-test/product/2026-12-01"
|
||||
profile := `{"product":"Config","source":{"tag_prefix":"releasekit-test/product"},"version":{"format":"date"}}`
|
||||
note := "docs/releases/" + version + ".md"
|
||||
if legacy {
|
||||
version, tag = "v1.2.3", "releasekit-test/product/v1.2.3"
|
||||
profile = `{"product":"Config","module_dir":"releasekit-test/product"}`
|
||||
note = "releasekit-test/product/docs/releases/" + version + ".md"
|
||||
writeRepositoryFile(t, repo, "releasekit-test/product/go.mod", "module example.com/product\n\ngo 1.27.0\n")
|
||||
writeRepositoryFile(t, repo, "releasekit-test/product/product.go", "package product\n")
|
||||
}
|
||||
writeRepositoryFile(t, repo, note, "# Config "+version+"\n")
|
||||
writeRepositoryFile(t, repo, "releasekit.json", profile)
|
||||
cliGitRun(t, repo, "add", ".")
|
||||
cliGitRun(t, repo, "commit", "-m", "configure production tag prefix")
|
||||
var out, diag bytes.Buffer
|
||||
if code := run(t.Context(), []string{"check", "--repo", repo, version}, &out, &diag); code != 0 {
|
||||
t.Fatalf("check code=%d diagnostic=%s", code, &diag)
|
||||
}
|
||||
commit := cliGitOutput(t, repo, "rev-parse", "HEAD")
|
||||
cliGitRun(t, repo, "tag", "-a", "-m", "# Config "+version, tag)
|
||||
out.Reset()
|
||||
diag.Reset()
|
||||
if code := run(t.Context(), []string{"ci-deliver", "--repo", repo, "--prepared", "--commit", commit, tag}, &out, &diag); code != 2 || !strings.Contains(diag.String(), "delivery.forge") {
|
||||
t.Fatalf("production dispatch code=%d output=%s diagnostics=%s", code, &out, &diag)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSourceCheckCommandUsesSelectedDirectoryAndEnvironment(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("POSIX shell check")
|
||||
|
||||
@@ -181,6 +181,31 @@ func TestWoodpeckerTagDeliveryTemplate(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestSingleProductWorkflowClassifiesCompleteDiagnosticTags(t *testing.T) {
|
||||
for _, file := range []string{"examples/woodpecker/tag-delivery.yml", "examples/woodpecker/releasekit-source-delivery.yml", "examples/source-only/.woodpecker/delivery.yml"} {
|
||||
t.Run(file, func(t *testing.T) {
|
||||
body := readWorkflowFile(t, cliRepositoryRoot(t), file)
|
||||
block, err := extractWoodpeckerCommand(body, "deliver")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
guard, _, ok := strings.Cut(block, "git check-ref-format")
|
||||
if !ok {
|
||||
t.Fatal("workflow has no tag preparation boundary")
|
||||
}
|
||||
guard = strings.ReplaceAll(guard, "$${", "${")
|
||||
for _, tag := range []string{"releasekit-test/product/v1.2.3", "releasekit-test/product/2026-12-01", "releasekit-test/root/" + strings.Repeat("a", 32)} {
|
||||
if output, err := executeWoodpeckerBlock(guard, t.TempDir(), map[string]string{"CI_COMMIT_TAG": tag, "CI_COMMIT_SHA": strings.Repeat("b", 40)}); err != nil {
|
||||
t.Fatalf("valid tag=%s output=%s error=%v", tag, output, err)
|
||||
}
|
||||
}
|
||||
if output, err := executeWoodpeckerBlock(guard, t.TempDir(), map[string]string{"CI_COMMIT_TAG": "releasekit-test/foreign/" + strings.Repeat("a", 32), "CI_COMMIT_SHA": strings.Repeat("b", 40)}); err == nil {
|
||||
t.Fatalf("foreign selector accepted: %s", output)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWoodpeckerTagDeliveryUsesTaggedModuleVersion(t *testing.T) {
|
||||
// Synthetic downloads must leave the caller's module cache untouched.
|
||||
callerCache := t.TempDir()
|
||||
|
||||
Reference in New Issue
Block a user