mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-16 03:52:12 +02:00
feat: allow parallelism by build target (#3213)
* Trying to fix parallelism on multiple builds issue https://github.com/goreleaser/goreleaser/issues/3209 * bugfixing * Update internal/pipe/build/build_test.go Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * Update internal/pipe/build/build_test.go Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * Update internal/pipe/build/build_test.go Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: gofumpt Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> Co-authored-by: JD <jdpcbs@gmail.com>
This commit is contained in:
parent
cf3c758356
commit
1d72e963f4
@ -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 {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user