Skip to content

Commit 32eb6f1

Browse files
authored
Merge branch 'master' into enabling-dialect-2-on-default
2 parents 5f619cf + ebe11d0 commit 32eb6f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+659
-553
lines changed

.github/actions/run-tests/action.yml

+6-15
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ runs:
2121
CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ inputs.redis-version }}"
2222
run: |
2323
set -e
24-
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
25-
if (( redis_major_version < 8 )); then
26-
echo "Using redis-stack for module tests"
27-
else
28-
echo "Using redis CE for module tests"
29-
fi
24+
redis_version_np=$(echo "$REDIS_VERSION" | grep -oP '^\d+.\d+')
3025
3126
# Mapping of redis version to redis testing containers
3227
declare -A redis_version_mapping=(
@@ -36,27 +31,23 @@ runs:
3631
)
3732
3833
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
39-
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
34+
echo "REDIS_VERSION=${redis_version_np}" >> $GITHUB_ENV
4035
echo "REDIS_IMAGE=redis:${{ inputs.redis-version }}" >> $GITHUB_ENV
4136
echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV
4237
else
4338
echo "Version not found in the mapping."
4439
exit 1
4540
fi
46-
sleep 10 # time to settle
41+
sleep 10 # wait for redis to start
4742
shell: bash
4843
- name: Set up Docker Compose environment with redis ${{ inputs.redis-version }}
49-
run: docker compose --profile all up -d
44+
run: |
45+
make docker.start
5046
shell: bash
5147
- name: Run tests
5248
env:
5349
RCE_DOCKER: "true"
5450
RE_CLUSTER: "false"
5551
run: |
56-
go test \
57-
--ginkgo.skip-file="ring_test.go" \
58-
--ginkgo.skip-file="sentinel_test.go" \
59-
--ginkgo.skip-file="pubsub_test.go" \
60-
--ginkgo.skip-file="gears_commands_test.go" \
61-
--ginkgo.label-filter="!NonRedisEnterprise"
52+
make test.ci
6253
shell: bash

.github/workflows/build.yml

+48-14
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ permissions:
1010
contents: read
1111

1212
jobs:
13-
build:
14-
name: build
13+
14+
benchmark:
15+
name: benchmark
1516
runs-on: ubuntu-latest
1617
strategy:
1718
fail-fast: false
1819
matrix:
19-
go-version: [1.21.x, 1.22.x, 1.23.x]
20+
redis-version:
21+
- "8.0-M03" # 8.0 milestone 4
22+
- "7.4.2" # should use redis stack 7.4
23+
go-version:
24+
- "1.23.x"
25+
- "1.24.x"
2026

2127
steps:
2228
- name: Set up ${{ matrix.go-version }}
@@ -27,15 +33,38 @@ jobs:
2733
- name: Checkout code
2834
uses: actions/checkout@v4
2935

30-
- name: Test
31-
run: make test
36+
- name: Setup Test environment
37+
env:
38+
REDIS_VERSION: ${{ matrix.redis-version }}
39+
CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ matrix.redis-version }}"
40+
run: |
41+
set -e
42+
redis_version_np=$(echo "$REDIS_VERSION" | grep -oP '^\d+.\d+')
43+
44+
# Mapping of redis version to redis testing containers
45+
declare -A redis_version_mapping=(
46+
["8.0-M03"]="8.0-M04-pre"
47+
["7.4.2"]="rs-7.4.0-v2"
48+
)
49+
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
50+
echo "REDIS_VERSION=${redis_version_np}" >> $GITHUB_ENV
51+
echo "REDIS_IMAGE=redis:${{ matrix.redis-version }}" >> $GITHUB_ENV
52+
echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV
53+
else
54+
echo "Version not found in the mapping."
55+
exit 1
56+
fi
57+
shell: bash
58+
- name: Set up Docker Compose environment with redis ${{ matrix.redis-version }}
59+
run: make docker.start
60+
shell: bash
61+
- name: Benchmark Tests
62+
env:
63+
RCE_DOCKER: "true"
64+
RE_CLUSTER: "false"
65+
run: make bench
66+
shell: bash
3267

33-
- name: Upload to Codecov
34-
uses: codecov/codecov-action@v5
35-
with:
36-
files: coverage.txt
37-
token: ${{ secrets.CODECOV_TOKEN }}
38-
3968
test-redis-ce:
4069
name: test-redis-ce
4170
runs-on: ubuntu-latest
@@ -47,11 +76,10 @@ jobs:
4776
- "7.4.2" # should use redis stack 7.4
4877
- "7.2.7" # should redis stack 7.2
4978
go-version:
50-
- "1.22.x"
5179
- "1.23.x"
80+
- "1.24.x"
5281

5382
steps:
54-
5583
- name: Checkout code
5684
uses: actions/checkout@v4
5785

@@ -60,4 +88,10 @@ jobs:
6088
with:
6189
go-version: ${{matrix.go-version}}
6290
redis-version: ${{ matrix.redis-version }}
63-
91+
92+
- name: Upload to Codecov
93+
uses: codecov/codecov-action@v5
94+
with:
95+
files: coverage.txt
96+
token: ${{ secrets.CODECOV_TOKEN }}
97+

.github/workflows/codeql-analysis.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
21+
jobs:
22+
analyze:
23+
name: Analyze
24+
runs-on: ubuntu-latest
25+
permissions:
26+
actions: read
27+
contents: read
28+
security-events: write
29+
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
language: [ 'go' ]
34+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
35+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
41+
# Initializes the CodeQL tools for scanning.
42+
- name: Initialize CodeQL
43+
uses: github/codeql-action/init@v3
44+
with:
45+
languages: ${{ matrix.language }}
46+
# If you wish to specify custom queries, you can do so here or in a config file.
47+
# By default, queries listed here will override any specified in a config file.
48+
# Prefix the list here with "+" to use these queries and those in the config file.
49+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
50+
51+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
52+
# If this step fails, then you should remove it and run the build manually (see below)
53+
- name: Autobuild
54+
uses: github/codeql-action/autobuild@v3
55+
56+
# ℹ️ Command-line programs to run using the OS shell.
57+
# 📚 https://git.io/JvXDl
58+
59+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
60+
# and modify them (or add more) to build your code if your project
61+
# uses a compiled language
62+
63+
#- run: |
64+
# make bootstrap
65+
# make release
66+
67+
- name: Perform CodeQL Analysis
68+
uses: github/codeql-action/analyze@v3

.github/workflows/doctests.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
go-version: [ "1.21", "1.22", "1.23" ]
28+
go-version: ["1.24"]
2929

3030
steps:
3131
- name: Set up ${{ matrix.go-version }}
@@ -38,4 +38,4 @@ jobs:
3838

3939
- name: Test doc examples
4040
working-directory: ./doctests
41-
run: go test
41+
run: go test -v

.github/workflows/test-redis-enterprise.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
go-version: [1.23.x]
18+
go-version: [1.24.x]
1919
re-build: ["7.4.2-54"]
2020

2121
steps:
@@ -47,7 +47,7 @@ jobs:
4747
- name: Test
4848
env:
4949
RE_CLUSTER: true
50-
REDIS_MAJOR_VERSION: 7
50+
REDIS_VERSION: "7.4"
5151
run: |
5252
go test \
5353
--ginkgo.skip-file="ring_test.go" \

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ testdata/*
55
*.tar.gz
66
*.dic
77
redis8tests.sh
8-
.vscode
8+
coverage.txt
9+
**/coverage.txt
10+
.vscode

CONTRIBUTING.md

+18-5
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,33 @@ Here's how to get started with your code contribution:
3232

3333
1. Create your own fork of go-redis
3434
2. Do the changes in your fork
35-
3. If you need a development environment, run `make test`. Note: this clones and builds the latest release of [redis](https://redis.io). You also need a redis-stack-server docker, in order to run the capabilities tests. This can be started by running:
36-
```docker run -p 6379:6379 -it redis/redis-stack-server:edge```
37-
4. While developing, make sure the tests pass by running `make tests`
35+
3. If you need a development environment, run `make docker.start`.
36+
37+
> Note: this clones and builds the docker containers specified in `docker-compose.yml`, to understand more about
38+
> the infrastructure that will be started you can check the `docker-compose.yml`. You also have the possiblity
39+
> to specify the redis image that will be pulled with the env variable `CLIENT_LIBS_TEST_IMAGE`.
40+
> By default the docker image that will be pulled and started is `redislabs/client-libs-test:rs-7.4.0-v2`.
41+
> If you want to test with newer Redis version, using a newer version of `redislabs/client-libs-test` should work out of the box.
42+
43+
4. While developing, make sure the tests pass by running `make test` (if you have the docker containers running, `make test.ci` may be sufficient).
44+
> Note: `make test` will try to start all containers, run the tests with `make test.ci` and then stop all containers.
3845
5. If you like the change and think the project could use it, send a
3946
pull request
4047

4148
To see what else is part of the automation, run `invoke -l`
4249

50+
4351
## Testing
4452

45-
Call `make test` to run all tests, including linters.
53+
### Setting up Docker
54+
To run the tests, you need to have Docker installed and running. If you are using a host OS that does not support
55+
docker host networks out of the box (e.g. Windows, OSX), you need to set up a docker desktop and enable docker host networks.
56+
57+
### Running tests
58+
Call `make test` to run all tests.
4659

4760
Continuous Integration uses these same wrappers to run all of these
48-
tests against multiple versions of python. Feel free to test your
61+
tests against multiple versions of redis. Feel free to test your
4962
changes against all the go versions supported, as declared by the
5063
[build.yml](./.github/workflows/build.yml) file.
5164

Makefile

+16-26
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,35 @@
11
GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
2-
export REDIS_MAJOR_VERSION := 7
32

4-
test: testdeps
5-
docker start go-redis-redis-stack || docker run -d --name go-redis-redis-stack -p 6379:6379 -e REDIS_ARGS="--enable-debug-command yes --enable-module-command yes" redis/redis-stack-server:latest
6-
$(eval GO_VERSION := $(shell go version | cut -d " " -f 3 | cut -d. -f2))
3+
docker.start:
4+
docker compose --profile all up -d --quiet-pull
5+
6+
docker.stop:
7+
docker compose --profile all down
8+
9+
test:
10+
$(MAKE) docker.start
11+
$(MAKE) test.ci
12+
$(MAKE) docker.stop
13+
14+
test.ci:
715
set -e; for dir in $(GO_MOD_DIRS); do \
8-
if echo "$${dir}" | grep -q "./example" && [ "$(GO_VERSION)" = "19" ]; then \
9-
echo "Skipping go test in $${dir} due to Go version 1.19 and dir contains ./example"; \
10-
continue; \
11-
fi; \
1216
echo "go test in $${dir}"; \
1317
(cd "$${dir}" && \
1418
go mod tidy -compat=1.18 && \
15-
go test && \
16-
go test ./... -short -race && \
17-
go test ./... -run=NONE -bench=. -benchmem && \
18-
env GOOS=linux GOARCH=386 go test && \
19-
go test -coverprofile=coverage.txt -covermode=atomic ./... && \
20-
go vet); \
19+
go vet && \
20+
go test -coverprofile=coverage.txt -covermode=atomic ./... -race); \
2121
done
2222
cd internal/customvet && go build .
2323
go vet -vettool ./internal/customvet/customvet
24-
docker stop go-redis-redis-stack
2524

26-
testdeps: testdata/redis/src/redis-server
27-
28-
bench: testdeps
25+
bench:
2926
go test ./... -test.run=NONE -test.bench=. -test.benchmem
3027

31-
.PHONY: all test testdeps bench fmt
28+
.PHONY: all test bench fmt
3229

3330
build:
3431
go build .
3532

36-
testdata/redis:
37-
mkdir -p $@
38-
wget -qO- https://download.redis.io/releases/redis-7.4.2.tar.gz | tar xvz --strip-components=1 -C $@
39-
40-
testdata/redis/src/redis-server: testdata/redis
41-
cd $< && make all
42-
4333
fmt:
4434
gofumpt -w ./
4535
goimports -w -local github.com/redis/go-redis ./

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@
1414
> See [OpenTelemetry](https://github.com/redis/go-redis/tree/master/example/otel) example which
1515
> demonstrates how you can use Uptrace to monitor go-redis.
1616
17+
## Supported versions
18+
19+
In `go-redis` we are aiming to support the last three releases of Redis. Currently, this means we do support:
20+
- [Redis 7.2](https://raw.githubusercontent.com/redis/redis/7.2/00-RELEASENOTES) - using Redis Stack 7.2 for modules support
21+
- [Redis 7.4](https://raw.githubusercontent.com/redis/redis/7.4/00-RELEASENOTES) - using Redis Stack 7.4 for modules support
22+
- [Redis 8.0](https://raw.githubusercontent.com/redis/redis/8.0/00-RELEASENOTES) - using Redis CE 8.0 where modules are included
23+
24+
Although the `go.mod` states it requires at minimum `go 1.18`, our CI is configured to run the tests against all three
25+
versions of Redis and latest two versions of Go ([1.23](https://go.dev/doc/devel/release#go1.23.0),
26+
[1.24](https://go.dev/doc/devel/release#go1.24.0)). We observe that some modules related test may not pass with
27+
Redis Stack 7.2 and some commands are changed with Redis CE 8.0.
28+
Please do refer to the documentation and the tests if you experience any issues. We do plan to update the go version
29+
in the `go.mod` to `go 1.24` in one of the next releases.
30+
1731
## How do I Redis?
1832

1933
[Learn for free at Redis University](https://university.redis.com/)

0 commit comments

Comments
 (0)