-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
55 lines (40 loc) · 1.39 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
.PHONY: install build doc fmt gen lint test vet bench
PKG_NAME=$(shell basename `pwd`)
TARGET_OS="linux"
VERSION_VAR=main.BuildVersion
TIMESTAMP_VAR=main.BuildTimestamp
VERSION=$(shell git describe --always --dirty --tags)
TIMESTAMP=$(shell date -u '+%Y-%m-%d_%I:%M:%S%p')
GOBUILD_VERSION_ARGS := -ldflags "-X $(VERSION_VAR)=$(VERSION) -X $(TIMESTAMP_VAR)=$(TIMESTAMP)"
CONTAINER_NAME=$(shell grep "FROM " contrib/docker/Dockerfile | sed 's/FROM \(.*\).*\:.*/\1/')
CONTAINER_VERSION=$(shell grep "FROM " contrib/docker/Dockerfile | sed 's/FROM .*\:\(.*\).*/\1/')
default: install
install:
go get -x $(GOBUILD_VERSION_ARGS) -t -v ./...
build:
go build -x $(GOBUILD_VERSION_ARGS) -v -o ./bin/$(PKG_NAME)
docker: docker_build docker_container
docker_container:
docker build -t $(CONTAINER_NAME)-kube-template:$(CONTAINER_VERSION) ./contrib/docker
docker_build:
CGO_ENABLED=0 GOOS=$(TARGET_OS) go build -x $(GOBUILD_VERSION_ARGS) -a -installsuffix cgo -v -o ./contrib/docker/bin/$(PKG_NAME)
clean:
rm -dRf ./bin
doc:
godoc -http=:6060
fmt:
go fmt ./...
gen:
go generate
# https://golangci.com/
# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
lint:
golangci-lint run --timeout=300s
test:
go test ./...
# Runs benchmarks
bench:
go test ./... -bench=.
# https://godoc.org/golang.org/x/tools/cmd/vet
vet:
go vet ./...