-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
50 lines (37 loc) · 1.12 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
VERSION=0.0.21
COVERAGE_FILE=.coverage
##################################
####### Setup ########
##################################
.PHONY: setup
setup:
@go mod download
##################################
####### Tool ########
##################################
.PHONY: fmt lint clean
fmt:
@gofmt -d -w -e .
lint:
@golangci-lint run ./...
clean:
@git clean -fdx ${COVERAGE_FILE}
##################################
####### Coverage ########
##################################
.PHONY: test coverage coverage_html
TEST_FLAGS = -v -race -failfast
test:
@go test ${TEST_FLAGS} -timeout=10s ./...
coverage: test
@go tool cover -func ${COVERAGE_FILE}
@COVERAGE=$$(go tool cover -func=${COVERAGE_FILE} | grep total | grep statements |awk '{print $$3}' | sed 's/\%//g'); \
echo "Current coverage is $${COVERAGE}%, minimal is ${MINIMAL_COVERAGE}."; \
awk "BEGIN {exit ($${COVERAGE} < ${MINIMAL_COVERAGE})}"
coverage_html: test
@go tool cover -html ${COVERAGE_FILE}
##################################
####### Release ########
##################################
release:
@bumpversion patch