-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
109 lines (90 loc) · 1.83 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
-include .env
export
REPOSITORY_OWNER := loozhengyuan
REPOSITORY_NAME := grench
PROJECT_NAME := $(REPOSITORY_OWNER)/$(REPOSITORY_NAME)
MODULE_NAME := github.com/$(PROJECT_NAME)
BUILD_TIMESTAMP := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
BUILD_COMMIT := $(shell git rev-parse --verify HEAD)
BUILD_VERSION := v0.0.0
# EXECUTABLE_NAME := grench
COVERAGE_FILE := coverage.out
# .PHONY: install
# install:
# go install ./cmd/...
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: check
check:
go mod verify
go vet ./...
.PHONY: lint
lint:
test -z $$(gofmt -l .)
.PHONY: test
test:
go test \
-race \
-cover \
-coverprofile=$(COVERAGE_FILE) \
-covermode=atomic \
./...
go tool cover \
-func=$(COVERAGE_FILE)
.PHONY: test-all
test-all:
go test \
-race \
-cover \
-coverprofile=$(COVERAGE_FILE) \
-covermode=atomic \
-tags=unit,integration,e2e \
./...
go tool cover \
-func=$(COVERAGE_FILE)
.PHONY: bench
bench:
go test \
-benchmem \
-bench=. \
./...
# .PHONY: build
# build:
# CGO_ENABLED=0 \
# go build \
# -ldflags=" \
# -X $(MODULE_NAME)/internal/build.Version=$(BUILD_VERSION) \
# -X $(MODULE_NAME)/internal/build.CommitHash=$(BUILD_COMMIT) \
# -X $(MODULE_NAME)/internal/build.Timestamp=$(BUILD_TIMESTAMP)" \
# -v \
# -o $(EXECUTABLE_NAME) \
# cmd/$(EXECUTABLE_NAME)/main.go
# .PHONY: image
# image:
# docker build \
# --build-arg VERSION=$(BUILD_VERSION) \
# --build-arg REVISION=$(BUILD_COMMIT) \
# --build-arg CREATED=$(BUILD_TIMESTAMP) \
# --tag ${PROJECT_NAME}:latest \
# .
.PHONY: clean
clean: clean-build clean-mod clean-test clean-cov
.PHONY: clean-build
clean-build:
go clean \
-cache
.PHONY: clean-mod
clean-mod:
go clean \
-modcache
.PHONY: clean-test
clean-test:
go clean \
-testcache
.PHONY: clean-cov
clean-cov:
find . \
-type f \
-name $(COVERAGE_FILE) \
-exec rm -rf {} \;