Skip to content

Commit

Permalink
feat: --skip-nix
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Nov 4, 2023
1 parent 53071b6 commit 954121f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/pipe/nix/nix.go
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/goreleaser/goreleaser/internal/client"
"github.com/goreleaser/goreleaser/internal/commitauthor"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/skips"
"github.com/goreleaser/goreleaser/internal/tmpl"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
Expand Down Expand Up @@ -64,7 +65,7 @@ func (Pipe) String() string { return "nixpkgs" }
func (Pipe) ContinueOnError() bool { return true }
func (Pipe) Dependencies(_ *context.Context) []string { return []string{"nix-prefetch-url"} }
func (p Pipe) Skip(ctx *context.Context) bool {
return len(ctx.Config.Nix) == 0 || !p.prefetcher.Available()
return skips.Any(ctx, skips.Nix) || len(ctx.Config.Nix) == 0 || !p.prefetcher.Available()
}

func (Pipe) Default(ctx *context.Context) error {
Expand Down
6 changes: 6 additions & 0 deletions internal/pipe/nix/nix_test.go
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/client"
"github.com/goreleaser/goreleaser/internal/golden"
"github.com/goreleaser/goreleaser/internal/skips"
"github.com/goreleaser/goreleaser/internal/testctx"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/stretchr/testify/require"
Expand All @@ -28,6 +29,11 @@ func TestSkip(t *testing.T) {
t.Run("no-nix", func(t *testing.T) {
require.True(t, Pipe{}.Skip(testctx.New()))
})
t.Run("skip flag", func(t *testing.T) {
require.False(t, NewPublish().Skip(testctx.NewWithCfg(config.Project{
Nix: []config.Nix{{}},
}, testctx.Skip(skips.Nix))))
})
t.Run("nix-all-good", func(t *testing.T) {
require.False(t, NewPublish().Skip(testctx.NewWithCfg(config.Project{
Nix: []config.Nix{{}},
Expand Down
2 changes: 2 additions & 0 deletions internal/skips/skips.go
Expand Up @@ -26,6 +26,7 @@ const (
Winget Key = "winget"
Snapcraft Key = "snapcraft"
Scoop Key = "scoop"
Nix Key = "nix"
AUR Key = "aur"
)

Expand Down Expand Up @@ -104,6 +105,7 @@ var Release = Keys{
Winget,
Snapcraft,
Scoop,
Nix,
AUR,
Before,
}
Expand Down

0 comments on commit 954121f

Please sign in to comment.