Skip to content

Commit 6575778

Browse files
authored
Refactored Dependecies Management (#225)
* Removed "-n auto" from examples CI * Bugfix: Added pytest-celery package to built-in Celery worker Dockerfile * Refactored Dependecies Management * Disabled Memcached automatic detection due to "Experimental Status"
1 parent b9051e6 commit 6575778

File tree

22 files changed

+390
-207
lines changed

22 files changed

+390
-207
lines changed

.github/workflows/examples.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ on:
1111
- "**.txt"
1212
- ".github/workflows/examples.yml"
1313
- "**.toml"
14+
- 'src/pytest_celery/vendors/worker/**'
15+
- 'Dockerfile'
1416
pull_request:
1517
paths:
1618
- "**.py"
1719
- "**.txt"
1820
- "**.toml"
1921
- ".github/workflows/examples.yml"
22+
- 'src/pytest_celery/vendors/worker/**'
23+
- 'Dockerfile'
2024

2125
permissions:
2226
contents: read # to fetch code (actions/checkout)
@@ -53,7 +57,7 @@ jobs:
5357
working-directory: examples/myworker
5458
timeout-minutes: 10
5559
run: |
56-
pytest -vv tests -n auto
60+
pytest -vv tests
5761
5862
range:
5963
runs-on: ${{ matrix.os }}
@@ -84,9 +88,9 @@ jobs:
8488
8589
- name: Run tests
8690
working-directory: examples/range
87-
timeout-minutes: 10
91+
timeout-minutes: 30
8892
run: |
89-
pytest -vv tests -n auto
93+
pytest -vv tests
9094
9195
rabbitmq_management:
9296
runs-on: ${{ matrix.os }}
@@ -119,7 +123,7 @@ jobs:
119123
working-directory: examples/rabbitmq_management
120124
timeout-minutes: 10
121125
run: |
122-
pytest -vv tests -n auto
126+
pytest -vv tests
123127
124128
django:
125129
runs-on: ${{ matrix.os }}
@@ -158,7 +162,7 @@ jobs:
158162
timeout-minutes: 10
159163
run: |
160164
export DJANGO_SETTINGS_MODULE=proj.settings
161-
pytest -vv tests -n auto
165+
pytest -vv tests
162166
163167
myutils:
164168
runs-on: ${{ matrix.os }}
@@ -191,4 +195,4 @@ jobs:
191195
working-directory: examples/myutils
192196
timeout-minutes: 10
193197
run: |
194-
pytest -vv tests -n auto
198+
pytest -vv tests

.github/workflows/parallel-support.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
poetry install --only ci
6363
6464
- name: Run tox for all environments in parallel
65-
timeout-minutes: 15
65+
timeout-minutes: 30
6666
run: |
6767
tox -e xdist
6868
@@ -104,6 +104,6 @@ jobs:
104104
poetry install --only ci
105105
106106
- name: Run tox for all environments in parallel
107-
timeout-minutes: 15
107+
timeout-minutes: 30
108108
run: |
109109
tox -e parallel

.github/workflows/python-package.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ on:
1212
- ".github/workflows/python-package.yml"
1313
- "**.toml"
1414
- "tox.ini"
15+
- 'src/pytest_celery/vendors/worker/**'
16+
- 'Dockerfile'
1517
pull_request:
1618
paths:
1719
- "**.py"
1820
- "**.txt"
1921
- "**.toml"
2022
- ".github/workflows/python-package.yml"
2123
- "tox.ini"
24+
- 'src/pytest_celery/vendors/worker/**'
25+
- 'Dockerfile'
2226

2327
permissions:
2428
contents: read # to fetch code (actions/checkout)
@@ -159,6 +163,6 @@ jobs:
159163
poetry install --only ci
160164
161165
- name: Run tox for "${{ matrix.python-version }}-smoke"
162-
timeout-minutes: 15
166+
timeout-minutes: 30
163167
run: |
164168
tox --verbose --verbose -e "${{ matrix.python-version }}-smoke" -- -n auto --reruns 2 --rerun-except AssertionError

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ build:
1717
# Tell poetry to not use a virtual environment
1818
- poetry config virtualenvs.create false
1919
post_install:
20-
- poetry install --with docs
20+
- poetry install -E "all" --with docs
2121

2222
# Build documentation in the "docs/" directory with Sphinx
2323
sphinx:

docs/faq.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ To avoid these, you may:
167167
1. Increase the resources available to Docker.
168168
2. Use the :pypi:`pytest-rerunfailures` pytest plugin to retry failed tests with:
169169

170-
.. code-block:: bash
170+
.. code-block:: console
171171
172172
--reruns 5 --reruns-delay 60 --rerun-except AssertionError
173173

docs/getting-started/first-steps.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ This simple test then,
148148
149149
Will run against all of the (enabled) possible combinations of the environment matrix.
150150

151-
.. code-block:: bash
151+
.. code-block:: console
152152
153153
pytest tests/test_example.py
154154
======================================================================= test session starts ===================================
@@ -165,7 +165,7 @@ With each iteration having its own isolated environment.
165165
RabbitMQ Broker Iteration Breakdown
166166
###################################
167167

168-
.. code-block:: bash
168+
.. code-block:: console
169169
170170
docker ps
171171
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@@ -175,7 +175,7 @@ RabbitMQ Broker Iteration Breakdown
175175
176176
With the worker configured correctly for its broker and backend.
177177

178-
.. code-block:: bash
178+
.. code-block:: console
179179
180180
-------------- celery_test_worker@0ffb4e75b5e4 v5.3.6 (emerald-rush)
181181
--- ***** -----
@@ -193,7 +193,7 @@ With the worker configured correctly for its broker and backend.
193193
194194
With more verbose test logs.
195195

196-
.. code-block:: bash
196+
.. code-block:: console
197197
198198
============================= test session starts ==============================
199199
...
@@ -215,7 +215,7 @@ With more verbose test logs.
215215
Redis Broker Iteration Breakdown
216216
################################
217217

218-
.. code-block:: bash
218+
.. code-block:: console
219219
220220
docker ps
221221
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@@ -225,7 +225,7 @@ Redis Broker Iteration Breakdown
225225
226226
With the worker configured correctly for its broker and backend.
227227

228-
.. code-block:: bash
228+
.. code-block:: console
229229
230230
-------------- celery_test_worker@37e8ea35206f v5.3.6 (emerald-rush)
231231
--- ***** -----
@@ -243,7 +243,7 @@ With the worker configured correctly for its broker and backend.
243243
244244
With more verbose test logs.
245245

246-
.. code-block:: bash
246+
.. code-block:: console
247247
248248
============================= test session starts ==============================
249249
...
@@ -299,7 +299,7 @@ Or, testing the :ref:`default redis broker <redis-broker>` at the node level.
299299
Remember, each test case is isolated. This means that both of these tests
300300
can run in parallel, and **each will be assigned its own container instance.**
301301

302-
.. code-block:: bash
302+
.. code-block:: console
303303
304304
pytest tests/test_example.py -n auto
305305
======================================================================= test session starts ===================================
@@ -312,7 +312,7 @@ can run in parallel, and **each will be assigned its own container instance.**
312312
313313
======================================================================== 2 passed in 1.72s ====================================
314314
315-
.. code-block:: bash
315+
.. code-block:: console
316316
317317
docker ps
318318
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

docs/getting-started/introduction.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
.. contents::
1111
:local:
12-
:depth: 1
12+
:depth: 2
1313

1414
What is Pytest Celery?
1515
======================
@@ -254,4 +254,6 @@ Quick Jump
254254
- :ref:`FAQ <faq>`
255255
- :ref:`API Reference <apiref>`
256256

257+
.. _installation:
258+
257259
.. include:: ../includes/installation.txt

docs/getting-started/vendors.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ Experimental brokers may be functional but are not confirmed to be
4343
production ready.
4444

4545
Enabled means that it is automatically added to the test setup matrix
46-
when running the test suite.
46+
when running the test suite :ref:`if the vendor dependencies are installed <installation>`.
4747

4848
.. warning::
4949

5050
Enabling a new vendor will automatically add it globally to every test suite that relies
51-
on the default configurations. Be careful when enabling new vendors.
51+
on the default vendors detection. Be careful when enabling new vendors and make sure they are
52+
stable and production ready.
5253

5354
.. _built-in-worker:
5455

docs/includes/installation.txt

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,68 @@
1-
.. _installation:
2-
31
Installation
42
============
53

6-
You can install Pytest Celery via the Python Package Index (PyPI).
4+
The **pytest-celery** plugin can be easily installed via the Python Package Index (PyPI) using :command:`pip`.
5+
6+
Installing the pytest-celery package
7+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78

8-
To install using :command:`pip`:
9+
To install the latest version of **pytest-celery**, run the following command:
910

1011
.. code-block:: console
1112

12-
$ pip install -U pytest-celery
13+
pip install -U pytest-celery
14+
15+
This command installs **pytest-celery** along with its required dependencies.
16+
17+
This will include:
18+
19+
- Latest version of :pypi:`celery`.
20+
- RabbitMQ broker via :pypi:`kombu`, installed as a dependency of Celery.
21+
22+
Installing pytest-celery vendors
23+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24+
25+
The plugin detects which vendor dependencies are installed in the test environment to configure
26+
the default configurations automatically. This means that just by installing the matching dependencies,
27+
the plugin will allow extending the default configurations, up to the supported built-in :ref:`vendors`.
28+
29+
.. warning::
30+
31+
If you don't install any vendor (e.g. no extras and no manual installation), the plugin will result in an
32+
empty setup matrix and might not be fully functional.
33+
34+
To install the vendors, you may either install all of the dependencies manually, or use the following extras:
35+
36+
- ``all``: Installs all vendors.
37+
- ``redis``: Installs Redis vendor, providing **broker** and **result backend** components.
38+
- ``memcached``: Installs Memcached vendor, providing a **result backend** component.
39+
40+
The following extra is installed by default:
41+
42+
- ``rabbitmq``: Installs RabbitMQ vendor, providing a **broker** component.
43+
44+
To install **pytest-celery** with the built-in :ref:`vendors`, replace ``<extra>`` with the name of the vendor.
45+
46+
.. code-block:: console
47+
48+
pip install -U "pytest-celery[<extra>]"
49+
50+
RabbitMQ & Redis combo
51+
----------------------
52+
53+
.. code-block:: console
54+
55+
pip install -U "pytest-celery[redis]"
56+
57+
This will configure the plugin to generate all possible setups using only RabbitMQ and Redis vendors.
58+
59+
All vendors
60+
-----------
61+
62+
.. code-block:: console
1363

14-
The :pypi:`celery` package will be installed by default with the ``redis`` and ``pymemcache``
15-
`extras <https://docs.celeryq.dev/en/stable/getting-started/introduction.html#transports-and-backends>`_.
64+
pip install -U "pytest-celery[all]"
1665

17-
With git
18-
~~~~~~~~
66+
This will configure the plugin to generate all possible setups.
1967

20-
Please see the :ref:`Contributing <contributing>` section.
68+
This approach allows you to tailor the installation to your project's specific needs by including only the necessary optional vendors.

examples/django/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sqlalchemy>=1.2.18
22
django>=2.2.1
33
pytest-django>=4.7.0
4-
git+https://github.com/celery/pytest-celery.git
54
pytest-xdist>=3.5.0
5+
pytest-celery[all]@git+https://github.com/Katz-Consulting-Group/pytest-celery.git@bugfix

0 commit comments

Comments
 (0)