forked from pingcap/go-tpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (31 loc) · 1000 Bytes
/
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
GOARCH := $(if $(GOARCH),$(GOARCH),amd64)
GO=GO15VENDOREXPERIMENT="1" CGO_ENABLED=0 GOARCH=$(GOARCH) GO111MODULE=on go
PACKAGE_LIST := go list ./...| grep -vE "cmd"
PACKAGES := $$($(PACKAGE_LIST))
FILES_TO_FMT := $(shell find . -path -prune -o -name '*.go' -print)
LDFLAGS += -X "main.version=$(shell git describe --tags --dirty --always)"
LDFLAGS += -X "main.commit=$(shell git rev-parse HEAD)"
LDFLAGS += -X "main.date=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
GOBUILD=$(GO) build -ldflags '$(LDFLAGS)'
# Image URL to use all building/pushing image targets
IMG ?= go-tpc:latest
all: format test build
format: vet fmt
fmt:
@echo "gofmt"
@gofmt -w ${FILES_TO_FMT}
@git diff --exit-code .
test:
go test ./... -cover $(PACKAGES)
build: mod
$(GOBUILD) -o ./bin/go-tpc cmd/go-tpc/*
vet:
go vet ./...
mod:
@echo "go mod tidy"
GO111MODULE=on go mod tidy
@git diff --exit-code -- go.sum go.mod
docker-build: test
docker build . -t ${IMG}
docker-push: docker-build
docker push ${IMG}