1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00

fix: s3: honor skip upload (#738)

refs https://github.com/goreleaser/goreleaser/issues/737
This commit is contained in:
Carlos Alexandro Becker 2018-07-27 17:17:15 -03:00 committed by GitHub
parent ba62d25bdd
commit 82493e2928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import (
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/semerrgroup"
"github.com/goreleaser/goreleaser/internal/tmpl"
"github.com/goreleaser/goreleaser/pipeline"
)
// Pipe for Artifactory
@ -47,6 +48,9 @@ func (Pipe) Default(ctx *context.Context) error {
// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
if ctx.SkipPublish {
return pipeline.ErrSkipPublishEnabled
}
var g = semerrgroup.New(ctx.Parallelism)
for _, conf := range ctx.Config.S3 {
conf := conf

View File

@ -13,7 +13,9 @@ import (
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/pipeline"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestDescription(t *testing.T) {
@ -53,6 +55,34 @@ func TestDefaults(t *testing.T) {
}}, ctx.Config.S3)
}
func TestSkipPublish(t *testing.T) {
folder, err := ioutil.TempDir("", "goreleasertest")
require.NoError(t, err)
artifactPath := filepath.Join(folder, "foo.tar.gz")
require.NoError(t, ioutil.WriteFile(artifactPath, []byte("fake\ntargz"), 0744))
var ctx = context.New(config.Project{
Dist: folder,
ProjectName: "testupload",
S3: []config.S3{
{
Bucket: "test",
Endpoint: "http://fake.s3.example",
},
},
})
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
ctx.Artifacts.Add(artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "foo.tar.gz",
Path: artifactPath,
})
ctx.SkipPublish = true
require.NoError(t, Pipe{}.Default(ctx))
err = Pipe{}.Run(ctx)
assert.True(t, pipeline.IsSkip(err))
assert.EqualError(t, err, pipeline.ErrSkipPublishEnabled.Error())
}
func TestUpload(t *testing.T) {
folder, err := ioutil.TempDir("", "goreleasertest")
assert.NoError(t, err)