1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-03 13:11:48 +02:00

feat(pipe/build): Report hook error in addition to stdout (#1430)

This helps in situations where hook couldn't run at all,
e.g. because of insufficient permissions.

Previously such failure would only be reported as
empty stdout/stderr output - this allows exposure
of the real root cause.
This commit is contained in:
Radek Simko 2020-04-12 14:44:12 +01:00 committed by GitHub
parent e580a18382
commit cfa0cc2d2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -162,7 +162,7 @@ func run(ctx *context.Context, command, env []string) error {
log.Debug("running")
if out, err := cmd.CombinedOutput(); err != nil {
log.WithError(err).Debug("failed")
return errors.New(string(out))
return errors.Wrapf(err, "%q", string(out))
}
return nil
}

View File

@ -182,14 +182,14 @@ func TestRunPipeFailingHooks(t *testing.T) {
ctx.Git.CurrentTag = "2.3.4"
ctx.Config.Builds[0].Hooks.Pre = "exit 1"
ctx.Config.Builds[0].Hooks.Post = "echo post"
assert.EqualError(t, Pipe{}.Run(ctx), `pre hook failed: `)
assert.EqualError(t, Pipe{}.Run(ctx), `pre hook failed: "": exec: "exit": executable file not found in $PATH`)
})
t.Run("post-hook", func(t *testing.T) {
var ctx = context.New(config)
ctx.Git.CurrentTag = "2.3.4"
ctx.Config.Builds[0].Hooks.Pre = "echo pre"
ctx.Config.Builds[0].Hooks.Post = "exit 1"
assert.EqualError(t, Pipe{}.Run(ctx), `post hook failed: `)
assert.EqualError(t, Pipe{}.Run(ctx), `post hook failed: "": exec: "exit": executable file not found in $PATH`)
})
}