-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
46 lines (35 loc) · 1.18 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
PACKAGE := github.com/RedisLabs/rediscloud-go-api
.DEFAULT_GOAL := all
.PHONY := clean all fmt coverage
go_files := $(shell find . -type f -name '*.go' -print)
clean:
# Removing all generated files...
@rm -rf bin/ || true
bin/.vendor: go.mod go.sum
# Downloading modules...
@go mod download
@mkdir -p bin/
@touch bin/.vendor
bin/.generate: $(go_files) bin/.vendor
@go generate ./...
@touch bin/.generate
fmt: bin/.generate $(go_files)
# Formatting files...
@go run golang.org/x/tools/cmd/goimports -w $(go_files)
bin/.vet: bin/.generate $(go_files)
go vet ./...
@touch bin/.vet
bin/.fmtcheck: bin/.generate $(go_files)
# Checking format of Go files...
@GOIMPORTS=$$(go run golang.org/x/tools/cmd/goimports -l $(go_files)) && \
if [ "$$GOIMPORTS" != "" ]; then \
go run golang.org/x/tools/cmd/goimports -d $(go_files); \
exit 1; \
fi
@touch bin/.fmtcheck
bin/.coverage.out: bin/.generate $(go_files)
@go test -cover -v -count=1 ./... -coverpkg=$(shell go list ${PACKAGE}/... | xargs | sed -e 's/ /,/g') -coverprofile bin/.coverage.tmp
@mv bin/.coverage.tmp bin/.coverage.out
coverage: bin/.coverage.out
@go tool cover -html=bin/.coverage.out
all: bin/.coverage.out bin/.fmtcheck