Skip to content

Commit 71d1a43

Browse files
committed
wip(tests): run doctests for vector sets on redis 8 only
1 parent e81a330 commit 71d1a43

File tree

4 files changed

+64
-6
lines changed

4 files changed

+64
-6
lines changed

.github/workflows/doctests.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ jobs:
1616

1717
services:
1818
redis-stack:
19-
image: redis/redis-stack-server:latest
20-
options: >-
21-
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
19+
image: redislabs/client-libs-test:8.0.1-pre
20+
env:
21+
TLS_ENABLED: no
22+
REDIS_CLUSTER: no
23+
PORT: 6379
2224
ports:
2325
- 6379:6379
2426

@@ -38,4 +40,4 @@ jobs:
3840

3941
- name: Test doc examples
4042
working-directory: ./doctests
41-
run: go test -v
43+
run: make test

Makefile

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,19 @@ docker.stop:
88

99
test:
1010
$(MAKE) docker.start
11-
$(MAKE) test.ci
11+
@if [ -z "$(REDIS_VERSION)" ]; then \
12+
echo "REDIS_VERSION not set, running all tests"; \
13+
$(MAKE) test.ci; \
14+
else \
15+
MAJOR_VERSION=$$(echo "$(REDIS_VERSION)" | cut -d. -f1); \
16+
if [ "$$MAJOR_VERSION" -ge 8 ]; then \
17+
echo "REDIS_VERSION $(REDIS_VERSION) >= 8, running all tests"; \
18+
$(MAKE) test.ci; \
19+
else \
20+
echo "REDIS_VERSION $(REDIS_VERSION) < 8, skipping vector_sets tests"; \
21+
$(MAKE) test.ci.skip-vectorsets; \
22+
fi; \
23+
fi
1224
$(MAKE) docker.stop
1325

1426
test.ci:
@@ -22,10 +34,22 @@ test.ci:
2234
cd internal/customvet && go build .
2335
go vet -vettool ./internal/customvet/customvet
2436

37+
test.ci.skip-vectorsets:
38+
set -e; for dir in $(GO_MOD_DIRS); do \
39+
echo "go test in $${dir} (skipping vector sets)"; \
40+
(cd "$${dir}" && \
41+
go mod tidy -compat=1.18 && \
42+
go vet && \
43+
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race \
44+
-run '^(?!.*(?:VectorSet|vectorset|ExampleClient_vectorset)).*$$'); \
45+
done
46+
cd internal/customvet && go build .
47+
go vet -vettool ./internal/customvet/customvet
48+
2549
bench:
2650
go test ./... -test.run=NONE -test.bench=. -test.benchmem
2751

28-
.PHONY: all test bench fmt
52+
.PHONY: all test test.ci test.ci.skip-vectorsets bench fmt
2953

3054
build:
3155
go build .

doctests/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
test:
2+
@if [ -z "$(REDIS_VERSION)" ]; then \
3+
echo "REDIS_VERSION not set, running all tests"; \
4+
go test -v ./...; \
5+
else \
6+
MAJOR_VERSION=$$(echo "$(REDIS_VERSION)" | cut -d. -f1); \
7+
if [ "$$MAJOR_VERSION" -ge 8 ]; then \
8+
echo "REDIS_VERSION $(REDIS_VERSION) >= 8, running all tests"; \
9+
go test -v ./...; \
10+
else \
11+
echo "REDIS_VERSION $(REDIS_VERSION) < 8, skipping vector_sets tests"; \
12+
go test -v ./... -run '^(?!.*(?:vectorset|ExampleClient_vectorset)).*$$'; \
13+
fi; \
14+
fi
15+
16+
.PHONY: test

doctests/main_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package example_commands_test
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"strconv"
7+
"strings"
8+
)
9+
10+
var RedisVersion float64
11+
12+
func init() {
13+
// read REDIS_VERSION from env
14+
RedisVersion, _ = strconv.ParseFloat(strings.Trim(os.Getenv("REDIS_VERSION"), "\""), 64)
15+
fmt.Printf("REDIS_VERSION: %.1f\n", RedisVersion)
16+
}

0 commit comments

Comments
 (0)