mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-01 13:07:49 +02:00
fix: goFish check for same OS/Arch is unnecessary (#2604)
Signed-off-by: Engin Diri <engin.diri@mail.schwarz>
This commit is contained in:
parent
d4e575dd47
commit
9fd61fb956
@ -123,15 +123,15 @@ func doRun(ctx *context.Context, goFish config.GoFish, cl client.Client) error {
|
||||
}
|
||||
|
||||
filename := goFish.Name + ".lua"
|
||||
path := filepath.Join(ctx.Config.Dist, filename)
|
||||
log.WithField("food", path).Info("writing")
|
||||
if err := os.WriteFile(path, []byte(content), 0o644); err != nil { //nolint: gosec
|
||||
luaPath := filepath.Join(ctx.Config.Dist, filename)
|
||||
log.WithField("food", luaPath).Info("writing")
|
||||
if err := os.WriteFile(luaPath, []byte(content), 0o644); err != nil { //nolint: gosec
|
||||
return fmt.Errorf("failed to write gofish food: %w", err)
|
||||
}
|
||||
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Name: filename,
|
||||
Path: path,
|
||||
Path: luaPath,
|
||||
Type: artifact.GoFishRig,
|
||||
Extra: map[string]interface{}{
|
||||
goFishConfigExtra: goFish,
|
||||
@ -238,11 +238,6 @@ func dataFor(ctx *context.Context, cfg config.GoFish, cl client.Client, artifact
|
||||
Target: art.ExtraOr(artifact.ExtraBinary, art.Name).(string),
|
||||
})
|
||||
}
|
||||
for _, v := range result.ReleasePackages {
|
||||
if v.OS == art.Goos && v.Arch == art.Goarch {
|
||||
return result, ErrMultipleArchivesSameOS
|
||||
}
|
||||
}
|
||||
result.ReleasePackages = append(result.ReleasePackages, releasePackage)
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package gofish
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@ -573,154 +572,6 @@ func TestRunPipeNoBuilds(t *testing.T) {
|
||||
require.False(t, client.CreatedFile)
|
||||
}
|
||||
|
||||
func TestRunPipeMultipleArchivesSameOsBuild(t *testing.T) {
|
||||
ctx := context.New(
|
||||
config.Project{
|
||||
Rigs: []config.GoFish{
|
||||
{
|
||||
Rig: config.RepoRef{
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
ctx.TokenType = context.TokenTypeGitHub
|
||||
f, err := ioutil.TempFile(t.TempDir(), "")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
require.NoError(t, f.Close())
|
||||
})
|
||||
|
||||
tests := []struct {
|
||||
expectedError error
|
||||
osarchs []struct {
|
||||
goos string
|
||||
goarch string
|
||||
goarm string
|
||||
}
|
||||
}{
|
||||
{
|
||||
expectedError: ErrMultipleArchivesSameOS,
|
||||
osarchs: []struct {
|
||||
goos string
|
||||
goarch string
|
||||
goarm string
|
||||
}{
|
||||
{
|
||||
goos: "darwin",
|
||||
goarch: "amd64",
|
||||
},
|
||||
{
|
||||
goos: "darwin",
|
||||
goarch: "amd64",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedError: ErrMultipleArchivesSameOS,
|
||||
osarchs: []struct {
|
||||
goos string
|
||||
goarch string
|
||||
goarm string
|
||||
}{
|
||||
{
|
||||
goos: "linux",
|
||||
goarch: "amd64",
|
||||
},
|
||||
{
|
||||
goos: "linux",
|
||||
goarch: "amd64",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedError: ErrMultipleArchivesSameOS,
|
||||
osarchs: []struct {
|
||||
goos string
|
||||
goarch string
|
||||
goarm string
|
||||
}{
|
||||
{
|
||||
goos: "linux",
|
||||
goarch: "arm64",
|
||||
},
|
||||
{
|
||||
goos: "linux",
|
||||
goarch: "arm64",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedError: ErrMultipleArchivesSameOS,
|
||||
osarchs: []struct {
|
||||
goos string
|
||||
goarch string
|
||||
goarm string
|
||||
}{
|
||||
{
|
||||
goos: "linux",
|
||||
goarch: "arm",
|
||||
goarm: "6",
|
||||
},
|
||||
{
|
||||
goos: "linux",
|
||||
goarch: "arm",
|
||||
goarm: "6",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedError: ErrMultipleArchivesSameOS,
|
||||
osarchs: []struct {
|
||||
goos string
|
||||
goarch string
|
||||
goarm string
|
||||
}{
|
||||
{
|
||||
goos: "linux",
|
||||
goarch: "arm",
|
||||
goarm: "5",
|
||||
},
|
||||
{
|
||||
goos: "linux",
|
||||
goarch: "arm",
|
||||
goarm: "6",
|
||||
},
|
||||
{
|
||||
goos: "linux",
|
||||
goarch: "arm",
|
||||
goarm: "7",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
for idx, ttt := range test.osarchs {
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Name: fmt.Sprintf("bin%d", idx),
|
||||
Path: f.Name(),
|
||||
Goos: ttt.goos,
|
||||
Goarch: ttt.goarch,
|
||||
Type: artifact.UploadableArchive,
|
||||
Extra: map[string]interface{}{
|
||||
artifact.ExtraID: fmt.Sprintf("foo%d", idx),
|
||||
artifact.ExtraFormat: "tar.gz",
|
||||
artifact.ExtraBinaries: []string{"foo"},
|
||||
},
|
||||
})
|
||||
}
|
||||
client := client.NewMock()
|
||||
require.Equal(t, test.expectedError, runAll(ctx, client))
|
||||
require.False(t, client.CreatedFile)
|
||||
// clean the artifacts for the next run
|
||||
ctx.Artifacts = artifact.New()
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunPipeBinaryRelease(t *testing.T) {
|
||||
folder := t.TempDir()
|
||||
ctx := &context.Context{
|
||||
|
Loading…
x
Reference in New Issue
Block a user