1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-29 01:44:39 +02:00

fix: improved artifact add logs

This commit is contained in:
Carlos Alexandro Becker 2017-12-18 09:19:02 -02:00
parent 10c6df73c0
commit 530feac44a
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
6 changed files with 15 additions and 8 deletions

View File

@ -4,6 +4,7 @@ TEST_OPTIONS?=
# Install all the build and lint dependencies
setup:
go get -u golang.org/x/tools/cmd/stringer
go get -u github.com/alecthomas/gometalinter
go get -u github.com/golang/dep/cmd/dep
go get -u github.com/pierrre/gotestcover
@ -41,6 +42,7 @@ ci: test lint
# Build a beta version of goreleaser
build:
go generate ./...
go build
.PHONY: build

1
internal/artifact/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
type_string.go

View File

@ -8,6 +8,7 @@ import (
)
// Type defines the type of an artifact
//go:generate stringer -type=Type
type Type int
const (
@ -57,16 +58,12 @@ func (artifacts Artifacts) List() []Artifact {
return artifacts.items
}
// Platform returns the platform string of a given artifact
func (a Artifact) Platform() string {
return a.Goos + a.Goarch + a.Goarm
}
// GroupByPlatform groups the artifacts by their platform
func (artifacts Artifacts) GroupByPlatform() map[string][]Artifact {
var result = map[string][]Artifact{}
for _, a := range artifacts.items {
result[a.Platform()] = append(result[a.Platform()], a)
plat := a.Goos + a.Goarch + a.Goarm
result[plat] = append(result[plat], a)
}
return result
}
@ -76,7 +73,9 @@ func (artifacts *Artifacts) Add(a Artifact) {
artifacts.lock.Lock()
defer artifacts.lock.Unlock()
log.WithFields(log.Fields{
"artifact": a,
"name": a.Name,
"path": a.Path,
"type": a.Type,
}).Info("added new artifact")
artifacts.items = append(artifacts.items, a)
}

View File

@ -1,12 +1,16 @@
package artifact
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"golang.org/x/sync/errgroup"
)
// ensure Type implements the stringer interface...
var _ fmt.Stringer = Type(0)
func TestAdd(t *testing.T) {
var g errgroup.Group
var artifacts = New()

View File

@ -28,6 +28,7 @@ func (t Target) Env() []string {
}
func (t Target) String() string {
// TODO: maybe replace this as suggested to OS_ArchArm?
return fmt.Sprintf("%v%v%v", t.OS, t.Arch, t.Arm)
}

View File

@ -67,7 +67,7 @@ func (Pipe) Default(ctx *context.Context) error {
}
func create(ctx *context.Context, artifacts []artifact.Artifact) error {
var format = archiveformat.For(ctx, artifacts[0].Platform())
var format = archiveformat.For(ctx, artifacts[0].Goos)
folder, err := nametemplate.Apply(ctx, artifacts[0], ctx.Config.ProjectName)
if err != nil {
return err