-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (62 loc) · 1.85 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
71
72
73
74
VERSION=`git describe --tags --abbrev=0`
COMMIT=`git rev-parse HEAD`
.PHONY: init
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.46.2
# for ginkgo
go install github.com/onsi/ginkgo/v2/ginkgo@latest
# for make mock
go install github.com/golang/mock/[email protected]
# for gofumpt
go install mvdan.cc/gofumpt@latest
# for golines
go install github.com/segmentio/golines@latest
# for goimports
go install -v github.com/incu6us/goimports-reviser/v3@latest
# for swag
go install github.com/swaggo/swag/cmd/swag@latest
.PHONY: dep
dep:
go mod tidy
go mod vendor
.PHONY: doc
doc:
swag init
.PHONY: mock
mock:
go generate ./...
.PHONY: lint
lint:
export GOFLAGS=-mod=vendor
golangci-lint run --fast --skip-dirs mock
.PHONY: fmt
fmt:
golines ./ -m 120 -w --base-formatter gofmt --no-reformat-tags
gofumpt -l -w .
goimports-reviser -rm-unused -set-alias -format ./...
.PHONY: test
test:
go test -mod=vendor -gcflags=all=-l $(shell go list ./... | grep -v mock | grep -v docs) -covermode=count -coverprofile .coverage.cov
.PHONY: cov
cov:
go tool cover -html=.coverage.cov
.PHONY: bench
bench:
go test -run=nonthingplease -benchmem -bench=. $(shell go list ./... | grep -v /vendor/)
.PHONY: build
build:
go build -mod=vendor -ldflags "\
-X mygo/template/pkg/version.Version=${VERSION} \
-X mygo/template/pkg/version.Commit=${COMMIT} \
-X mygo/template/pkg/version.BuildTime=`date +%Y-%m-%d_%I:%M:%S` \
-X mygo/template/pkg/version.GoVersion=`go version` \
-w" .
.PHONY: serve
serve: build
./mygo -c config.yaml
.PHONY: dev-image
dev-image:
docker build --build-arg VERSION=${VERSION} --build-arg COMMIT=${COMMIT} -f Dockerfile . -t mygo:development