From 0410f5bc7270b3f4d792f4d25e9e60f7a39c03f2 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sat, 1 Jul 2017 21:31:55 -0300 Subject: [PATCH] cleaning up --- context/context.go | 17 +++-------------- pipeline/build/build.go | 1 - pipeline/build/build_test.go | 33 +++++++++++++-------------------- 3 files changed, 16 insertions(+), 35 deletions(-) diff --git a/context/context.go b/context/context.go index 7b93ba935..d36195401 100644 --- a/context/context.go +++ b/context/context.go @@ -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{}, } } diff --git a/pipeline/build/build.go b/pipeline/build/build.go index a9294a5c7..49a1e4874 100644 --- a/pipeline/build/build.go +++ b/pipeline/build/build.go @@ -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 != "" { diff --git a/pipeline/build/build_test.go b/pipeline/build/build_test.go index cf48c0fb6..e2f1938b9 100644 --- a/pipeline/build/build_test.go +++ b/pipeline/build/build_test.go @@ -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"