This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 88
/
Makefile
70 lines (51 loc) · 2.01 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
VERSION ?= $(shell cat VERSION)
GITCOMMIT = $(shell git rev-parse HEAD 2>/dev/null)
GITBRANCH = $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
BUILDTIME := $(shell TZ=GMT date "+%Y-%m-%d_%H:%M_GMT")
SRCS = $(shell find . -name '*.go' | grep -v '^./vendor/')
PKGS := $(foreach pkg,$(subst ./ , , $(sort $(dir $(SRCS)))), $(pkg))
DOCKER_IMG := dockerhub.grammarly.io/golang-1.8.3-cross:v1
TESTARGS ?=
export GO15VENDOREXPERIMENT := 1
default:
go build -v
install:
go install -v
dist_dir:
mkdir -p ./dist/linux_amd64
mkdir -p ./dist/darwin_amd64
cross: dist_dir
docker run --rm -ti -v $(shell pwd):/go/src/github.com/grammarly/rocker \
-e GOOS=linux -e GOARCH=amd64 \
-w /go/src/github.com/grammarly/rocker \
$(DOCKER_IMG) go build \
-ldflags "-X main.Version=$(VERSION) -X main.GitCommit=$(GITCOMMIT) -X main.GitBranch=$(GITBRANCH) -X main.BuildTime=$(BUILDTIME)" \
-v -o ./dist/linux_amd64/rocker
docker run --rm -ti -v $(shell pwd):/go/src/github.com/grammarly/rocker \
-e GOOS=darwin -e GOARCH=amd64 \
-w /go/src/github.com/grammarly/rocker \
$(DOCKER_IMG) go build \
-ldflags "-X main.Version=$(VERSION) -X main.GitCommit=$(GITCOMMIT) -X main.GitBranch=$(GITBRANCH) -X main.BuildTime=$(BUILDTIME)" \
-v -o ./dist/darwin_amd64/rocker
cross_tars: cross
COPYFILE_DISABLE=1 tar -zcvf ./dist/rocker_linux_amd64.tar.gz -C dist/linux_amd64 rocker
COPYFILE_DISABLE=1 tar -zcvf ./dist/rocker_darwin_amd64.tar.gz -C dist/darwin_amd64 rocker
clean:
rm -Rf dist
testdeps:
@ go get github.com/GeertJohan/fgt
fmtcheck:
$(foreach file,$(SRCS),gofmt $(file) | diff -u $(file) - || exit;)
lint:
@ go get -u github.com/golang/lint/golint
$(foreach file,$(SRCS),fgt golint -min_confidence 0.9 $(file) || exit;)
vet:
$(foreach pkg,$(PKGS),fgt go vet $(pkg) || exit;)
gocyclo:
@ go get github.com/fzipp/gocyclo
gocyclo -over 25 ./src
test: testdeps fmtcheck vet lint
go test ./src/... $(TESTARGS)
test_integration:
go test -v ./test/... --args -verbosity=0
.PHONY: clean test fmtcheck lint vet gocyclo default