diff --git a/templates/.snapshots/TestGoreleaserYmlOnlyCommands-.goreleaser.yml.tpl-.goreleaser.yml.snapshot b/templates/.snapshots/TestGoreleaserYmlOnlyCommands-.goreleaser.yml.tpl-.goreleaser.yml.snapshot new file mode 100644 index 0000000..4e2c922 --- /dev/null +++ b/templates/.snapshots/TestGoreleaserYmlOnlyCommands-.goreleaser.yml.tpl-.goreleaser.yml.snapshot @@ -0,0 +1,10 @@ +(*codegen.File)(# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +before: + hooks: + - make deparchives: [] +checksum: + name_template: 'checksums.txt' +release: + # We handle releasing via semantic-release + disable: true +) diff --git a/templates/.snapshots/TestGoreleaserYmlWithBuildAsset-.goreleaser.yml.tpl-.goreleaser.yml.snapshot b/templates/.snapshots/TestGoreleaserYmlWithBuildAsset-.goreleaser.yml.tpl-.goreleaser.yml.snapshot new file mode 100644 index 0000000..ffc53b0 --- /dev/null +++ b/templates/.snapshots/TestGoreleaserYmlWithBuildAsset-.goreleaser.yml.tpl-.goreleaser.yml.snapshot @@ -0,0 +1,29 @@ +(*codegen.File)(# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +before: + hooks: + - make dep +builds: + - main: ./cmd/cmd3-sub2 + id: &name cmd3-sub2 + binary: *name + goos: + - linux + - darwin + goarch: + - arm64 + - amd64 + ldflags: + - '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"' + - '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"' + - '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"' + env: + - CGO_ENABLED=0 + ## <> + + ## <>archives: [] +checksum: + name_template: 'checksums.txt' +release: + # We handle releasing via semantic-release + disable: true +) diff --git a/templates/.snapshots/TestGoreleaserYmlWithSpecifiedOrAndArch-.goreleaser.yml.tpl-.goreleaser.yml.snapshot b/templates/.snapshots/TestGoreleaserYmlWithSpecifiedOrAndArch-.goreleaser.yml.tpl-.goreleaser.yml.snapshot new file mode 100644 index 0000000..5204b90 --- /dev/null +++ b/templates/.snapshots/TestGoreleaserYmlWithSpecifiedOrAndArch-.goreleaser.yml.tpl-.goreleaser.yml.snapshot @@ -0,0 +1,27 @@ +(*codegen.File)(# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +before: + hooks: + - make dep +builds: + - main: ./cmd/cmd1 + id: &name cmd1 + binary: *name + goos: + - linux + goarch: + - arm64 + ldflags: + - '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"' + - '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"' + - '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"' + env: + - CGO_ENABLED=0 + ## <> + + ## <>archives: [] +checksum: + name_template: 'checksums.txt' +release: + # We handle releasing via semantic-release + disable: true +) diff --git a/templates/main_test.go b/templates/main_test.go index b7ac52a..df5efc8 100644 --- a/templates/main_test.go +++ b/templates/main_test.go @@ -230,10 +230,10 @@ func TestGRPCServerRPC(t *testing.T) { "grpc", }, }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } -func TestGoreleaserYml(t *testing.T) { +func TestGoreleaserYmlOnlyCommands(t *testing.T) { st := stenciltest.New(t, ".goreleaser.yml.tpl", libraryTmpls...) st.Args(map[string]interface{}{ "commands": []interface{}{ @@ -244,7 +244,53 @@ func TestGoreleaserYml(t *testing.T) { "cmd4_sub1", }, }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) +} + +func TestGoreleaserYmlWithBuildAsset(t *testing.T) { + st := stenciltest.New(t, ".goreleaser.yml.tpl", libraryTmpls...) + st.Args(map[string]interface{}{ + "commands": []any{ + map[string]any{ + "cmd1": map[string]any{ + "buildAsset": true, + }, + "cmd2": map[string]any{ + "buildAsset": true, + }, + "cmd3-sub1": map[string]any{ + "buildAsset": true, + }, + "cmd3-sub2": map[string]any{ + "buildAsset": true, + }, + "cmd4_sub1": map[string]any{ + "buildAsset": true, + }, + }, + }, + }) + st.Run(stenciltest.RegenerateSnapshots()) +} + +func TestGoreleaserYmlWithSpecifiedOrAndArch(t *testing.T) { + st := stenciltest.New(t, ".goreleaser.yml.tpl", libraryTmpls...) + st.Args(map[string]interface{}{ + "commands": []any{ + map[string]any{ + "cmd1": map[string]any{ + "buildAsset": true, + "os": []any{ + "linux", + }, + "arch": []any{ + "arm64", + }, + }, + }, + }, + }) + st.Run(stenciltest.RegenerateSnapshots()) } func TestRenderGolangcilintYaml(t *testing.T) {