diff --git a/internal/pipe/build/build.go b/internal/pipe/build/build.go index e9198dbba..a05f42d2e 100644 --- a/internal/pipe/build/build.go +++ b/internal/pipe/build/build.go @@ -31,17 +31,16 @@ func (Pipe) String() string { // Run the pipe. func (Pipe) Run(ctx *context.Context) error { + g := semerrgroup.New(ctx.Parallelism) for _, build := range ctx.Config.Builds { if build.Skip { log.WithField("id", build.ID).Info("skip is set") continue } log.WithField("build", build).Debug("building") - if err := runPipeOnBuild(ctx, build); err != nil { - return err - } + runPipeOnBuild(ctx, g, build) } - return nil + return g.Wait() } // Default sets the pipe defaults. @@ -81,8 +80,7 @@ func buildWithDefaults(ctx *context.Context, build config.Build) (config.Build, return builders.For(build.Builder).WithDefaults(build) } -func runPipeOnBuild(ctx *context.Context, build config.Build) error { - g := semerrgroup.New(ctx.Parallelism) +func runPipeOnBuild(ctx *context.Context, g semerrgroup.Group, build config.Build) { for _, target := range build.Targets { target := target build := build @@ -106,8 +104,6 @@ func runPipeOnBuild(ctx *context.Context, build config.Build) error { return nil }) } - - return g.Wait() } func runHook(ctx *context.Context, opts builders.Options, buildEnv []string, hooks config.Hooks) error { diff --git a/internal/pipe/build/build_test.go b/internal/pipe/build/build_test.go index 83f98dc6b..7155f8fd9 100644 --- a/internal/pipe/build/build_test.go +++ b/internal/pipe/build/build_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/goreleaser/goreleaser/internal/artifact" + "github.com/goreleaser/goreleaser/internal/semerrgroup" "github.com/goreleaser/goreleaser/internal/testlib" "github.com/goreleaser/goreleaser/internal/tmpl" api "github.com/goreleaser/goreleaser/pkg/build" @@ -489,8 +490,9 @@ func TestBuild_hooksKnowGoosGoarch(t *testing.T) { build, }, }) - err := runPipeOnBuild(ctx, build) - require.NoError(t, err) + g := semerrgroup.New(ctx.Parallelism) + runPipeOnBuild(ctx, g, build) + require.NoError(t, g.Wait()) require.FileExists(t, filepath.Join(tmpDir, "pre-hook-amd64-linux")) require.FileExists(t, filepath.Join(tmpDir, "post-hook-amd64-linux")) } @@ -520,8 +522,9 @@ func TestPipeOnBuild_hooksRunPerTarget(t *testing.T) { build, }, }) - err := runPipeOnBuild(ctx, build) - require.NoError(t, err) + g := semerrgroup.New(ctx.Parallelism) + runPipeOnBuild(ctx, g, build) + require.NoError(t, g.Wait()) require.FileExists(t, filepath.Join(tmpDir, "pre-hook-linux_amd64")) require.FileExists(t, filepath.Join(tmpDir, "pre-hook-darwin_amd64")) require.FileExists(t, filepath.Join(tmpDir, "pre-hook-windows_amd64")) @@ -543,8 +546,9 @@ func TestPipeOnBuild_invalidBinaryTpl(t *testing.T) { build, }, }) - err := runPipeOnBuild(ctx, build) - require.EqualError(t, err, `template: tmpl:1:11: executing "tmpl" at <.XYZ>: map has no entry for key "XYZ"`) + g := semerrgroup.New(ctx.Parallelism) + runPipeOnBuild(ctx, g, build) + require.EqualError(t, g.Wait(), `template: tmpl:1:11: executing "tmpl" at <.XYZ>: map has no entry for key "XYZ"`) } func TestBuildOptionsForTarget(t *testing.T) {