-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (36 loc) · 1.64 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
VERSION=$(shell git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD)
GITCOMMIT=$(shell git rev-parse --short HEAD 2> /dev/null || true)
BUILDTIME=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
PROJECT_NAME = `basename ${PWD}`
PROJECT_DIR = ${PWD}
MODULE_NAME = `go list`
LDFLAGS = \
-X $(MODULE_NAME)/version.GitCommit=$(GITCOMMIT) \
-X $(MODULE_NAME)/version.Version=$(VERSION) \
-X $(MODULE_NAME)/version.BuildTime=$(BUILDTIME)
clean: ## Remove ignored files and folders
git check-ignore --no-index \
{,.[!.]}** \
{,.[!.]}**/{,.[!.]}** \
{,.[!.]}**/{,.[!.]}**/{,.[!.]}** \
{,.[!.]}**/{,.[!.]}**/{,.[!.]}**/{,.[!.]}** \
| grep -v vendor \
| grep -v .idea \
| sort | uniq \
| while read line; do rm -rf "$$line";done;
binary: ## Build binary to current OS
CGO_ENABLED=0 GOPRIVATE="github.com/osodracnai" go build -o "$(PROJECT_NAME)" --ldflags "$(LDFLAGS)" "$(MODULE_NAME)"
.PHONY: fmt
fmt: ## fmt go files
go fmt `go list ./... | grep -v /vendor/`
vet: ## vet go files
go vet `go list ./... | grep -v /vendor/`
.PHONY: test
test: ## Test go files
go test -race `go list ./...|grep -v "/vendor"` -coverpkg=./... -coverprofile ./cover.out ./...
mock: ## generates mocks
go install github.com/golang/mock/mockgen@v1.6.0
mockgen -source=./pkg/server/accounts/accounts.go -destination=mocks/accounts_mock.go -package=mocks
mockgen -source=./pkg/server/transactions/transactions.go -destination=mocks/transactions_mock.go -package=mocks
help: ## print this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)