Skip to content

DOC-5078 vector set examples #3394

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

Merged
merged 4 commits into from
Jun 6, 2025
Merged
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
10 changes: 6 additions & 4 deletions .github/workflows/doctests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ jobs:

services:
redis-stack:
image: redis/redis-stack-server:latest
options: >-
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
image: redislabs/client-libs-test:8.0.1-pre
env:
TLS_ENABLED: no
REDIS_CLUSTER: no
PORT: 6379
ports:
- 6379:6379

Expand All @@ -38,4 +40,4 @@ jobs:

- name: Test doc examples
working-directory: ./doctests
run: go test -v
run: make test
32 changes: 28 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ docker.stop:

test:
$(MAKE) docker.start
$(MAKE) test.ci
@if [ -z "$(REDIS_VERSION)" ]; then \
echo "REDIS_VERSION not set, running all tests"; \
$(MAKE) test.ci; \
else \
MAJOR_VERSION=$$(echo "$(REDIS_VERSION)" | cut -d. -f1); \
if [ "$$MAJOR_VERSION" -ge 8 ]; then \
echo "REDIS_VERSION $(REDIS_VERSION) >= 8, running all tests"; \
$(MAKE) test.ci; \
else \
echo "REDIS_VERSION $(REDIS_VERSION) < 8, skipping vector_sets tests"; \
$(MAKE) test.ci.skip-vectorsets; \
fi; \
fi
$(MAKE) docker.stop

test.ci:
Expand All @@ -17,15 +29,27 @@ test.ci:
(cd "$${dir}" && \
go mod tidy -compat=1.18 && \
go vet && \
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race); \
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race -skip Example); \
done
cd internal/customvet && go build .
go vet -vettool ./internal/customvet/customvet

test.ci.skip-vectorsets:
set -e; for dir in $(GO_MOD_DIRS); do \
echo "go test in $${dir} (skipping vector sets)"; \
(cd "$${dir}" && \
go mod tidy -compat=1.18 && \
go vet && \
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race \
-run '^(?!.*(?:VectorSet|vectorset|ExampleClient_vectorset)).*$$' -skip Example); \
done
cd internal/customvet && go build .
go vet -vettool ./internal/customvet/customvet

bench:
go test ./... -test.run=NONE -test.bench=. -test.benchmem
go test ./... -test.run=NONE -test.bench=. -test.benchmem -skip Example

.PHONY: all test bench fmt
.PHONY: all test test.ci test.ci.skip-vectorsets bench fmt

build:
go build .
Expand Down
16 changes: 16 additions & 0 deletions doctests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
test:
@if [ -z "$(REDIS_VERSION)" ]; then \
echo "REDIS_VERSION not set, running all tests"; \
go test -v ./...; \
else \
MAJOR_VERSION=$$(echo "$(REDIS_VERSION)" | cut -d. -f1); \
if [ "$$MAJOR_VERSION" -ge 8 ]; then \
echo "REDIS_VERSION $(REDIS_VERSION) >= 8, running all tests"; \
go test -v ./...; \
else \
echo "REDIS_VERSION $(REDIS_VERSION) < 8, skipping vector_sets tests"; \
go test -v ./... -run '^(?!.*(?:vectorset|ExampleClient_vectorset)).*$$'; \
fi; \
fi

.PHONY: test
16 changes: 16 additions & 0 deletions doctests/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package example_commands_test

import (
"fmt"
"os"
"strconv"
"strings"
)

var RedisVersion float64

func init() {
// read REDIS_VERSION from env
RedisVersion, _ = strconv.ParseFloat(strings.Trim(os.Getenv("REDIS_VERSION"), "\""), 64)
fmt.Printf("REDIS_VERSION: %.1f\n", RedisVersion)
}
Loading
Loading