Use shared release scripts in Woodpecker
This commit is contained in:
@@ -60,9 +60,58 @@ func TestReleaseWorkflowRequiresValidation(t *testing.T) {
|
||||
if err := yaml.Unmarshal(data, &workflow); err != nil {
|
||||
t.Fatalf("parse release workflow: %v", err)
|
||||
}
|
||||
if !workflowDependsOn(workflow.Steps, "publish-release", "validate", map[string]bool{}) {
|
||||
t.Fatal("publish-release must depend on validate so validation failures block releases")
|
||||
validate, ok := workflow.Steps["validate-release"]
|
||||
if !ok {
|
||||
t.Fatal("release workflow must define validate-release")
|
||||
}
|
||||
if validate.Image != "golang:1.25.5" || !containsWorkflowCommand(validate.Commands, `./scripts/check-release-candidate.sh "$CI_COMMIT_TAG"`) {
|
||||
t.Fatalf("validate-release = %#v, want the shared candidate checker in golang:1.25.5", validate)
|
||||
}
|
||||
assets, ok := workflow.Steps["build-release-assets"]
|
||||
if !ok {
|
||||
t.Fatal("release workflow must define build-release-assets")
|
||||
}
|
||||
if assets.Image != "golang:1.25.5" || !workflowDependsOn(workflow.Steps, "build-release-assets", "validate-release", map[string]bool{}) {
|
||||
t.Fatalf("build-release-assets = %#v, want validated golang:1.25.5 asset construction", assets)
|
||||
}
|
||||
assetCommands := strings.Join(assets.Commands, "\n")
|
||||
if !strings.Contains(assetCommands, `./scripts/build-release-assets.sh "$CI_COMMIT_TAG" "$PWD/dist"`) || strings.Contains(assetCommands, "GOOS=") || strings.Contains(assetCommands, "go build") {
|
||||
t.Fatalf("build-release-assets commands must delegate target construction: %q", assetCommands)
|
||||
}
|
||||
publish, ok := workflow.Steps["publish-release"]
|
||||
if !ok {
|
||||
t.Fatal("release workflow must define publish-release")
|
||||
}
|
||||
if publish.Image != "woodpeckerci/plugin-release:0.3.1" || !workflowDependsOn(workflow.Steps, "publish-release", "validate-release", map[string]bool{}) || !workflowDependsOn(workflow.Steps, "publish-release", "build-release-assets", map[string]bool{}) {
|
||||
t.Fatalf("publish-release = %#v, want transitive validation and asset dependencies", publish)
|
||||
}
|
||||
for key, want := range map[string]any{
|
||||
"title": "Narratio ${CI_COMMIT_TAG}",
|
||||
"note": "docs/releases/${CI_COMMIT_TAG}.md",
|
||||
"checksum": "sha256",
|
||||
"checksum-file": "SHA256SUMS",
|
||||
"checksum-flatten": true,
|
||||
"file-exists": "skip",
|
||||
"overwrite": false,
|
||||
"prerelease": false,
|
||||
} {
|
||||
if got := publish.Settings[key]; got != want {
|
||||
t.Fatalf("publish-release setting %q = %#v, want %#v", key, got, want)
|
||||
}
|
||||
}
|
||||
files, ok := publish.Settings["files"].([]any)
|
||||
if !ok || len(files) != 1 || files[0] != "dist/narratio-*" {
|
||||
t.Fatalf("publish-release files = %#v", publish.Settings["files"])
|
||||
}
|
||||
}
|
||||
|
||||
func containsWorkflowCommand(commands []string, want string) bool {
|
||||
for _, command := range commands {
|
||||
if strings.Contains(command, want) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func repositoryRoot(t *testing.T) string {
|
||||
@@ -130,6 +179,9 @@ type woodpeckerWorkflow struct {
|
||||
|
||||
type woodpeckerStep struct {
|
||||
DependsOn woodpeckerDependencies `yaml:"depends_on"`
|
||||
Image string `yaml:"image"`
|
||||
Commands []string `yaml:"commands"`
|
||||
Settings map[string]any `yaml:"settings"`
|
||||
}
|
||||
|
||||
type woodpeckerDependencies []string
|
||||
|
||||
Reference in New Issue
Block a user