-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
79 lines (54 loc) · 1.98 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
# Define directories
ROOT_DIR ?= ${CURDIR}
TOOLS_DIR ?= ${ROOT_DIR}/tools
INTEGRATIONS_DIR ?= ${ROOT_DIR}/integrations
# Set a local GOBIN, since the default value can't be trusted
# (See https://github.com/golang/go/issues/23439)
export GOBIN ?= ${TOOLS_DIR}/bin
# Build flags
GO_CLEAN_FLAGS ?= -i -r -x ${GO_BUILD_FLAGS}
# Tool flags
GOFUMPT_FLAGS ?=
GOLINT_MIN_CONFIDENCE ?= 0.3
# Set the mode for code-coverage
GO_TEST_COVERAGE_MODE ?= count
GO_TEST_COVERAGE_FILE_NAME ?= coverage.out
all: install-deps build
clean:
go clean ${GO_CLEAN_FLAGS} ./...
build: install-deps
go build ${GO_BUILD_FLAGS}
install-deps:
go mod download
${TOOLS_DIR} tools install-deps-dev:
cd ${TOOLS_DIR} && go install \
golang.org/x/lint/golint \
honnef.co/go/tools/cmd/staticcheck \
mvdan.cc/gofumpt
update-deps:
go get ./...
test:
go test -v ./...
test-with-coverage:
go test -cover -covermode ${GO_TEST_COVERAGE_MODE} ./...
test-with-coverage-formatted:
go test -cover -covermode ${GO_TEST_COVERAGE_MODE} ./... | column -t | sort -r
test-with-coverage-profile:
go test -covermode ${GO_TEST_COVERAGE_MODE} -coverprofile ${GO_TEST_COVERAGE_FILE_NAME} ./...
${INTEGRATIONS_DIR} test-integrations:
cd ${INTEGRATIONS_DIR} && go test -v ./...
test-all: test test-integrations
format-lint:
$(info ${GOBIN}/gofumpt -l ${GOFUMPT_FLAGS} .)
@errors=$$(${GOBIN}/gofumpt -l ${GOFUMPT_FLAGS} .); if [ "$${errors}" != "" ]; then echo "Format lint failed on:\n$${errors}\n"; exit 1; fi
style-lint: install-deps-dev
${GOBIN}/golint -min_confidence=${GOLINT_MIN_CONFIDENCE} -set_exit_status ./...
${GOBIN}/staticcheck ./...
lint: install-deps-dev format-lint style-lint
vet:
go vet ./...
format-fix:
${GOBIN}/gofumpt -w ${GOFUMPT_FLAGS} .
fix: install-deps-dev format-fix
go fix ./...
.PHONY: all clean build install-deps tools install-deps-dev update-deps test test-with-coverage test-with-coverage-formatted test-with-coverage-profile test-integrations test-all format-lint style-lint lint vet format-fix fix