Skip to content
Permalink
Browse files

Merge remote-tracking branch 'origin/master' into sem

  • Loading branch information...
caarlos0 committed Jul 4, 2018
2 parents 31f0599 + 47b6bd5 commit 846f5ead40252cc44334df75fe908825db12b12d
@@ -1,7 +1,7 @@
dist: trusty
sudo: required
language: go
go: '1.10'
go: '1.10.3'
services:
- docker
addons:

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -9,6 +9,8 @@ export PATH := ./bin:$(PATH)
setup:
go get -u golang.org/x/tools/cmd/stringer
go get -u golang.org/x/tools/cmd/cover
# TODO: temporary hack for https://github.com/golang/go/issues/21387
(cd $$GOPATH/src/golang.org/x/tools; git checkout ae8cc594552814363a7aeeb4f2825515a771fa38; go install ./cmd/stringer/... ; go install ./cmd/cover/...)
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
curl -sfL https://install.goreleaser.com/github.com/gohugoio/hugo.sh | sh
curl -sfL https://install.goreleaser.com/github.com/caarlos0/bandep.sh | sh
@@ -44,7 +46,8 @@ fmt:

# Run all the linters
lint:
golangci-lint run --tests=false --enable-all ./...
# TODO: fix tests and lll issues
./bin/golangci-lint run --tests=false --enable-all --disable=lll ./...
find . -name '*.md' -not -wholename './vendor/*' | xargs prettier -l
.PHONY: lint

@@ -55,7 +55,7 @@ func (*Builder) WithDefaults(build config.Build) config.Build {

// Build builds a golang build
func (*Builder) Build(ctx *context.Context, build config.Build, options api.Options) error {
if err := checkMain(ctx, build); err != nil {
if err := checkMain(build); err != nil {
return err
}
cmd := []string{"go", "build"}
@@ -187,7 +187,7 @@ func (b buildTarget) Env() []string {
}
}

func checkMain(ctx *context.Context, build config.Build) error {
func checkMain(build config.Build) error {
var main = build.Main
if main == "" {
main = "."
@@ -19,6 +19,7 @@ func (t target) String() string {
}

func matrix(build config.Build) (result []string) {
// nolint:prealloc
var targets []target
for _, target := range allBuildTargets(build) {
if !valid(target) {
@@ -2,7 +2,6 @@
package git

import (
"bytes"
"errors"
"os/exec"
"strings"
@@ -18,18 +17,17 @@ func IsRepo() bool {

// Run runs a git command and returns its output or errors
func Run(args ...string) (string, error) {
// TODO: use exex.CommandContext here and refactor.
/* #nosec */
var cmd = exec.Command("git", args...)
log.WithField("args", args).Debug("running git")
var stdout bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return "", errors.New(stderr.String())
bts, err := cmd.CombinedOutput()
log.WithField("output", string(bts)).
Debug("git result")
if err != nil {
return "", errors.New(string(bts))
}
log.WithField("output", stdout.String()).Debug("git result")
return stdout.String(), nil
return string(bts), nil
}

// Clean the output
@@ -110,7 +110,7 @@ func doRun(ctx *context.Context, client client.Client) error {
return ErrTooManyDarwin64Builds
}

content, err := buildFormula(ctx, client, archives[0])
content, err := buildFormula(ctx, archives[0])
if err != nil {
return err
}
@@ -141,8 +141,8 @@ func doRun(ctx *context.Context, client client.Client) error {
return client.CreateFile(ctx, ctx.Config.Brew.CommitAuthor, ctx.Config.Brew.GitHub, content, path, msg)
}

func buildFormula(ctx *context.Context, client client.Client, artifact artifact.Artifact) (bytes.Buffer, error) {
data, err := dataFor(ctx, client, artifact)
func buildFormula(ctx *context.Context, artifact artifact.Artifact) (bytes.Buffer, error) {
data, err := dataFor(ctx, artifact)
if err != nil {
return bytes.Buffer{}, err
}
@@ -158,7 +158,7 @@ func doBuildFormula(data templateData) (out bytes.Buffer, err error) {
return
}

func dataFor(ctx *context.Context, client client.Client, artifact artifact.Artifact) (result templateData, err error) {
func dataFor(ctx *context.Context, artifact artifact.Artifact) (result templateData, err error) {
sum, err := checksum.SHA256(artifact.Path)
if err != nil {
return
@@ -62,7 +62,7 @@ func (Pipe) Run(ctx *context.Context) (err error) {
artifact := artifact
g.Go(func() error {
defer sem.Release()
return checksums(ctx, file, artifact)
return checksums(file, artifact)
})
}
ctx.Artifacts.Add(artifact.Artifact{
@@ -73,7 +73,7 @@ func (Pipe) Run(ctx *context.Context) (err error) {
return g.Wait()
}

func checksums(ctx *context.Context, file *os.File, artifact artifact.Artifact) error {
func checksums(file *os.File, artifact artifact.Artifact) error {
log.WithField("file", artifact.Name).Info("checksumming")
sha, err := checksum.SHA256(artifact.Path)
if err != nil {
@@ -149,6 +149,7 @@ func tagName(ctx *context.Context, tagTemplate string) (string, error) {
func process(ctx *context.Context, docker config.Docker, artifact artifact.Artifact, seed int) error {
var root = filepath.Dir(artifact.Path)
var dockerfile = filepath.Join(root, filepath.Base(docker.Dockerfile)) + fmt.Sprintf(".%d", seed)
// nolint:prealloc
var images []string
for _, tagTemplate := range docker.TagTemplates {
tag, err := tagName(ctx, tagTemplate)
@@ -27,6 +27,7 @@ func init() {

func describeBody(ctx *context.Context) (bytes.Buffer, error) {
var out bytes.Buffer
// nolint:prealloc
var dockers []string
for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerImage)).List() {
dockers = append(dockers, a.Name)
@@ -63,7 +63,7 @@ func doRun(ctx *context.Context, client client.Client) error {

path := ctx.Config.ProjectName + ".json"

content, err := buildManifest(ctx, client, archives)
content, err := buildManifest(ctx, archives)
if err != nil {
return err
}
@@ -100,7 +100,7 @@ type Resource struct {
Bin string `json:"bin"` // name of binary inside the archive
}

func buildManifest(ctx *context.Context, client client.Client, artifacts []artifact.Artifact) (result bytes.Buffer, err error) {
func buildManifest(ctx *context.Context, artifacts []artifact.Artifact) (result bytes.Buffer, err error) {
manifest := Manifest{
Version: ctx.Version,
Architecture: make(map[string]Resource),
@@ -404,7 +404,7 @@ func Test_buildManifest(t *testing.T) {
},
},
}
out, err := buildManifest(ctx, &DummyClient{}, []artifact.Artifact{
out, err := buildManifest(ctx, []artifact.Artifact{
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64"},
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386"},
})
@@ -61,6 +61,7 @@ func (Pipe) Run(ctx *context.Context) error {
}

func sign(ctx *context.Context, artifacts []artifact.Artifact) error {
// nolint:prealloc
var sigs []string
for _, a := range artifacts {
sig, err := signone(ctx, a)
@@ -87,6 +88,7 @@ func signone(ctx *context.Context, artifact artifact.Artifact) (string, error) {
}
env["signature"] = expand(cfg.Signature, env)

// nolint:prealloc
var args []string
for _, a := range cfg.Args {
args = append(args, expand(a, env))

0 comments on commit 846f5ea

Please sign in to comment.
You can’t perform that action at this time.