-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
75 lines (60 loc) · 1.74 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
# Go parameters
GOCMD=GO111MODULE=on go
GOBUILD=$(GOCMD) build
GOBUILDRACE=$(GOCMD) build -race
GOINSTALL=$(GOCMD) install
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=$(GOCMD) fmt
BIN_NAME=redisgraph-benchmark-go
DISTDIR = ./dist
# Build-time GIT variables
ifeq ($(GIT_SHA),)
GIT_SHA:=$(shell git rev-parse HEAD)
endif
ifeq ($(GIT_DIRTY),)
GIT_DIRTY:=$(shell git diff --no-ext-diff 2> /dev/null | wc -l)
endif
LDFLAGS = "-X 'main.GitSHA1=$(GIT_SHA)' -X 'main.GitDirty=$(GIT_DIRTY)'"
.PHONY: all test coverage build checkfmt fmt
all: test coverage build checkfmt fmt
build:
$(GOBUILD) \
-ldflags=$(LDFLAGS) .
build-race:
$(GOBUILDRACE) \
-ldflags=$(LDFLAGS) .
checkfmt:
@echo 'Checking gofmt';\
bash -c "diff -u <(echo -n) <(go fmt .)";\
EXIT_CODE=$$?;\
if [ "$$EXIT_CODE" -ne 0 ]; then \
echo '$@: Go files must be formatted with gofmt'; \
fi && \
exit $$EXIT_CODE
lint:
$(GOGET) github.com/golangci/golangci-lint/cmd/golangci-lint
golangci-lint run
fmt:
$(GOFMT) .
get:
$(GOGET) -t -v ./...
test: get
$(GOFMT) ./...
$(GOTEST) -race -covermode=atomic ./...
coverage: get test
$(GOTEST) -race -coverprofile=coverage.txt -covermode=atomic .
flow-test: build-race
./$(BIN_NAME) -n 100000 -query "CREATE(n)" -query-ratio 0.33 -query "MATCH (n) RETURN n LIMIT 1" -query-ratio 0.67
release:
$(GOGET) github.com/mitchellh/gox
$(GOGET) github.com/tcnksm/ghr
GO111MODULE=on gox -osarch "linux/amd64 darwin/amd64" -output "dist/redisgraph-benchmark-go_{{.OS}}_{{.Arch}}" .
publish: release
@for f in $(shell ls ${DISTDIR}); \
do \
echo "copying ${DISTDIR}/$${f}"; \
aws s3 cp ${DISTDIR}/$${f} s3://benchmarks.redislabs/tools/redisgraph-benchmark-go/unstable/$${f} --acl public-read; \
done