Consolidate Woodpecker delivery templates

This commit is contained in:
2026-10-06 19:49:19 +00:00
parent c6a5db8aeb
commit 21294404d7
12 changed files with 295 additions and 184 deletions

View File

@@ -78,22 +78,30 @@ func TestReleaseKitSourceDeliveryWorkflowFromTaggedCheckout(t *testing.T) {
cliGitRun(t, repository, "remote", "set-url", "origin", remote)
cliGitRun(t, repository, "push", "origin", "HEAD:refs/heads/main", "refs/tags/"+version)
// Match the maintained workflow: fetch and bind the tag, then build the
// executable from that detached tagged checkout before page-only delivery.
cliGitRun(t, repository, "fetch", "origin", "refs/tags/"+version+":refs/tags/"+version)
if got := cliGitOutput(t, repository, "rev-parse", "refs/tags/"+version+"^{commit}"); got != state.commit {
t.Fatalf("fetched tag commit = %s, want %s", got, state.commit)
}
cliGitRun(t, repository, "checkout", "--detach", state.commit)
tool := filepath.Join(repository, ".releasekit", "bin", "releasekit")
if err := os.MkdirAll(filepath.Dir(tool), 0o700); err != nil {
template, err := os.ReadFile(filepath.Join(root, "examples", "woodpecker", "releasekit-source-delivery.yml"))
if err != nil {
t.Fatal(err)
}
build := exec.Command("go", "build", "-o", tool, "./cmd/releasekit")
build.Dir = repository
build.Env = append(os.Environ(), "GOTOOLCHAIN=local", "GOPROXY=off", "GOSUMDB=off")
if output, err := build.CombinedOutput(); err != nil {
t.Fatalf("build CLI from tagged checkout: %v\n%s", err, output)
buildBlock, err := extractWoodpeckerCommand(string(template), "build-tool")
if err != nil {
t.Fatal(err)
}
deliveryBlock, err := extractWoodpeckerCommand(string(template), "deliver-page")
if err != nil {
t.Fatal(err)
}
env := map[string]string{
"CI_WORKSPACE": repository,
"CI_COMMIT_SHA": state.commit,
"CI_COMMIT_TAG": version,
"RELEASEKIT_GITEA_TOKEN": "fixture-token",
"GOPROXY": "off",
"GOSUMDB": "off",
}
runWoodpeckerBlock(t, strings.ReplaceAll(buildBlock, "$${", "${"), repository, env)
if got := cliGitOutput(t, repository, "rev-parse", "HEAD"); got != state.commit {
t.Fatalf("template checkout = %s, want %s", got, state.commit)
}
state.remoteCommit = strings.Repeat("f", 40)
@@ -109,7 +117,7 @@ func TestReleaseKitSourceDeliveryWorkflowFromTaggedCheckout(t *testing.T) {
state.remoteCommit = ""
for attempt := 0; attempt < 2; attempt++ {
output := runWoodpeckerCommand(t, tool, repository, true, "deliver", "--repo", repository, version)
output := runWoodpeckerBlock(t, strings.ReplaceAll(deliveryBlock, "$${", "${"), repository, env)
if !strings.Contains(output, "state complete") {
t.Fatalf("delivery attempt %d output = %q", attempt+1, output)
}