Skip to content

Commit

Permalink
fix: make scoop write .json when --skip-publish
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jonaslu committed Aug 3, 2021
1 parent 18695c2 commit e16c135
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
4 changes: 0 additions & 4 deletions internal/pipe/scoop/scoop.go
Expand Up @@ -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
Expand Down
56 changes: 55 additions & 1 deletion internal/pipe/scoop/scoop_test.go
Expand Up @@ -997,7 +997,7 @@ func Test_buildManifest(t *testing.T) {
}
}

func TestRunPipeScoopWithSkip(t *testing.T) {
func TestRunPipeScoopWithSkipUpload(t *testing.T) {
folder := t.TempDir()
ctx := &context.Context{
Git: context.GitInfo{
Expand Down Expand Up @@ -1051,6 +1051,60 @@ func TestRunPipeScoopWithSkip(t *testing.T) {
require.NoError(t, err, "file should exist: "+distFile)
}

func TestRunPipeScoopWithSkipPublish(t *testing.T) {
folder := t.TempDir()
ctx := &context.Context{
Git: context.GitInfo{
CurrentTag: "v1.0.1",
},
Version: "1.0.1",
Artifacts: artifact.New(),
Config: config.Project{
Archives: []config.Archive{
{Format: "tar.gz"},
},
Builds: []config.Build{
{Binary: "test"},
},
Dist: folder,
ProjectName: "run-pipe",
Scoop: config.Scoop{
Bucket: config.RepoRef{
Owner: "test",
Name: "test",
},
Description: "A run pipe test formula",
Homepage: "https://github.com/goreleaser",
Name: "run-pipe",
},
},
SkipPublish: true,
}
path := filepath.Join(folder, "bin.tar.gz")
ctx.Artifacts.Add(&artifact.Artifact{
Name: "bin.tar.gz",
Path: path,
Goos: "windows",
Goarch: "amd64",
Type: artifact.UploadableArchive,
Extra: map[string]interface{}{
"ID": "foo",
"Format": "tar.gz",
},
})

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")
Expand Down

0 comments on commit e16c135

Please sign in to comment.