-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
56 lines (46 loc) · 1.28 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
PREFIX ?= $(shell pwd)/bin/
GO ?= go
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
GOHOSTOS ?= $(shell $(GO) env GOHOSTOS)
GOHOSTARCH ?= $(shell $(GO) env GOHOSTARCH)
BUILDTIME = ${shell TZ=Asia/Shanghai date +%Y-%m-%dT%T%z}
GOBUILD = CGO_ENABLED=0 go build -trimpath
ifdef VERSION
VERSION=${VERSION}
else
VERSION=$(shell git describe --tags --always --dirty="-dirty")
endif
ifdef GITCOMMIT
GITCOMMIT=${GITCOMMIT}
else
GITCOMMIT=$(shell git rev-parse HEAD)
endif
# Go Reproducible Build
ifdef REPRODUCIBLE_BUILD
GOBUILD=CGO_ENABLED=0 go build -trimpath -ldflags=-buildid=
BUILDTIME=0
endif
.PHONY: tidy
tidy:
@go mod tidy
.PHONY: test
test:
@go test -coverprofile=./cover.out -covermode=atomic ./...
.PHONY: lint
lint:
@golangci-lint run --issues-exit-code=0 --fix ./...
.PHONY: benchmark
benchmark:
@go test -benchmem -bench=. ./...
.PHONY: generate
generate:
@go generate ./...
.PHONY: docs
docs:
@swag init --outputTypes go,json -g ./cmd/dev/server.go --exclude ./
@swag fmt -g ./cmd/dev/server.go --exclude ./
.PHONY: build
build:
@echo ">> rebuilding binaries"
${GOBUILD} -o ./bin/dev ./cmd/dev
${GOBUILD} -o ./bin/gen-lint ./cmd/gen-lint