From b8c9d6cd8a62751290070ce391ba238415b8f5e4 Mon Sep 17 00:00:00 2001 From: Jonas Lundberg Date: Tue, 3 Aug 2021 03:10:26 +0200 Subject: [PATCH 1/2] fix: make scoop write .json when --skip-publish Don't skip the pipeline altogether but write out the manifest.json file as the homebrew pipeline does, only skip committing to the repo. closes #2374 --- internal/pipe/scoop/scoop.go | 4 ---- internal/pipe/scoop/scoop_test.go | 31 ++++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/internal/pipe/scoop/scoop.go b/internal/pipe/scoop/scoop.go index 681c4a2c0f9..9f2e4911633 100644 --- a/internal/pipe/scoop/scoop.go +++ b/internal/pipe/scoop/scoop.go @@ -34,10 +34,6 @@ func (Pipe) String() string { // Publish scoop manifest. func (Pipe) Publish(ctx *context.Context) error { - if ctx.SkipPublish { - return pipe.ErrSkipPublishEnabled - } - client, err := client.New(ctx) if err != nil { return err diff --git a/internal/pipe/scoop/scoop_test.go b/internal/pipe/scoop/scoop_test.go index e9758b8079a..450ead5bd9f 100644 --- a/internal/pipe/scoop/scoop_test.go +++ b/internal/pipe/scoop/scoop_test.go @@ -997,8 +997,7 @@ func Test_buildManifest(t *testing.T) { } } -func TestRunPipeScoopWithSkip(t *testing.T) { - folder := t.TempDir() +func getScoopPipeSkipCtx(folder string) (*context.Context, string) { ctx := &context.Context{ Git: context.GitInfo{ CurrentTag: "v1.0.1", @@ -1022,11 +1021,12 @@ func TestRunPipeScoopWithSkip(t *testing.T) { Description: "A run pipe test formula", Homepage: "https://github.com/goreleaser", Name: "run-pipe", - SkipUpload: "true", }, }, } + path := filepath.Join(folder, "bin.tar.gz") + ctx.Artifacts.Add(&artifact.Artifact{ Name: "bin.tar.gz", Path: path, @@ -1039,6 +1039,14 @@ func TestRunPipeScoopWithSkip(t *testing.T) { }, }) + return ctx, path +} + +func TestRunPipeScoopWithSkipUpload(t *testing.T) { + folder := t.TempDir() + ctx, path := getScoopPipeSkipCtx(folder) + ctx.Config.Scoop.SkipUpload = "true" + f, err := os.Create(path) require.NoError(t, err) require.NoError(t, f.Close()) @@ -1051,6 +1059,23 @@ func TestRunPipeScoopWithSkip(t *testing.T) { require.NoError(t, err, "file should exist: "+distFile) } +func TestRunPipeScoopWithSkipPublish(t *testing.T) { + folder := t.TempDir() + ctx, path := getScoopPipeSkipCtx(folder) + ctx.SkipPublish = true + + f, err := os.Create(path) + require.NoError(t, err) + require.NoError(t, f.Close()) + + cli := &DummyClient{} + require.EqualError(t, doRun(ctx, cli), pipe.ErrSkipPublishEnabled.Error()) + + distFile := filepath.Join(folder, ctx.Config.Scoop.Name+".json") + _, err = os.Stat(distFile) + require.NoError(t, err, "file should exist: "+distFile) +} + func TestWrapInDirectory(t *testing.T) { folder := t.TempDir() file := filepath.Join(folder, "archive") From a8182f6fa5cc9cb97c041181d4f259d1f28997cd Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 2 Aug 2021 23:30:04 -0300 Subject: [PATCH 2/2] Update internal/pipe/scoop/scoop_test.go --- internal/pipe/scoop/scoop_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/pipe/scoop/scoop_test.go b/internal/pipe/scoop/scoop_test.go index 450ead5bd9f..328f2f36ade 100644 --- a/internal/pipe/scoop/scoop_test.go +++ b/internal/pipe/scoop/scoop_test.go @@ -1072,8 +1072,7 @@ func TestRunPipeScoopWithSkipPublish(t *testing.T) { require.EqualError(t, doRun(ctx, cli), pipe.ErrSkipPublishEnabled.Error()) distFile := filepath.Join(folder, ctx.Config.Scoop.Name+".json") - _, err = os.Stat(distFile) - require.NoError(t, err, "file should exist: "+distFile) + require.FileExists(t, distFile) } func TestWrapInDirectory(t *testing.T) {