Skip to content

Commit

Permalink
Merge branch 'master' into allow-disable-greetings
Browse files Browse the repository at this point in the history
  • Loading branch information
laixintao authored Oct 31, 2023
2 parents 02fd9fe + 9cc5b02 commit a22270d
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 96 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tests
scripts
CHANGELOG.md
Dockerfile
docs
pyoxidizer.template.bzl
redis-doc
3 changes: 2 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ jobs:
test:
name: Pytest
strategy:
fail-fast: false
matrix:
os: ["ubuntu-20.04"]
python: ["3.7", "3.8", "3.9", "3.10", "3.11.1"]
redis: [5, 6, 7]
redis: [5, 6, 7, 7.2]
runs-on: ${{ matrix.os }}

services:
Expand Down
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## UPCOMING

### 1.13.3
## 1.14

- Dependency: upgrade redis-py to 5 (thanks to [chayim])
- Feature: porting to redis-server 7.2 now
- Feature: supports python 3.10, 3.11 now
- Doc: update commands.json from redis-doc to latest version
- Feature: add `--no-greetings` option, to allow disable greetings information
on IRedis startup.

Expand Down Expand Up @@ -286,7 +290,7 @@

### 0.8.12

- Bugfix: Multi spaces between commands can be recongnised as correct commands
- Bugfix: Multi spaces between commands can be recognised as correct commands
now.
- Feature: Warning on dangerous command.

Expand Down Expand Up @@ -324,3 +328,4 @@
[tssujt]: https://github.com/tssujt
[aymericbeaumet]: https://github.com/aymericbeaumet
[torrefatto]: https://github.com/torrefatto
[chayim]: https://github.com/chayim
28 changes: 13 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
FROM python:3
FROM redis/redis-stack-server:latest

WORKDIR /iredis
COPY README.md poetry.lock pyproject.toml ./
COPY iredis ./iredis

RUN apt-get update && apt-get install -y --allow-unauthenticated \
redis-server && \
rm -rf /var/lib/apt/lists/*
COPY . /iredis

RUN apt-get update --fix-missing
RUN apt-get install -yqq python3 python3-pip python-is-python3
RUN python3 -m pip install poetry
WORKDIR /iredis
RUN poetry config virtualenvs.create false
RUN poetry build
RUN pip install dist/iredis*.tar.gz
WORKDIR /
RUN rm -rf .cache /var/cache/apt
RUN rm -rf /iredis

RUN python3 -m venv iredis_env && \
. iredis_env/bin/activate && \
pip install poetry && \
poetry install --no-dev && \
rm -rf ~/.cache

CMD ["sh","-c","redis-server --daemonize yes && . iredis_env/bin/activate && iredis"]
CMD ["sh", "-c", "/opt/redis-stack/bin/redis-stack-server --daemonize yes && iredis"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<p align="center">
<a href="https://github.com/laixintao/iredis/actions"><img src="https://github.com/laixintao/iredis/workflows/Test/badge.svg" alt="Github Action"></a>
<a href="https://badge.fury.io/py/iredis"><img src="https://badge.fury.io/py/iredis.svg" alt="PyPI version"></a>
<img src="https://badgen.net/badge/python/3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9%20%7C%203.10/" alt="Python version">
<img src="https://badgen.net/badge/python/3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11" alt="Python version">
<a href="https://pepy.tech/project/iredis"><img src="https://pepy.tech/badge/iredis" alt="Download stats"></a>
</p>

Expand Down
1 change: 1 addition & 0 deletions iredis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def __init__(
try:
self.connection.connect()
except Exception as e:
logger.exception("Can not create connection to server")
print(str(e), file=sys.stderr)
sys.exit(1)
if not config.no_info:
Expand Down
57 changes: 22 additions & 35 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
# "Programming Language :: Python :: 3.12",
"Topic :: Database",
"License :: OSI Approved :: MIT License",
"Intended Audience :: Developers",
]

packages = [
{ include = "iredis" },
{ include = "tests", format = "sdist" },
]

[tool.poetry.dependencies]
Expand All @@ -35,12 +36,12 @@ prompt_toolkit = "^3"
Pygments = "^2"
mistune = "^3.0"
configobj = "^5.0"
click = "^7.0"
pendulum = "^2.0"
click = "^8.0"
pendulum = "^2.1.0"
# wcwidth 0.2.x uses pkg_resources which is not supported by PyOxidizer
wcwidth = "0.1.9"
packaging = "^21.3"
redis = "^4.5.3"
packaging = "^23.0"
redis = "^5.0.0"

[tool.poetry.dev-dependencies]
pytest = "^7.2"
Expand Down
2 changes: 1 addition & 1 deletion redis-doc
8 changes: 5 additions & 3 deletions tests/cli_tests/test_cli_start.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from textwrap import dedent

from packaging.version import parse as version_parse # noqa: F401
import pexpect
import pytest
from textwrap import dedent


def test_start_on_connection_error():
Expand Down Expand Up @@ -29,14 +31,14 @@ def test_short_help_option(config):
c.close()


@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) != 5")
@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) != version_parse('5')")
def test_server_version_in_starting_on5():
c = pexpect.spawn("iredis", timeout=2)
c.expect("redis-server 5")
c.close()


@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) != 6")
@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) != version_parse('6')")
def test_server_version_in_starting_on6():
c = pexpect.spawn("iredis", timeout=2)
c.expect("redis-server 6")
Expand Down
8 changes: 5 additions & 3 deletions tests/cli_tests/test_command_input.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os

from packaging.version import parse as version_parse
import pytest


Expand All @@ -9,7 +11,7 @@ def test_wrong_select_db_index(cli):
cli.sendline("select 128")
cli.expect(["DB index is out of range", "127.0.0.1:6379[1]>"])

if int(os.environ["REDIS_VERSION"]) > 5:
if version_parse(os.environ["REDIS_VERSION"]) > version_parse("5"):
text = "value is not an integer or out of range"
else:
text = "invalid DB index"
Expand Down Expand Up @@ -42,14 +44,14 @@ def test_enter_key_binding(clean_redis, cli):
cli.expect(r"hello")


@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) < 6")
@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) < version_parse('6')")
def test_auth_hidden_password_with_username(clean_redis, cli):
cli.send("auth default hello-world")
cli.expect("default")
cli.expect(r"\*{11}")


@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) > 5")
@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) > version_parse('5')")
def test_auth_hidden_password(clean_redis, cli):
cli.send("auth hello-world")
cli.expect("auth")
Expand Down
3 changes: 2 additions & 1 deletion tests/cli_tests/test_completer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from packaging.version import parse as version_parse # noqa: F401
import pytest


Expand Down Expand Up @@ -37,7 +38,7 @@ def test_command_completion_when_space_command(cli, clean_redis):
cli.expect("command info")


@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) < 6")
@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) < version_parse('6')")
def test_username_completer(cli, iredis_client):
iredis_client.execute("acl setuser", "foo1")
iredis_client.execute("acl setuser", "bar2")
Expand Down
17 changes: 9 additions & 8 deletions tests/cli_tests/test_pager.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# noqa: F541
from contextlib import contextmanager
import os
import sys
import pexpect
import pathlib
from contextlib import contextmanager
import sys
from textwrap import dedent
from packaging.version import parse as version_parse

import pexpect


TEST_IREDISRC = "/tmp/.iredisrc.test"
Expand All @@ -22,6 +24,10 @@
TEST_PAGER_BOUNDARY_NUMBER,
)

long_list_type = "quicklist"
if version_parse(os.environ["REDIS_VERSION"]) >= version_parse("7"):
long_list_type = "listpack"


@contextmanager
def pager_enabled_cli():
Expand Down Expand Up @@ -54,11 +60,6 @@ def test_using_pager_works_for_help():
child.expect(TEST_PAGER_BOUNDARY)


long_list_type = "quicklist"
if os.environ["REDIS_VERSION"] == "7":
long_list_type = "listpack"


def test_pager_works_for_peek(clean_redis):
for index in range(100):
clean_redis.lpush("long-list", f"value-{index}")
Expand Down
Loading

0 comments on commit a22270d

Please sign in to comment.