Skip to content

Commit d990136

Browse files
authored
Merge branch 'master' into patch-1
2 parents 723a748 + 0be67bf commit d990136

Some content is hidden

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

59 files changed

+3709
-473
lines changed

.github/workflows/integration.yaml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ permissions:
2424
contents: read # to fetch code (actions/checkout)
2525

2626
env:
27-
REDIS_STACK_IMAGE: redis/redis-stack-server:7.4.0-rc1
27+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
28+
REDIS_IMAGE: redis:7.4-rc2
29+
REDIS_STACK_IMAGE: redis/redis-stack-server:7.4.0-rc2
2830

2931
jobs:
3032
dependency-audit:
@@ -115,7 +117,9 @@ jobs:
115117
python-version: ['3.8', '3.11']
116118
test-type: ['standalone', 'cluster']
117119
connection-type: ['hiredis', 'plain']
118-
protocol: ['3']
120+
exclude:
121+
- test-type: 'cluster'
122+
connection-type: 'hiredis'
119123
env:
120124
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
121125
name: RESP3 [${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}]
@@ -134,9 +138,33 @@ jobs:
134138
pip install hiredis
135139
fi
136140
invoke devenv
137-
sleep 5 # time to settle
138-
invoke ${{matrix.test-type}}-tests
139-
invoke ${{matrix.test-type}}-tests --uvloop
141+
sleep 10 # time to settle
142+
invoke ${{matrix.test-type}}-tests --protocol=3
143+
invoke ${{matrix.test-type}}-tests --uvloop --protocol=3
144+
145+
- uses: actions/upload-artifact@v4
146+
if: success() || failure()
147+
with:
148+
name: pytest-results-${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.python-version}}-resp3
149+
path: '${{matrix.test-type}}*results.xml'
150+
151+
- name: Upload codecov coverage
152+
uses: codecov/codecov-action@v4
153+
with:
154+
fail_ci_if_error: false
155+
156+
- name: View Test Results
157+
uses: dorny/test-reporter@v1
158+
if: success() || failure()
159+
continue-on-error: true
160+
with:
161+
name: Test Results ${{matrix.python-version}} ${{matrix.test-type}}-${{matrix.connection-type}}-resp3
162+
path: '*.xml'
163+
reporter: java-junit
164+
list-suites: all
165+
list-tests: all
166+
max-annotations: 10
167+
fail-on-error: 'false'
140168

141169
build_and_test_package:
142170
name: Validate building and installing the package

.github/workflows/spellcheck.yml

Lines changed: 1 addition & 1 deletion
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.36.0
11+
uses: rojopolis/spellcheck-github-actions@0.38.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

.github/workflows/stale-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/stale@v3
15+
- uses: actions/stale@v9
1616
with:
1717
repo-token: ${{ secrets.GITHUB_TOKEN }}
1818
stale-issue-message: 'This issue is marked stale. It will be closed in 30 days if it is not updated.'

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* Mark `redis.asyncio` as public in the top-level __init__.py
2+
* Move doctests (doc code examples) to main branch
23
* Update `ResponseT` type hint
34
* Allow to control the minimum SSL version
45
* Add an optional lock_name attribute to LockError.

dev_requirements.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
click==8.0.4
21
black==24.3.0
32
cachetools
4-
flake8==5.0.4
3+
click==8.0.4
54
flake8-isort==6.0.0
5+
flake8==5.0.4
66
flynt~=0.69.0
7+
invoke==1.7.3
78
mock==4.0.3
89
packaging>=20.4
9-
pytest==7.2.0
10-
pytest-timeout==2.1.0
11-
pytest-asyncio>=0.20.2
12-
invoke==1.7.3
13-
pytest-cov>=4.0.0
14-
vulture>=2.3.0
10+
pytest
11+
pytest-asyncio
12+
pytest-cov
13+
pytest-timeout
1514
ujson>=4.2.0
16-
wheel>=0.30.0
1715
urllib3<2
1816
uvloop
17+
vulture>=2.3.0
18+
wheel>=0.30.0

docker-compose.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
redis:
88
image: ${REDIS_IMAGE:-redis:latest}
99
container_name: redis-standalone
10-
command: redis-server --enable-debug-command yes
10+
command: redis-server --enable-debug-command yes --protected-mode no
1111
ports:
1212
- 6379:6379
1313
profiles:
@@ -21,7 +21,7 @@ services:
2121
container_name: redis-replica
2222
depends_on:
2323
- redis
24-
command: redis-server --replicaof redis 6379
24+
command: redis-server --replicaof redis 6379 --protected-mode no
2525
ports:
2626
- 6380:6379
2727
profiles:
@@ -67,7 +67,7 @@ services:
6767
container_name: redis-sentinel
6868
depends_on:
6969
- redis
70-
entrypoint: "/usr/local/bin/redis-sentinel /redis.conf --port 26379"
70+
entrypoint: "redis-sentinel /redis.conf --port 26379"
7171
ports:
7272
- 26379:26379
7373
volumes:
@@ -81,7 +81,7 @@ services:
8181
container_name: redis-sentinel2
8282
depends_on:
8383
- redis
84-
entrypoint: "/usr/local/bin/redis-sentinel /redis.conf --port 26380"
84+
entrypoint: "redis-sentinel /redis.conf --port 26380"
8585
ports:
8686
- 26380:26380
8787
volumes:
@@ -95,7 +95,7 @@ services:
9595
container_name: redis-sentinel3
9696
depends_on:
9797
- redis
98-
entrypoint: "/usr/local/bin/redis-sentinel /redis.conf --port 26381"
98+
entrypoint: "redis-sentinel /redis.conf --port 26381"
9999
ports:
100100
- 26381:26381
101101
volumes:
@@ -114,3 +114,12 @@ services:
114114
profiles:
115115
- standalone
116116
- all
117+
118+
redis-stack-graph:
119+
image: redis/redis-stack-server:6.2.6-v15
120+
container_name: redis-stack-graph
121+
ports:
122+
- 6480:6379
123+
profiles:
124+
- standalone
125+
- all

dockers/create_cluster.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dir /nodes/$PORT
3131
EOF
3232

3333
set -x
34-
/usr/local/bin/redis-server /nodes/$PORT/redis.conf
34+
redis-server /nodes/$PORT/redis.conf
3535
sleep 1
3636
if [ $? -ne 0 ]; then
3737
echo "Redis failed to start, exiting."
@@ -40,8 +40,8 @@ EOF
4040
echo 127.0.0.1:$PORT >> /nodes/nodemap
4141
done
4242
if [ -z "${REDIS_PASSWORD}" ]; then
43-
echo yes | /usr/local/bin/redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
43+
echo yes | redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
4444
else
45-
echo yes | /usr/local/bin/redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
45+
echo yes | redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
4646
fi
4747
tail -f /redis.log

doctests/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Command examples for redis.io
2+
3+
## How to add an example
4+
5+
Create regular python file in the current folder with meaningful name. It makes sense prefix example files with
6+
command category (e.g. string, set, list, hash, etc) to make navigation in the folder easier. Files ending in *.py*
7+
are automatically run by the test suite.
8+
9+
### Special markup
10+
11+
See https://github.com/redis-stack/redis-stack-website#readme for more details.
12+
13+
## How to test examples
14+
15+
Examples are standalone python scripts, committed to the *doctests* directory. These scripts assume that the
16+
```requirements.txt``` and ```dev_requirements.txt``` from this repository have been installed, as per below.
17+
18+
```bash
19+
pip install -r requirements.txt
20+
pip install -r dev_requirements.txt
21+
pip install -r doctests/requirements.txt
22+
```
23+
24+
Note - the CI process, runs the basic ```black``` and ```isort``` linters against the examples. Assuming
25+
the requirements above have been installed you can run ```black yourfile.py``` and ```isort yourfile.py```
26+
locally to validate the linting, prior to CI.
27+
28+
Just include necessary assertions in the example file and run
29+
```bash
30+
sh doctests/run_examples.sh
31+
```
32+
to test all examples in the current folder.

doctests/dt_bitfield.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# EXAMPLE: bitfield_tutorial
2+
# HIDE_START
3+
"""
4+
Code samples for Bitfield doc pages:
5+
https://redis.io/docs/latest/develop/data-types/bitfields/
6+
"""
7+
import redis
8+
9+
r = redis.Redis(decode_responses=True)
10+
# HIDE_END
11+
12+
# REMOVE_START
13+
r.delete("bike:1:stats")
14+
# REMOVE_END
15+
16+
# STEP_START bf
17+
bf = r.bitfield("bike:1:stats")
18+
res1 = bf.set("u32", "#0", 1000).execute()
19+
print(res1) # >>> [0]
20+
21+
res2 = bf.incrby("u32", "#0", -50).incrby("u32", "#1", 1).execute()
22+
print(res2) # >>> [950, 1]
23+
24+
res3 = bf.incrby("u32", "#0", 500).incrby("u32", "#1", 1).execute()
25+
print(res3) # >>> [1450, 2]
26+
27+
res4 = bf.get("u32", "#0").get("u32", "#1").execute()
28+
print(res4) # >>> [1450, 2]
29+
# STEP_END
30+
31+
# REMOVE_START
32+
assert res1 == [0]
33+
assert res4 == [1450, 2]
34+
# REMOVE_END

doctests/dt_bitmap.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# EXAMPLE: bitmap_tutorial
2+
# HIDE_START
3+
"""
4+
Code samples for Bitmap doc pages:
5+
https://redis.io/docs/latest/develop/data-types/bitmaps/
6+
"""
7+
import redis
8+
9+
r = redis.Redis(decode_responses=True)
10+
# HIDE_END
11+
12+
# REMOVE_START
13+
r.delete("pings:2024-01-01-00:00")
14+
# REMOVE_END
15+
16+
# STEP_START ping
17+
res1 = r.setbit("pings:2024-01-01-00:00", 123, 1)
18+
print(res1) # >>> 0
19+
20+
res2 = r.getbit("pings:2024-01-01-00:00", 123)
21+
print(res2) # >>> 1
22+
23+
res3 = r.getbit("pings:2024-01-01-00:00", 456)
24+
print(res3) # >>> 0
25+
# STEP_END
26+
27+
# REMOVE_START
28+
assert res1 == 0
29+
# REMOVE_END
30+
31+
# STEP_START bitcount
32+
# HIDE_START
33+
r.setbit("pings:2024-01-01-00:00", 123, 1)
34+
# HIDE_END
35+
res4 = r.bitcount("pings:2024-01-01-00:00")
36+
print(res4) # >>> 1
37+
# STEP_END
38+
# REMOVE_START
39+
assert res4 == 1
40+
# REMOVE_END

0 commit comments

Comments
 (0)