You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-03 00:57:43 +02:00
feat: improve skip-publish behavior (#1474)
* Revert "feat: split brew tap in 2 steps (#1425)"
This reverts commit 5e8882fbb6
.
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
* fix: brew generation
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
* feat: improve bucket write
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
* fix: tests
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
* fix: tests
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
* fix: minio test
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
* fix: lint issues
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
* fix: lint issues
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
* fix: err handling
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
committed by
GitHub
parent
705ab90e4f
commit
15fd80eded
@ -5,6 +5,7 @@ package blob
|
||||
// the test setup and teardown
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
@ -19,6 +20,7 @@ import (
|
||||
"github.com/goreleaser/goreleaser/pkg/context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gocloud.dev/blob"
|
||||
)
|
||||
|
||||
func TestMinioUpload(t *testing.T) {
|
||||
@ -153,7 +155,7 @@ func TestMinioUploadInvalidCustomBucketID(t *testing.T) {
|
||||
},
|
||||
},
|
||||
})
|
||||
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
|
||||
ctx.Git = context.GitInfo{CurrentTag: "v1.1.0"}
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Type: artifact.UploadableArchive,
|
||||
Name: "bin.tar.gz",
|
||||
@ -172,6 +174,77 @@ func TestMinioUploadInvalidCustomBucketID(t *testing.T) {
|
||||
assert.Error(t, Pipe{}.Publish(ctx))
|
||||
}
|
||||
|
||||
func TestMinioUploadSkipPublish(t *testing.T) {
|
||||
var listen = randomListen(t)
|
||||
folder, err := ioutil.TempDir("", "goreleasertest")
|
||||
assert.NoError(t, err)
|
||||
srcpath := filepath.Join(folder, "source.tar.gz")
|
||||
tgzpath := filepath.Join(folder, "bin.tar.gz")
|
||||
debpath := filepath.Join(folder, "bin.deb")
|
||||
checkpath := filepath.Join(folder, "check.txt")
|
||||
assert.NoError(t, ioutil.WriteFile(checkpath, []byte("fake checksums"), 0744))
|
||||
assert.NoError(t, ioutil.WriteFile(srcpath, []byte("fake\nsrc"), 0744))
|
||||
assert.NoError(t, ioutil.WriteFile(tgzpath, []byte("fake\ntargz"), 0744))
|
||||
assert.NoError(t, ioutil.WriteFile(debpath, []byte("fake\ndeb"), 0744))
|
||||
var ctx = context.New(config.Project{
|
||||
Dist: folder,
|
||||
ProjectName: "testupload",
|
||||
Blobs: []config.Blob{
|
||||
{
|
||||
Provider: "s3",
|
||||
Bucket: "test",
|
||||
Region: "us-east",
|
||||
Endpoint: "http://" + listen,
|
||||
IDs: []string{"foo", "bar"},
|
||||
},
|
||||
},
|
||||
})
|
||||
ctx.SkipPublish = true
|
||||
ctx.Git = context.GitInfo{CurrentTag: "v1.2.0"}
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Type: artifact.Checksum,
|
||||
Name: "checksum.txt",
|
||||
Path: checkpath,
|
||||
})
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Type: artifact.UploadableSourceArchive,
|
||||
Name: "source.tar.gz",
|
||||
Path: srcpath,
|
||||
Extra: map[string]interface{}{
|
||||
"Format": "tar.gz",
|
||||
},
|
||||
})
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Type: artifact.UploadableArchive,
|
||||
Name: "bin.tar.gz",
|
||||
Path: tgzpath,
|
||||
Extra: map[string]interface{}{
|
||||
"ID": "foo",
|
||||
},
|
||||
})
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Type: artifact.LinuxPackage,
|
||||
Name: "bin.deb",
|
||||
Path: debpath,
|
||||
Extra: map[string]interface{}{
|
||||
"ID": "bar",
|
||||
},
|
||||
})
|
||||
var name = "test_upload"
|
||||
defer stop(t, name)
|
||||
start(t, name, listen)
|
||||
prepareEnv(t, listen)
|
||||
assert.NoError(t, Pipe{}.Default(ctx))
|
||||
assert.NoError(t, Pipe{}.Publish(ctx))
|
||||
|
||||
require.NotContains(t, getFiles(t, ctx, ctx.Config.Blobs[0]), []string{
|
||||
"testupload/v1.2.0/bin.deb",
|
||||
"testupload/v1.2.0/bin.tar.gz",
|
||||
"testupload/v1.2.0/checksum.txt",
|
||||
"testupload/v1.2.0/source.tar.gz",
|
||||
})
|
||||
}
|
||||
|
||||
func randomListen(t *testing.T) string {
|
||||
listener, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
require.NoError(t, err)
|
||||
@ -229,19 +302,20 @@ func removeTestData(t *testing.T) {
|
||||
_ = os.RemoveAll("./testdata/data/test/testupload") // dont care if it fails
|
||||
}
|
||||
|
||||
func getFiles(t *testing.T, ctx *context.Context, blob config.Blob) []string {
|
||||
var bucket = Bucket{}
|
||||
url, err := bucket.url(ctx, blob)
|
||||
func getFiles(t *testing.T, ctx *context.Context, cfg config.Blob) []string {
|
||||
url, err := urlFor(ctx, cfg)
|
||||
require.NoError(t, err)
|
||||
conn, err := bucket.Connect(ctx, url)
|
||||
conn, err := blob.OpenBucket(ctx, url)
|
||||
require.NoError(t, err)
|
||||
defer conn.Close()
|
||||
var iter = conn.List(nil)
|
||||
var files []string
|
||||
for {
|
||||
file, err := iter.Next(ctx)
|
||||
if err != nil {
|
||||
if err != nil && err == io.EOF {
|
||||
break
|
||||
}
|
||||
require.NoError(t, err)
|
||||
files = append(files, file.Key)
|
||||
}
|
||||
return files
|
||||
|
Reference in New Issue
Block a user