Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Makefile changes #120

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ GOMOD=$(GOCMD) mod
GOFMT=$(GOCMD) fmt
GODOC=godoc

.PHONY: all test coverage
.PHONY: all test coverage get checkfmt fmt godoc \
examples godoc_examples start-redis stop-redis monitor

all: test coverage examples

get:
Expand All @@ -19,7 +21,18 @@ get:
TLS_CERT ?= redis.crt
TLS_KEY ?= redis.key
TLS_CACERT ?= ca.crt
REDISEARCH_TEST_HOST ?= 127.0.0.1:6379

REDIS_SERVER ?= localhost:6379
export REDISEARCH_TEST_HOST=$(REDIS_SERVER)

REDIS_HOST:=$(word 1,$(subst :, ,$(REDIS_SERVER)))
REDIS_PORT:=$(word 2,$(subst :, ,$(REDIS_SERVER)))
ifeq ($(word 1,$(REDIS_HOST)),)
REDIS_HOST:=localhost
endif
ifeq ($(word 1,$(REDIS_PORT)),)
REDIS_PORT:=6379
endif

checkfmt:
@echo 'Checking gofmt';\
Expand All @@ -41,16 +54,21 @@ examples: get
./redisearch_tls_client --tls-cert-file $(TLS_CERT) \
--tls-key-file $(TLS_KEY) \
--tls-ca-cert-file $(TLS_CACERT) \
--host $(REDISEARCH_TEST_HOST)
--host $(REDIS_SERVER)

fmt:
$(GOFMT) ./...

godoc_examples: get fmt
$(GOTEST) -race -covermode=atomic ./redisearch

TEST ?= Test
ifeq ($(VERBOSE),1)
TEST_FLAGS += -v
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add -count=1 to TEST_FLAGS to ensure multiple calls to test do indeed trigger the tests.

endif

test: get fmt
$(GOTEST) -run "Test" ./redisearch
$(GOTEST) $(TEST_FLAGS) -run $(TEST) ./redisearch

coverage: get
$(GOTEST) -race -coverprofile=coverage.txt -covermode=atomic ./redisearch
Expand All @@ -60,3 +78,11 @@ godoc:
echo "Open browser tab on localhost:6060"
$(GODOC)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if possible can we take this chance to also add the microbenchamrks rule @rafie ?
sample one:
https://github.com/HdrHistogram/hdrhistogram-go/blob/master/Makefile#L40

start-redis:
@docker run --name redisearch-go-tests -d --rm -p 6379:6379 redislabs/redisearch:edge

stop-redis:
@docker stop redisearch-go-tests

monitor:
@redis-cli -h $(REDIS_HOST) -p $(REDIS_PORT) monitor
2 changes: 1 addition & 1 deletion redisearch/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Game struct {
Categories []string `json:"categories"`
}

func init() {
func _init() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

U1000: func _init is unused
(at-me in a reply with help or ignore)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deadcode: _init is unused
(at-me in a reply with help or ignore)

/* load test data */
value, exists := os.LookupEnv("REDISEARCH_RDB_LOADED")
requiresDatagen := true
Expand Down