From 984ba480686c448d3d49e42e611f77a2adbe8bb6 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 9 Apr 2017 10:43:23 -0300 Subject: [PATCH 1/4] fixed several lint errors --- pipeline/build/build.go | 29 ++++++++++++----------------- pipeline/env/env_test.go | 2 +- pipeline/git/git.go | 3 ++- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/pipeline/build/build.go b/pipeline/build/build.go index 692924094..24192a52e 100644 --- a/pipeline/build/build.go +++ b/pipeline/build/build.go @@ -23,12 +23,8 @@ func (Pipe) Description() string { // Run the pipe func (Pipe) Run(ctx *context.Context) error { - if ctx.Config.Build.Hooks.Pre != "" { - log.Println("Running pre-build hook", ctx.Config.Build.Hooks.Pre) - cmd := strings.Fields(ctx.Config.Build.Hooks.Pre) - if err := run(runtime.GOOS, runtime.GOARCH, cmd); err != nil { - return err - } + if err := runHook(ctx.Config.Build.Hooks.Pre); err != nil { + return err } var g errgroup.Group for _, goos := range ctx.Config.Build.Goos { @@ -51,14 +47,16 @@ func (Pipe) Run(ctx *context.Context) error { if err := g.Wait(); err != nil { return err } - if ctx.Config.Build.Hooks.Post != "" { - log.Println("Running post-build hook", ctx.Config.Build.Hooks.Post) - cmd := strings.Fields(ctx.Config.Build.Hooks.Post) - if err := run(runtime.GOOS, runtime.GOARCH, cmd); err != nil { - return err - } + return runHook(ctx.Config.Build.Hooks.Post) +} + +func runHook(hook string) error { + if hook == "" { + return nil } - return nil + log.Println("Running build hook", hook) + cmd := strings.Fields(hook) + return run(runtime.GOOS, runtime.GOARCH, cmd) } func build(name, goos, goarch string, ctx *context.Context) error { @@ -77,10 +75,7 @@ func build(name, goos, goarch string, ctx *context.Context) error { return err } cmd = append(cmd, "-ldflags="+flags, "-o", output, ctx.Config.Build.Main) - if err := run(goos, goarch, cmd); err != nil { - return err - } - return nil + return run(goos, goarch, cmd) } func run(goos, goarch string, command []string) error { diff --git a/pipeline/env/env_test.go b/pipeline/env/env_test.go index 287fb3f13..01bb766ed 100644 --- a/pipeline/env/env_test.go +++ b/pipeline/env/env_test.go @@ -24,7 +24,7 @@ func TestValidEnv(t *testing.T) { func TestInvalidEnv(t *testing.T) { assert := assert.New(t) - os.Unsetenv("GITHUB_TOKEN") + assert.NoError(os.Unsetenv("GITHUB_TOKEN")) var ctx = &context.Context{ Config: config.Project{}, } diff --git a/pipeline/git/git.go b/pipeline/git/git.go index f1a7db438..34b2434c5 100644 --- a/pipeline/git/git.go +++ b/pipeline/git/git.go @@ -46,7 +46,8 @@ func (Pipe) Run(ctx *context.Context) (err error) { } // removes usual `v` prefix ctx.Version = strings.TrimPrefix(tag, "v") - if matches, err := regexp.MatchString("^[0-9.]+", ctx.Version); !matches || err != nil { + matches, err := regexp.MatchString("^[0-9.]+", ctx.Version) + if err != nil || !matches { return ErrInvalidVersionFormat{ctx.Version} } commit, err := commitHash() From 9185da1f5d7029ac6c66bc5c8a4c6440f424cf90 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 9 Apr 2017 10:44:28 -0300 Subject: [PATCH 2/4] fixed msg --- pipeline/build/build.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline/build/build.go b/pipeline/build/build.go index 24192a52e..ee3f7ed93 100644 --- a/pipeline/build/build.go +++ b/pipeline/build/build.go @@ -54,7 +54,7 @@ func runHook(hook string) error { if hook == "" { return nil } - log.Println("Running build hook", hook) + log.Println("Running hook", hook) cmd := strings.Fields(hook) return run(runtime.GOOS, runtime.GOARCH, cmd) } From 9984b5e770789da684b80f520bf09c2b2eaa8887 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 9 Apr 2017 10:44:37 -0300 Subject: [PATCH 3/4] trying to run gometalinter on build again --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 222e54bed..acd0ddb77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: go go: 1.8 install: make setup script: - - make test + - make ci after_success: - go get github.com/mattn/goveralls - goveralls -coverprofile=coverage.out -service=travis-ci -repotoken="$COVERALLS_TOKEN" From 8d3af579cddef609c130ddb253ff6b585e82f8aa Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 9 Apr 2017 10:49:59 -0300 Subject: [PATCH 4/4] Revert "trying to run gometalinter on build again" This reverts commit 9984b5e770789da684b80f520bf09c2b2eaa8887. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index acd0ddb77..222e54bed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: go go: 1.8 install: make setup script: - - make ci + - make test after_success: - go get github.com/mattn/goveralls - goveralls -coverprofile=coverage.out -service=travis-ci -repotoken="$COVERALLS_TOKEN"