Skip to content

Commit

Permalink
fix: skip gomod info loading if no go builds
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Dec 2, 2024
1 parent 8542907 commit f4ad27c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
9 changes: 9 additions & 0 deletions internal/pipe/gomod/gomod.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ type Pipe struct{}

func (Pipe) String() string { return "loading go mod information" }

func (Pipe) Skip(ctx *context.Context) bool {
for _, build := range ctx.Config.Builds {
if build.Builder == "go" {
return false
}
}
return true
}

// Default sets the pipe defaults.
func (Pipe) Default(ctx *context.Context) error {
if ctx.Config.GoMod.GoBinary == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/pipe/gomod/gomod_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func TestProxyDescription(t *testing.T) {
require.NotEmpty(t, ProxyPipe{}.String())
}

func TestSkip(t *testing.T) {
func TestSkipProxy(t *testing.T) {
t.Run("skip false gomod.proxy", func(t *testing.T) {
ctx := testctx.New()
require.True(t, ProxyPipe{}.Skip(ctx))
Expand Down
26 changes: 26 additions & 0 deletions internal/pipe/gomod/gomod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,32 @@ import (
"github.com/stretchr/testify/require"
)

func TestSkip(t *testing.T) {
t.Run("skip", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Builds: []config.Build{
{
Builder: "zig",
},
},
})
require.True(t, Pipe{}.Skip(ctx))
})
t.Run("dont skip", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Builds: []config.Build{
{
Builder: "go",
},
{
Builder: "zig",
},
},
})
require.False(t, Pipe{}.Skip(ctx))
})
}

func TestRun(t *testing.T) {
ctx := testctx.New()
require.NoError(t, Pipe{}.Default(ctx))
Expand Down

0 comments on commit f4ad27c

Please sign in to comment.