Skip to content

Commit adbf0af

Browse files
authored
Merge branch 'master' into v9.7
2 parents 3d041a1 + 30e7388 commit adbf0af

Some content is hidden

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

80 files changed

+8775
-2158
lines changed

Diff for: .github/actions/run-tests/action.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: 'Run go-redis tests'
2+
description: 'Runs go-redis tests against different Redis versions and configurations'
3+
inputs:
4+
go-version:
5+
description: 'Go version to use for running tests'
6+
default: '1.23'
7+
redis-version:
8+
description: 'Redis version to test against'
9+
required: true
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Set up ${{ inputs.go-version }}
14+
uses: actions/setup-go@v5
15+
with:
16+
go-version: ${{ inputs.go-version }}
17+
18+
- name: Setup Test environment
19+
env:
20+
REDIS_VERSION: ${{ inputs.redis-version }}
21+
CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ inputs.redis-version }}"
22+
run: |
23+
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
30+
31+
# Mapping of redis version to redis testing containers
32+
declare -A redis_version_mapping=(
33+
["8.0-M03"]="8.0-M04-pre"
34+
["7.4.2"]="rs-7.4.0-v2"
35+
["7.2.7"]="rs-7.2.0-v14"
36+
)
37+
38+
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
39+
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
40+
echo "REDIS_IMAGE=redis:${{ inputs.redis-version }}" >> $GITHUB_ENV
41+
echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV
42+
else
43+
echo "Version not found in the mapping."
44+
exit 1
45+
fi
46+
sleep 10 # time to settle
47+
shell: bash
48+
- name: Set up Docker Compose environment with redis ${{ inputs.redis-version }}
49+
run: docker compose --profile all up -d
50+
shell: bash
51+
- name: Run tests
52+
env:
53+
RCE_DOCKER: "true"
54+
RE_CLUSTER: "false"
55+
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"
62+
shell: bash

Diff for: .github/workflows/build.yml

+29-11
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
go-version: [1.19.x, 1.20.x, 1.21.x]
20-
21-
services:
22-
redis:
23-
image: redis/redis-stack-server:latest
24-
options: >-
25-
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
26-
ports:
27-
- 6379:6379
19+
go-version: [1.21.x, 1.22.x, 1.23.x]
2820

2921
steps:
3022
- name: Set up ${{ matrix.go-version }}
@@ -39,7 +31,33 @@ jobs:
3931
run: make test
4032

4133
- name: Upload to Codecov
42-
uses: codecov/codecov-action@v4
34+
uses: codecov/codecov-action@v5
4335
with:
4436
files: coverage.txt
45-
token: ${{ secrets.CODECOV_TOKEN }}
37+
token: ${{ secrets.CODECOV_TOKEN }}
38+
39+
test-redis-ce:
40+
name: test-redis-ce
41+
runs-on: ubuntu-latest
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
redis-version:
46+
- "8.0-M03" # 8.0 milestone 4
47+
- "7.4.2" # should use redis stack 7.4
48+
- "7.2.7" # should redis stack 7.2
49+
go-version:
50+
- "1.22.x"
51+
- "1.23.x"
52+
53+
steps:
54+
55+
- name: Checkout code
56+
uses: actions/checkout@v4
57+
58+
- name: Run tests
59+
uses: ./.github/actions/run-tests
60+
with:
61+
go-version: ${{matrix.go-version}}
62+
redis-version: ${{ matrix.redis-version }}
63+

Diff for: .github/workflows/doctests.yaml

+1-1
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.18", "1.19", "1.20", "1.21" ]
28+
go-version: [ "1.21", "1.22", "1.23" ]
2929

3030
steps:
3131
- name: Set up ${{ matrix.go-version }}

Diff for: .github/workflows/spellcheck.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: Checkout
99
uses: actions/checkout@v4
1010
- name: Check Spelling
11-
uses: rojopolis/spellcheck-github-actions@0.40.0
11+
uses: rojopolis/spellcheck-github-actions@0.47.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

Diff for: .github/workflows/test-redis-enterprise.yml

+3-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.21.x]
18+
go-version: [1.23.x]
1919
re-build: ["7.4.2-54"]
2020

2121
steps:
@@ -46,7 +46,8 @@ jobs:
4646

4747
- name: Test
4848
env:
49-
RE_CLUSTER: "1"
49+
RE_CLUSTER: true
50+
REDIS_MAJOR_VERSION: 7
5051
run: |
5152
go test \
5253
--ginkgo.skip-file="ring_test.go" \

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ testdata/*
33
.idea/
44
.DS_Store
55
*.tar.gz
6-
*.dic
6+
*.dic
7+
redis8tests.sh

Diff for: Makefile

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

34
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
46
$(eval GO_VERSION := $(shell go version | cut -d " " -f 3 | cut -d. -f2))
57
set -e; for dir in $(GO_MOD_DIRS); do \
68
if echo "$${dir}" | grep -q "./example" && [ "$(GO_VERSION)" = "19" ]; then \
@@ -19,6 +21,7 @@ test: testdeps
1921
done
2022
cd internal/customvet && go build .
2123
go vet -vettool ./internal/customvet/customvet
24+
docker stop go-redis-redis-stack
2225

2326
testdeps: testdata/redis/src/redis-server
2427

@@ -32,7 +35,7 @@ build:
3235

3336
testdata/redis:
3437
mkdir -p $@
35-
wget -qO- https://download.redis.io/releases/redis-7.4-rc2.tar.gz | tar xvz --strip-components=1 -C $@
38+
wget -qO- https://download.redis.io/releases/redis-7.4.2.tar.gz | tar xvz --strip-components=1 -C $@
3639

3740
testdata/redis/src/redis-server: testdata/redis
3841
cd $< && make all

Diff for: acl_commands.go

+54
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,20 @@ import "context"
44

55
type ACLCmdable interface {
66
ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd
7+
78
ACLLog(ctx context.Context, count int64) *ACLLogCmd
89
ACLLogReset(ctx context.Context) *StatusCmd
10+
11+
ACLSetUser(ctx context.Context, username string, rules ...string) *StatusCmd
12+
ACLDelUser(ctx context.Context, username string) *IntCmd
13+
ACLList(ctx context.Context) *StringSliceCmd
14+
15+
ACLCat(ctx context.Context) *StringSliceCmd
16+
ACLCatArgs(ctx context.Context, options *ACLCatArgs) *StringSliceCmd
17+
}
18+
19+
type ACLCatArgs struct {
20+
Category string
921
}
1022

1123
func (c cmdable) ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd {
@@ -33,3 +45,45 @@ func (c cmdable) ACLLogReset(ctx context.Context) *StatusCmd {
3345
_ = c(ctx, cmd)
3446
return cmd
3547
}
48+
49+
func (c cmdable) ACLDelUser(ctx context.Context, username string) *IntCmd {
50+
cmd := NewIntCmd(ctx, "acl", "deluser", username)
51+
_ = c(ctx, cmd)
52+
return cmd
53+
}
54+
55+
func (c cmdable) ACLSetUser(ctx context.Context, username string, rules ...string) *StatusCmd {
56+
args := make([]interface{}, 3+len(rules))
57+
args[0] = "acl"
58+
args[1] = "setuser"
59+
args[2] = username
60+
for i, rule := range rules {
61+
args[i+3] = rule
62+
}
63+
cmd := NewStatusCmd(ctx, args...)
64+
_ = c(ctx, cmd)
65+
return cmd
66+
}
67+
68+
func (c cmdable) ACLList(ctx context.Context) *StringSliceCmd {
69+
cmd := NewStringSliceCmd(ctx, "acl", "list")
70+
_ = c(ctx, cmd)
71+
return cmd
72+
}
73+
74+
func (c cmdable) ACLCat(ctx context.Context) *StringSliceCmd {
75+
cmd := NewStringSliceCmd(ctx, "acl", "cat")
76+
_ = c(ctx, cmd)
77+
return cmd
78+
}
79+
80+
func (c cmdable) ACLCatArgs(ctx context.Context, options *ACLCatArgs) *StringSliceCmd {
81+
// if there is a category passed, build new cmd, if there isn't - use the ACLCat method
82+
if options != nil && options.Category != "" {
83+
cmd := NewStringSliceCmd(ctx, "acl", "cat", options.Category)
84+
_ = c(ctx, cmd)
85+
return cmd
86+
}
87+
88+
return c.ACLCat(ctx)
89+
}

0 commit comments

Comments
 (0)