Skip to content

Commit 8a4ea86

Browse files
committed
feat: add new tests
1 parent 14a735c commit 8a4ea86

4 files changed

+195
-3
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(*codegen.File)(# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2+
before:
3+
hooks:
4+
- make dep<nil>archives: []
5+
checksum:
6+
name_template: 'checksums.txt'
7+
release:
8+
# We handle releasing via semantic-release
9+
disable: true
10+
)
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
(*codegen.File)(# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2+
before:
3+
hooks:
4+
- make dep
5+
builds:
6+
- main: ./cmd/cmd1
7+
id: &name cmd1
8+
binary: *name
9+
goos:
10+
- linux
11+
- darwin
12+
goarch:
13+
- arm64
14+
- amd64
15+
ldflags:
16+
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
17+
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
18+
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
19+
env:
20+
- CGO_ENABLED=0
21+
## <<Stencil::Block(cmd1AdditionalEnv)>>
22+
23+
## <</Stencil::Block>>
24+
- main: ./cmd/cmd2
25+
id: &name cmd2
26+
binary: *name
27+
goos:
28+
- linux
29+
- darwin
30+
goarch:
31+
- arm64
32+
- amd64
33+
ldflags:
34+
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
35+
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
36+
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
37+
env:
38+
- CGO_ENABLED=0
39+
## <<Stencil::Block(cmd2AdditionalEnv)>>
40+
41+
## <</Stencil::Block>>
42+
- main: ./cmd/cmd3-sub1
43+
id: &name cmd3-sub1
44+
binary: *name
45+
goos:
46+
- linux
47+
- darwin
48+
goarch:
49+
- arm64
50+
- amd64
51+
ldflags:
52+
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
53+
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
54+
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
55+
env:
56+
- CGO_ENABLED=0
57+
## <<Stencil::Block(cmd3sub1AdditionalEnv)>>
58+
59+
## <</Stencil::Block>>
60+
- main: ./cmd/cmd3-sub2
61+
id: &name cmd3-sub2
62+
binary: *name
63+
goos:
64+
- linux
65+
- darwin
66+
goarch:
67+
- arm64
68+
- amd64
69+
ldflags:
70+
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
71+
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
72+
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
73+
env:
74+
- CGO_ENABLED=0
75+
## <<Stencil::Block(cmd3sub2AdditionalEnv)>>
76+
77+
## <</Stencil::Block>>
78+
- main: ./cmd/cmd4_sub1
79+
id: &name cmd4_sub1
80+
binary: *name
81+
goos:
82+
- linux
83+
- darwin
84+
goarch:
85+
- arm64
86+
- amd64
87+
ldflags:
88+
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
89+
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
90+
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
91+
env:
92+
- CGO_ENABLED=0
93+
## <<Stencil::Block(cmd4sub1AdditionalEnv)>>
94+
95+
## <</Stencil::Block>>archives: []
96+
checksum:
97+
name_template: 'checksums.txt'
98+
release:
99+
# We handle releasing via semantic-release
100+
disable: true
101+
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(*codegen.File)(# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2+
before:
3+
hooks:
4+
- make dep
5+
builds:
6+
- main: ./cmd/cmd1
7+
id: &name cmd1
8+
binary: *name
9+
goos:
10+
- linux
11+
goarch:
12+
- arm64
13+
ldflags:
14+
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
15+
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
16+
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
17+
env:
18+
- CGO_ENABLED=0
19+
## <<Stencil::Block(cmd1AdditionalEnv)>>
20+
21+
## <</Stencil::Block>>archives: []
22+
checksum:
23+
name_template: 'checksums.txt'
24+
release:
25+
# We handle releasing via semantic-release
26+
disable: true
27+
)

templates/main_test.go

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ func TestGRPCServerRPC(t *testing.T) {
230230
"grpc",
231231
},
232232
})
233-
st.Run(true)
233+
st.Run(stenciltest.RegenerateSnapshots())
234234
}
235235

236-
func TestGoreleaserYml(t *testing.T) {
236+
func TestGoreleaserYmlOnlyCommands(t *testing.T) {
237237
st := stenciltest.New(t, ".goreleaser.yml.tpl", libraryTmpls...)
238238
st.Args(map[string]interface{}{
239239
"commands": []interface{}{
@@ -244,7 +244,61 @@ func TestGoreleaserYml(t *testing.T) {
244244
"cmd4_sub1",
245245
},
246246
})
247-
st.Run(true)
247+
st.Run(stenciltest.RegenerateSnapshots())
248+
}
249+
250+
func TestGoreleaserYmlWithBuildAsset(t *testing.T) {
251+
st := stenciltest.New(t, ".goreleaser.yml.tpl", libraryTmpls...)
252+
st.Args(map[string]interface{}{
253+
"commands": []any{
254+
map[string]any{
255+
"cmd1": map[string]any{
256+
"buildAsset": true,
257+
},
258+
},
259+
map[string]any{
260+
"cmd2": map[string]any{
261+
"buildAsset": true,
262+
},
263+
},
264+
map[string]any{
265+
"cmd3-sub1": map[string]any{
266+
"buildAsset": true,
267+
},
268+
},
269+
map[string]any{
270+
"cmd3-sub2": map[string]any{
271+
"buildAsset": true,
272+
},
273+
},
274+
map[string]any{
275+
"cmd4_sub1": map[string]any{
276+
"buildAsset": true,
277+
},
278+
},
279+
},
280+
})
281+
st.Run(stenciltest.RegenerateSnapshots())
282+
}
283+
284+
func TestGoreleaserYmlWithSpecifiedOrAndArch(t *testing.T) {
285+
st := stenciltest.New(t, ".goreleaser.yml.tpl", libraryTmpls...)
286+
st.Args(map[string]interface{}{
287+
"commands": []any{
288+
map[string]any{
289+
"cmd1": map[string]any{
290+
"buildAsset": true,
291+
"os": []any{
292+
"linux",
293+
},
294+
"arch": []any{
295+
"arm64",
296+
},
297+
},
298+
},
299+
},
300+
})
301+
st.Run(stenciltest.RegenerateSnapshots())
248302
}
249303

250304
func TestRenderGolangcilintYaml(t *testing.T) {

0 commit comments

Comments
 (0)