mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
cleaning up
This commit is contained in:
parent
cc5f80b3a9
commit
0410f5bc72
@ -27,7 +27,6 @@ type Context struct {
|
||||
Config config.Project
|
||||
Token string
|
||||
Git GitInfo
|
||||
Binaries map[string]string
|
||||
Folders map[string]string
|
||||
Artifacts []string
|
||||
ReleaseNotes string
|
||||
@ -38,7 +37,6 @@ type Context struct {
|
||||
}
|
||||
|
||||
var artifactsLock sync.Mutex
|
||||
var binariesLock sync.Mutex
|
||||
var foldersLock sync.Mutex
|
||||
|
||||
// AddArtifact adds a file to upload list
|
||||
@ -51,14 +49,6 @@ func (ctx *Context) AddArtifact(file string) {
|
||||
log.WithField("artifact", file).Info("new artifact")
|
||||
}
|
||||
|
||||
// AddBinary adds a built binary to the current context
|
||||
func (ctx *Context) AddBinary(key, file string) {
|
||||
binariesLock.Lock()
|
||||
defer binariesLock.Unlock()
|
||||
ctx.Binaries[key] = file
|
||||
log.WithField("key", key).WithField("binary", file).Info("new binary")
|
||||
}
|
||||
|
||||
// AddFolder adds a built binary to the current context
|
||||
func (ctx *Context) AddFolder(key, folder string) {
|
||||
foldersLock.Lock()
|
||||
@ -70,9 +60,8 @@ func (ctx *Context) AddFolder(key, folder string) {
|
||||
// New context
|
||||
func New(config config.Project) *Context {
|
||||
return &Context{
|
||||
Context: ctx.Background(),
|
||||
Config: config,
|
||||
Binaries: map[string]string{},
|
||||
Folders: map[string]string{},
|
||||
Context: ctx.Background(),
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,6 @@ func doBuild(ctx *context.Context, build config.Build, target buildTarget) error
|
||||
folder,
|
||||
build.Binary+ext.For(target.goos),
|
||||
)
|
||||
ctx.AddBinary(build.Binary+target.String(), binary)
|
||||
log.WithField("binary", binary).Info("building")
|
||||
cmd := []string{"go", "build"}
|
||||
if build.Flags != "" {
|
||||
|
@ -38,9 +38,8 @@ func TestBuild(t *testing.T) {
|
||||
},
|
||||
}
|
||||
var ctx = &context.Context{
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
Binaries: map[string]string{},
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
}
|
||||
assert.NoError(doBuild(ctx, ctx.Config.Builds[0], runtimeTarget))
|
||||
}
|
||||
@ -73,9 +72,8 @@ func TestRunFullPipe(t *testing.T) {
|
||||
},
|
||||
}
|
||||
var ctx = &context.Context{
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
Binaries: map[string]string{},
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
}
|
||||
assert.NoError(Pipe{}.Run(ctx))
|
||||
assert.True(exists(binary), binary)
|
||||
@ -109,9 +107,8 @@ func TestRunPipeArmBuilds(t *testing.T) {
|
||||
},
|
||||
}
|
||||
var ctx = &context.Context{
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
Binaries: map[string]string{},
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
}
|
||||
assert.NoError(Pipe{}.Run(ctx))
|
||||
assert.True(exists(binary), binary)
|
||||
@ -133,9 +130,8 @@ func TestBuildFailed(t *testing.T) {
|
||||
},
|
||||
}
|
||||
var ctx = &context.Context{
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
Binaries: map[string]string{},
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
}
|
||||
assert.Error(Pipe{}.Run(ctx))
|
||||
}
|
||||
@ -156,9 +152,8 @@ func TestRunPipeWithInvalidOS(t *testing.T) {
|
||||
},
|
||||
}
|
||||
var ctx = &context.Context{
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
Binaries: map[string]string{},
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
}
|
||||
assert.NoError(Pipe{}.Run(ctx))
|
||||
}
|
||||
@ -190,8 +185,7 @@ func TestRunInvalidNametemplate(t *testing.T) {
|
||||
func TestRunInvalidLdflags(t *testing.T) {
|
||||
var assert = assert.New(t)
|
||||
var ctx = &context.Context{
|
||||
Folders: map[string]string{},
|
||||
Binaries: map[string]string{},
|
||||
Folders: map[string]string{},
|
||||
Config: config.Project{
|
||||
Builds: []config.Build{
|
||||
{
|
||||
@ -227,9 +221,8 @@ func TestRunPipeFailingHooks(t *testing.T) {
|
||||
},
|
||||
}
|
||||
var ctx = &context.Context{
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
Binaries: map[string]string{},
|
||||
Config: config,
|
||||
Folders: map[string]string{},
|
||||
}
|
||||
t.Run("pre-hook", func(t *testing.T) {
|
||||
ctx.Config.Builds[0].Hooks.Pre = "exit 1"
|
||||
|
Loading…
x
Reference in New Issue
Block a user