Skip to content

Manage build tools via go.mod #724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ deploy:
skip_cleanup: true
script:
- make test_race
- curl -sL https://git.io/goreleaser | bash
- make release
on:
tags: true
# it's important to build on the newest version of go:
Expand Down
39 changes: 12 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
.DEFAULT_GOAL = test
.PHONY: FORCE

# Enable Go module support across all commands.
# enable module support across all go commands.
export GO111MODULE = on
# opt-in to vendor deps across all go commands.
export GOFLAGS = -mod=vendor

# Build

Expand Down Expand Up @@ -59,51 +61,35 @@ fast_check_generated:
.PHONY: fast_check_generated

release:
rm -rf dist
curl -sL https://git.io/goreleaser | bash
go run ./vendor/github.com/goreleaser/goreleaser
.PHONY: release

# Non-PHONY targets (real files)

golangci-lint: FORCE pkg/logutils/mock_logutils/mock_log.go
go build -o $@ ./cmd/golangci-lint

tools/mockgen: go.mod go.sum
GOBIN=$(CURDIR)/tools go install github.com/golang/mock/mockgen

tools/goimports: go.mod go.sum
GOBIN=$(CURDIR)/tools go install golang.org/x/tools/cmd/goimports

tools/go.mod:
tools:
@mkdir -p tools
@rm -f $@
cd tools && go mod init local-tools

tools/godownloader: Makefile tools/go.mod
# https://github.com/goreleaser/godownloader/issues/133
cd tools && GOBIN=$(CURDIR)/tools go get -u github.com/goreleaser/godownloader

tools/svg-term:
@mkdir -p tools
tools/svg-term: tools
cd tools && npm ci
ln -sf node_modules/.bin/svg-term $@

tools/Dracula.itermcolors:
@mkdir -p tools
tools/Dracula.itermcolors: tools
curl -fL -o $@ https://raw.githubusercontent.com/dracula/iterm/master/Dracula.itermcolors

docs/demo.svg: tools/svg-term tools/Dracula.itermcolors
PATH=$(CURDIR)/tools:$${PATH} svg-term --cast=183662 --out docs/demo.svg --window --width 110 --height 30 --from 2000 --to 20000 --profile ./tools/Dracula.itermcolors --term iterm2
./tools/svg-term --cast=183662 --out docs/demo.svg --window --width 110 --height 30 --from 2000 --to 20000 --profile ./tools/Dracula.itermcolors --term iterm2

install.sh: tools/godownloader .goreleaser.yml
PATH=$(CURDIR)/tools:$${PATH} tools/godownloader .goreleaser.yml | sed '/DO NOT EDIT/s/ on [0-9TZ:-]*//' > $@
install.sh: .goreleaser.yml
go run ./vendor/github.com/goreleaser/godownloader .goreleaser.yml | sed '/DO NOT EDIT/s/ on [0-9TZ:-]*//' > $@

README.md: FORCE golangci-lint
go run ./scripts/gen_readme/main.go

pkg/logutils/mock_logutils/mock_log.go: tools/mockgen tools/goimports pkg/logutils/log.go
@rm -f $@
PATH=$(CURDIR)/tools:$${PATH} go generate ./...
pkg/logutils/mock_logutils/mock_log.go: pkg/logutils/log.go
go generate ./...

go.mod: FORCE
go mod tidy
Expand All @@ -112,5 +98,4 @@ go.sum: go.mod

.PHONY: vendor
vendor: go.mod go.sum
rm -rf vendor
go mod vendor
19 changes: 15 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ require (
github.com/golangci/prealloc v0.0.0-20180630174525-215b22d4de21
github.com/golangci/revgrep v0.0.0-20180526074752-d9c87f5ffaf0
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4
github.com/goreleaser/godownloader v0.0.0-20190907185828-93b2b793cd90
github.com/goreleaser/goreleaser v0.118.0
github.com/matoous/godox v0.0.0-20190910121045-032ad8106c86
github.com/mattn/go-colorable v0.1.2
github.com/mitchellh/go-homedir v1.1.0
Expand All @@ -47,7 +49,16 @@ require (
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f
)

// https://github.com/golang/tools/pull/162
// https://github.com/golang/tools/pull/160
// https://github.com/golang/tools/pull/156
replace golang.org/x/tools => github.com/golangci/tools v0.0.0-20190915081525-6aa350649b1c
replace (
// Fix godownloader/goreleaser deps (ambiguous imports/invalid pseudo-version)
// https://github.com/goreleaser/godownloader/issues/133
// https://github.com/goreleaser/goreleaser/issues/1145
github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.0.1+incompatible
github.com/census-instrumentation/opencensus-proto => github.com/census-instrumentation/opencensus-proto v0.2.1
github.com/go-macaron/cors => github.com/go-macaron/cors v0.0.0-20190418220122-6fd6a9bfe14e

// https://github.com/golang/tools/pull/156
// https://github.com/golang/tools/pull/160
// https://github.com/golang/tools/pull/162
golang.org/x/tools => github.com/golangci/tools v0.0.0-20190915081525-6aa350649b1c
)
825 changes: 823 additions & 2 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/logutils/log.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package logutils

//go:generate mockgen -source log.go -destination mock_logutils/mock_log.go
//go:generate goimports -w mock_logutils/mock_log.go
//go:generate go run ../../vendor/github.com/golang/mock/mockgen -source log.go -destination mock_logutils/mock_log.go
//go:generate go run ../../vendor/golang.org/x/tools/cmd/goimports -w mock_logutils/mock_log.go

type Log interface {
Fatalf(format string, args ...interface{})
Expand Down
16 changes: 16 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// +build tools

package tools

// Manage tool dependencies via go.mod.
//
// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
// https://github.com/golang/go/issues/25922
//
// nolint
import (
_ "github.com/golang/mock/mockgen"
_ "github.com/goreleaser/godownloader"
_ "github.com/goreleaser/goreleaser"
_ "golang.org/x/tools/cmd/goimports"
)
202 changes: 202 additions & 0 deletions vendor/cloud.google.com/go/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading