Skip to content
Closed
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
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Dockerfile.test
.dockerignore
.gitignore
.git/

# from .gitignore
.eggs/
*.egg-info/
.pytest_cache/
*.pyc
__pycache__/
ssl/*.cert
ssl/*.certchain
ssl/*.csr
ssl/*.key
ssl/*.srl
.tox/
.coverage
16 changes: 16 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Docker Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
docker-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . --file Dockerfile.test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ ssl/*.csr
ssl/*.key
ssl/*.srl
.tox/
poetry.lock
.coverage
25 changes: 25 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Test, with a single Docker command!
# `docker build` => succeeds if tests pass
FROM rabbitmq:4.1.2

RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:deadsnakes/ppa
RUN apt-get install -y python3.10 python3.11 python3.12 python3.13 python3-pip python3-venv netcat-openbsd

WORKDIR /src
RUN python3 -mvenv /src/venv
RUN venv/bin/python3 -mpip install --upgrade pip poetry setuptools tox

ADD pyproject.toml /src

RUN venv/bin/tox --notest run

ADD pyproject.toml poetry.lock README.rst /src
ADD channels_rabbitmq /src/channels_rabbitmq
ADD tests /src/tests

ADD ssl /src/ssl
ADD test-rabbitmq.conf /etc/rabbitmq/rabbitmq.conf

RUN bash -c 'ssl/prepare-certs.sh && (rabbitmq-server - & ((while ! nc -z localhost 5671; do sleep 0.1; done) && (while ! nc -z localhost 5672; do sleep 0.1; done) && venv/bin/tox))'
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ Now take on the development cycle:
#. ``tox`` # to ensure tests pass.
#. Write new tests in ``tests/`` and make sure they fail.
#. Write new code in ``channels_rabbitmq/`` to make the tests pass.
#. Run ``docker build . -f Dockerfile.test`` to test all Python versions.
#. Submit a pull request.

To deploy
Expand Down
6 changes: 3 additions & 3 deletions channels_rabbitmq/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ def __init__(
self._queue_name = "channels_{rand}".format(rand=_random_letters(12))

self._multi_queue = MultiQueue(capacity=local_capacity)
self._carehare_connection: asyncio.Future[
carehare.Connection
] = asyncio.Future()
self._carehare_connection: asyncio.Future[carehare.Connection] = (
asyncio.Future()
)
self._want_close: bool = False

@property
Expand Down
517 changes: 517 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ channels = ">=3.0,<5"
msgpack = "~=1.0"
python = "~=3.8"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = "~=7.2"
pytest-asyncio = "~=0.20"
pytest-cov = "~=4.0"
Expand All @@ -37,7 +37,7 @@ legacy_tox_ini = """
[tox]
isolated_build = True
skipsdist = True
envlist = {py38,py39,py310}-{pyflakes,black,isort,pytest}
envlist = {py310,py311,py312,py313}-{pyflakes,black,isort,pytest}

[flake8]
exclude = venv/*,tox/*,specs/*,build/*
Expand Down
2 changes: 1 addition & 1 deletion ssl/prepare-certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ rm -f ./*.{srl,csr,key,cert}
# root-CA ("Certificate authority") key
openssl genrsa -out ca.key 2048
# root-CA certificate (server and client will trust this)
openssl req -x509 -new -key ca.key -sha256 -days 9999 -out ca.cert -subj '/CN=localhost'
openssl req -x509 -new -key ca.key -sha256 -days 9999 -out ca.cert -subj '/CN=localhost' -addext "keyUsage = digitalSignature, cRLSign, keyCertSign"

# server key
openssl genrsa -out server.key 2048
Expand Down
7 changes: 7 additions & 0 deletions test-rabbitmq.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# for `docker build. -f Dockerfile.test`
listeners.ssl.default = 5671
ssl_options.cacertfile = /src/ssl/ca.cert
ssl_options.certfile = /src/ssl/server.cert
ssl_options.keyfile = /src/ssl/server.key
ssl_options.verify = verify_peer
ssl_options.fail_if_no_peer_cert = true
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

HOST = "amqps://guest:guest@localhost"
SSL_CONTEXT = ssl.create_default_context(
cafile=str(Path(__file__).parent.parent / "ssl" / "server.cert")
cafile=str(Path(__file__).parent.parent / "ssl" / "ca.cert")
)
SSL_CONTEXT.load_cert_chain(
certfile=str(Path(__file__).parent.parent / "ssl" / "client.certchain"),
Expand Down