forked from TencentBlueKing/bk-iam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (45 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
.PHONY: init dep migrations mock lint lint-dupl test bench build build-linux build-aarch64 clean all serve cov
VERSION = `head -1 VERSION`
init:
pip install pre-commit
pre-commit install
# go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.29.0
# for make doc
go get -u github.com/swaggo/swag/cmd/[email protected]
# for make mock
go install github.com/golang/mock/[email protected]
dep:
go mod tidy
go mod vendor
doc:
swag init
godoc:
godoc -http=127.0.0.1:6060 -goroot="."
# migrations:
# sh pkg/database/migrations/template.sh pkg/database/migrations
mock:
go generate ./...
lint:
export GOFLAGS=-mod=vendor
golangci-lint run
lint-dupl:
export GOFLAGS=-mod=vendor
golangci-lint run --no-config --disable-all --enable=dupl
test:
go test -mod=vendor -gcflags=all=-l $(shell go list ./... | grep -v mock | grep -v docs) -covermode=count -coverprofile .coverage.cov
cov:
go tool cover -html=.coverage.cov
bench:
go test -run=nonthingplease -benchmem -bench=. $(shell go list ./... | grep -v /vendor/)
build:
# go build .
go build -mod=vendor -tags=jsoniter -ldflags "-X iam/pkg/version.Version=${VERSION} -X iam/pkg/version.Commit=`git rev-parse HEAD` -X iam/pkg/version.BuildTime=`date +%Y-%m-%d_%I:%M:%S` -X 'iam/pkg/version.GoVersion=`go version`'" .
build-linux:
# GOOS=linux GOARCH=amd64 go build .
GOOS=linux GOARCH=amd64 go build -mod=vendor -tags=jsoniter -ldflags "-X iam/pkg/version.Version=${VERSION} -X iam/pkg/version.Commit=`git rev-parse HEAD` -X iam/pkg/version.BuildTime=`date +%Y-%m-%d_%I:%M:%S` -X 'iam/pkg/version.GoVersion=`go version`'" .
build-aarch64:
GOOS=linux GOARCH=arm64 go build -mod=vendor -tags=jsoniter -ldflags "-X iam/pkg/version.Version=${VERSION} -X iam/pkg/version.Commit=`git rev-parse HEAD` -X iam/pkg/version.BuildTime=`date +%Y-%m-%d_%I:%M:%S` -X 'iam/pkg/version.GoVersion=`go version`'" .
all: lint test build
serve: build
./iam -c config.yaml