Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: snapcraft: do not push when skip publish #1374

Merged
merged 2 commits into from Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/pipe/snapcraft/snapcraft.go
Expand Up @@ -141,6 +141,9 @@ func isValidArch(arch string) bool {

// Publish packages
func (Pipe) Publish(ctx *context.Context) error {
if ctx.SkipPublish {
return pipe.ErrSkipPublishEnabled
}
snaps := ctx.Artifacts.Filter(artifact.ByType(artifact.PublishableSnapcraft)).List()
var g = semerrgroup.New(ctx.Parallelism)
for _, snap := range snaps {
Expand Down
14 changes: 14 additions & 0 deletions internal/pipe/snapcraft/snapcraft_test.go
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -355,6 +356,19 @@ func TestPublish(t *testing.T) {
assert.Contains(t, err.Error(), "failed to push nope.snap package")
}

func TestPublishSkip(t *testing.T) {
var ctx = context.New(config.Project{})
ctx.SkipPublish = true
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: "nope.snap",
Goarch: "amd64",
Goos: "linux",
Type: artifact.PublishableSnapcraft,
})
testlib.AssertSkipped(t, Pipe{}.Publish(ctx))
}

func TestDefaultSet(t *testing.T) {
var ctx = context.New(config.Project{
Snapcrafts: []config.Snapcraft{
Expand Down