mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
feat: make fpm respect --parallelism
It was firing unlimited fpm processes until now.
This commit is contained in:
parent
df0cf14912
commit
3234cb98da
@ -40,16 +40,21 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
|
||||
func doRun(ctx *context.Context) error {
|
||||
var g errgroup.Group
|
||||
sem := make(chan bool, ctx.Parallelism)
|
||||
for _, format := range ctx.Config.FPM.Formats {
|
||||
for platform, groups := range ctx.Binaries {
|
||||
if !strings.Contains(platform, "linux") {
|
||||
log.WithField("platform", platform).Debug("skipped non-linux builds for fpm")
|
||||
continue
|
||||
}
|
||||
sem <- true
|
||||
format := format
|
||||
arch := linux.Arch(platform)
|
||||
for folder, binaries := range groups {
|
||||
g.Go(func() error {
|
||||
defer func() {
|
||||
<-sem
|
||||
}()
|
||||
return create(ctx, format, folder, arch, binaries)
|
||||
})
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
@ -18,8 +19,9 @@ func TestDescription(t *testing.T) {
|
||||
|
||||
func TestRunPipeNoFormats(t *testing.T) {
|
||||
var ctx = &context.Context{
|
||||
Version: "1.0.0",
|
||||
Config: config.Project{},
|
||||
Version: "1.0.0",
|
||||
Config: config.Project{},
|
||||
Parallelism: runtime.NumCPU(),
|
||||
}
|
||||
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
|
||||
}
|
||||
@ -34,7 +36,8 @@ func TestRunPipe(t *testing.T) {
|
||||
_, err = os.Create(binPath)
|
||||
assert.NoError(t, err)
|
||||
var ctx = &context.Context{
|
||||
Version: "1.0.0",
|
||||
Version: "1.0.0",
|
||||
Parallelism: runtime.NumCPU(),
|
||||
Config: config.Project{
|
||||
ProjectName: "mybin",
|
||||
Dist: dist,
|
||||
@ -63,7 +66,8 @@ func TestNoFPMInPath(t *testing.T) {
|
||||
}()
|
||||
assert.NoError(t, os.Setenv("PATH", ""))
|
||||
var ctx = &context.Context{
|
||||
Version: "1.0.0",
|
||||
Version: "1.0.0",
|
||||
Parallelism: runtime.NumCPU(),
|
||||
Config: config.Project{
|
||||
FPM: config.FPM{
|
||||
Formats: []string{"deb", "rpm"},
|
||||
@ -80,7 +84,8 @@ func TestCreateFileDoesntExist(t *testing.T) {
|
||||
assert.NoError(t, os.Mkdir(dist, 0755))
|
||||
assert.NoError(t, os.Mkdir(filepath.Join(dist, "mybin"), 0755))
|
||||
var ctx = &context.Context{
|
||||
Version: "1.0.0",
|
||||
Version: "1.0.0",
|
||||
Parallelism: runtime.NumCPU(),
|
||||
Config: config.Project{
|
||||
Dist: dist,
|
||||
FPM: config.FPM{
|
||||
@ -97,7 +102,8 @@ func TestCreateFileDoesntExist(t *testing.T) {
|
||||
|
||||
func TestRunPipeWithExtraFiles(t *testing.T) {
|
||||
var ctx = &context.Context{
|
||||
Version: "1.0.0",
|
||||
Version: "1.0.0",
|
||||
Parallelism: runtime.NumCPU(),
|
||||
Config: config.Project{
|
||||
FPM: config.FPM{
|
||||
Formats: []string{"deb", "rpm"},
|
||||
|
Loading…
x
Reference in New Issue
Block a user