-
Notifications
You must be signed in to change notification settings - Fork 81
/
Makefile
29 lines (25 loc) · 820 Bytes
/
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
# must ensure your go version >= 1.16
.PHONY: install
install:
go install github.com/golang/mock/[email protected]
go install golang.org/x/tools/cmd/goimports@latest
.PHONY: tidy
tidy:
go mod tidy
@$(foreach dir,$(shell go list -f {{.Dir}} ./...),goimports -w $(dir);)
@$(foreach dir,$(shell go list -f {{.Dir}} ./...),gofmt -s -w $(dir);)
.PHONY: test
test:
go test -race -coverprofile=coverage.out ./...
# include integration tests
.PHONY: g-test
g-test:
go test -tags=integration -race -coverprofile=coverage.out ./...
# usage
# you must run `make install` to install necessary tools
# make mock
.PHONY: mock
mock:
for file in `find . -type d \( -path ./.git -o -path ./.github \) -prune -o -name '*.go' -print | xargs grep --files-with-matches -e '//go:generate mockgen'`; do \
go generate $$file; \
done