mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
Merge pull request #475 from goreleaser/par-checksum
fix: paralelism on checksums pipe
This commit is contained in:
commit
4e0c234527
@ -44,8 +44,8 @@ func (Pipe) Run(ctx *context.Context) (err error) {
|
||||
}
|
||||
defer file.Close() // nolint: errcheck
|
||||
|
||||
// TODO: parallelism should be considered here as well.
|
||||
var g errgroup.Group
|
||||
var semaphore = make(chan bool, ctx.Parallelism)
|
||||
for _, artifact := range ctx.Artifacts.Filter(
|
||||
artifact.Or(
|
||||
artifact.ByType(artifact.UploadableArchive),
|
||||
@ -53,8 +53,12 @@ func (Pipe) Run(ctx *context.Context) (err error) {
|
||||
artifact.ByType(artifact.LinuxPackage),
|
||||
),
|
||||
).List() {
|
||||
semaphore <- true
|
||||
artifact := artifact
|
||||
g.Go(func() error {
|
||||
defer func() {
|
||||
<-semaphore
|
||||
}()
|
||||
return checksums(ctx, file, artifact)
|
||||
})
|
||||
}
|
||||
|
@ -37,6 +37,11 @@ func TestPipe(t *testing.T) {
|
||||
Path: file,
|
||||
Type: artifact.UploadableBinary,
|
||||
})
|
||||
ctx.Artifacts.Add(artifact.Artifact{
|
||||
Name: binary + ".tar.gz",
|
||||
Path: file,
|
||||
Type: artifact.UploadableArchive,
|
||||
})
|
||||
assert.NoError(t, Pipe{}.Run(ctx))
|
||||
var artifacts []string
|
||||
for _, a := range ctx.Artifacts.List() {
|
||||
@ -45,7 +50,8 @@ func TestPipe(t *testing.T) {
|
||||
assert.Contains(t, artifacts, checksums, binary)
|
||||
bts, err := ioutil.ReadFile(filepath.Join(folder, checksums))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "61d034473102d7dac305902770471fd50f4c5b26f6831a56dd90b5184b3c30fc binary\n", string(bts))
|
||||
assert.Contains(t, string(bts), "61d034473102d7dac305902770471fd50f4c5b26f6831a56dd90b5184b3c30fc binary")
|
||||
assert.Contains(t, string(bts), "61d034473102d7dac305902770471fd50f4c5b26f6831a56dd90b5184b3c30fc binary.tar.gz")
|
||||
}
|
||||
|
||||
func TestPipeFileNotExist(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user