Skip to content

Commit

Permalink
feat: --skip=snapcraft
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Nov 3, 2023
1 parent c6cb980 commit 1a8702f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/pipe/snapcraft/snapcraft.go
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/goreleaser/goreleaser/internal/ids"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/semerrgroup"
"github.com/goreleaser/goreleaser/internal/skips"
"github.com/goreleaser/goreleaser/internal/tmpl"
"github.com/goreleaser/goreleaser/internal/yaml"
"github.com/goreleaser/goreleaser/pkg/config"
Expand Down Expand Up @@ -104,8 +105,10 @@ type Pipe struct{}

func (Pipe) String() string { return "snapcraft packages" }
func (Pipe) ContinueOnError() bool { return true }
func (Pipe) Skip(ctx *context.Context) bool { return len(ctx.Config.Snapcrafts) == 0 }
func (Pipe) Dependencies(_ *context.Context) []string { return []string{"snapcraft"} }
func (Pipe) Skip(ctx *context.Context) bool {
return skips.Any(ctx, skips.Snapcraft) || len(ctx.Config.Snapcrafts) == 0
}

// Default sets the pipe defaults.
func (Pipe) Default(ctx *context.Context) error {
Expand Down
2 changes: 2 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/gio"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/skips"
"github.com/goreleaser/goreleaser/internal/testctx"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/goreleaser/goreleaser/internal/yaml"
Expand Down Expand Up @@ -678,6 +679,7 @@ func Test_isValidArch(t *testing.T) {
func TestSkip(t *testing.T) {
t.Run("skip", func(t *testing.T) {
require.True(t, Pipe{}.Skip(testctx.New()))
require.True(t, Pipe{}.Skip(testctx.New(testctx.Skip(skips.Snapcraft))))
})

t.Run("dont skip", func(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions internal/skips/skips.go
Expand Up @@ -24,6 +24,7 @@ const (
Docker Key = "docker"
Before Key = "before"
Winget Key = "winget"
Snapcraft Key = "snapcraft"
Scoop Key = "scoop"
)

Expand Down Expand Up @@ -100,6 +101,7 @@ var Release = Keys{
Ko,
Docker,
Winget,
Snapcraft,
Scoop,
Before,
}
Expand Down

0 comments on commit 1a8702f

Please sign in to comment.