You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

88 rivejä
2.6 KiB

  1. GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
  2. REDIS_VERSION ?= 8.2
  3. RE_CLUSTER ?= false
  4. RCE_DOCKER ?= true
  5. CLIENT_LIBS_TEST_IMAGE ?= redislabs/client-libs-test:8.2.1-pre
  6. docker.start:
  7. export RE_CLUSTER=$(RE_CLUSTER) && \
  8. export RCE_DOCKER=$(RCE_DOCKER) && \
  9. export REDIS_VERSION=$(REDIS_VERSION) && \
  10. export CLIENT_LIBS_TEST_IMAGE=$(CLIENT_LIBS_TEST_IMAGE) && \
  11. docker compose --profile all up -d --quiet-pull
  12. docker.stop:
  13. docker compose --profile all down
  14. test:
  15. $(MAKE) docker.start
  16. @if [ -z "$(REDIS_VERSION)" ]; then \
  17. echo "REDIS_VERSION not set, running all tests"; \
  18. $(MAKE) test.ci; \
  19. else \
  20. MAJOR_VERSION=$$(echo "$(REDIS_VERSION)" | cut -d. -f1); \
  21. if [ "$$MAJOR_VERSION" -ge 8 ]; then \
  22. echo "REDIS_VERSION $(REDIS_VERSION) >= 8, running all tests"; \
  23. $(MAKE) test.ci; \
  24. else \
  25. echo "REDIS_VERSION $(REDIS_VERSION) < 8, skipping vector_sets tests"; \
  26. $(MAKE) test.ci.skip-vectorsets; \
  27. fi; \
  28. fi
  29. $(MAKE) docker.stop
  30. test.ci:
  31. set -e; for dir in $(GO_MOD_DIRS); do \
  32. echo "go test in $${dir}"; \
  33. (cd "$${dir}" && \
  34. export RE_CLUSTER=$(RE_CLUSTER) && \
  35. export RCE_DOCKER=$(RCE_DOCKER) && \
  36. export REDIS_VERSION=$(REDIS_VERSION) && \
  37. go mod tidy -compat=1.18 && \
  38. go vet && \
  39. go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race -skip Example); \
  40. done
  41. cd internal/customvet && go build .
  42. go vet -vettool ./internal/customvet/customvet
  43. test.ci.skip-vectorsets:
  44. set -e; for dir in $(GO_MOD_DIRS); do \
  45. echo "go test in $${dir} (skipping vector sets)"; \
  46. (cd "$${dir}" && \
  47. export RE_CLUSTER=$(RE_CLUSTER) && \
  48. export RCE_DOCKER=$(RCE_DOCKER) && \
  49. export REDIS_VERSION=$(REDIS_VERSION) && \
  50. go mod tidy -compat=1.18 && \
  51. go vet && \
  52. go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race \
  53. -run '^(?!.*(?:VectorSet|vectorset|ExampleClient_vectorset)).*$$' -skip Example); \
  54. done
  55. cd internal/customvet && go build .
  56. go vet -vettool ./internal/customvet/customvet
  57. bench:
  58. export RE_CLUSTER=$(RE_CLUSTER) && \
  59. export RCE_DOCKER=$(RCE_DOCKER) && \
  60. export REDIS_VERSION=$(REDIS_VERSION) && \
  61. go test ./... -test.run=NONE -test.bench=. -test.benchmem -skip Example
  62. .PHONY: all test test.ci test.ci.skip-vectorsets bench fmt
  63. build:
  64. export RE_CLUSTER=$(RE_CLUSTER) && \
  65. export RCE_DOCKER=$(RCE_DOCKER) && \
  66. export REDIS_VERSION=$(REDIS_VERSION) && \
  67. go build .
  68. fmt:
  69. gofumpt -w ./
  70. goimports -w -local github.com/redis/go-redis ./
  71. go_mod_tidy:
  72. set -e; for dir in $(GO_MOD_DIRS); do \
  73. echo "go mod tidy in $${dir}"; \
  74. (cd "$${dir}" && \
  75. go get -u ./... && \
  76. go mod tidy -compat=1.18); \
  77. done