-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
84 lines (69 loc) · 1.56 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
ifndef PKGS
PKGS := $(shell go list ./... 2>&1 | grep -v test | grep -v mock)
endif
$(info PKGS=$(PKGS))
HAS_ERRCHECK := $(shell command -v errcheck 2> /dev/null)
all: test
vendor:
go mod download
go mod tidy -compat=1.20
go mod vendor
build:
@echo ">>> go build"
go build $(PKGS)
install:
@echo ">>> go install"
go install $(PKGS)
vet:
@echo ">>> go vet"
go vet $(PKGS)
errcheck:
ifndef HAS_ERRCHECK
go install github.com/kisielk/errcheck@latest
endif
@echo ">>> errcheck"
errcheck \
github.com/portworx/kvdb \
github.com/portworx/kvdb/common \
github.com/portworx/kvdb/consul \
github.com/portworx/kvdb/mem \
github.com/portworx/kvdb/wrappers \
github.com/portworx/kvdb/zookeeper
pretest: errcheck vet
gotest:
@echo ">>> gotest"
ifeq ($(PKGS),"")
$(error Error: No packages found to test)
endif
for pkg in $(PKGS); \
do \
echo ">>> Testing $${pkg}"; \
go test --timeout 1h -v -tags unittest -coverprofile=profile.out -covermode=atomic $(BUILD_OPTIONS) $${pkg} || exit 1; \
if [ -f profile.out ]; then \
cat profile.out >> coverage.txt; \
rm profile.out; \
fi; \
done
test: pretest gotest
docker-build-kvdb-dev:
docker build -t portworx/kvdb:test_container -f $(GOPATH)/src/github.com/portworx/kvdb/Dockerfile.kvdb .
docker-test:
docker run --rm \
-v $(GOPATH)/src/github.com/portworx/kvdb:/go/src/github.com/portworx/kvdb \
portworx/kvdb:test_container \
make gotest
mockgen:
go generate -x ./...
clean:
go clean -i ./...
.PHONY: \
all \
vendor \
build \
install \
vet \
errcheck \
pretest \
gotest \
test \
clean