Skip to content

Commit

Permalink
ci: Change the GitHub Actions trigger, drop Celery 3 support (#261)
Browse files Browse the repository at this point in the history
* ci: Change the GitHub Actions trigger

Now, it will run tests for every pull request made to the `master` branch, as well as when merges are pushed to `master`.

* Drop support for Celery 3

Celery 3 depends on `use_2to3` which is no longer supported by any of the latest patch versions of CPython and Pypy, for >= 3.7.

The CI for Celery 3 was not able to run on any Python provided by GitHub Actions. It is time to fully decommission it.
  • Loading branch information
Mulugruntz authored and WaYdotNET committed Dec 4, 2023
1 parent fa9141e commit eefeab4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 41 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ name: Build and Test

on:
push:
branches:
- master
pull_request:
branches:
- master
types: [closed]

jobs:
matrix-builder:
Expand All @@ -24,7 +25,7 @@ jobs:
env:
PY_VERSIONS: "[\"3.7\", \"3.8\", \"3.9\", \"3.10\", \"3.11\", \"pypy-3.8-v7.3.11\", \"pypy-3.9-v7.3.11\"]"
OS_NAMES: "[\"ubuntu-20.04\"]" #, windows-latest, macOS-latest]
CELERY_VERSIONS: "[\">=3.1.0,<4.0.0\", \">=4.0.0,<5.0.0\", \">=5.0.0,<6.0.0\"]"
CELERY_VERSIONS: "[\">=4.0.0,<5.0.0\", \">=5.0.0,<6.0.0\"]"
run: |
python -m pip install --upgrade pip
MATRIX=$(python .github/workflows/resolve_versions.py matrix -c "$PY_VERSIONS" -o "$OS_NAMES" -n "celery" -s "$CELERY_VERSIONS")
Expand Down Expand Up @@ -109,6 +110,9 @@ jobs:
pip install "celery${{ matrix.celery }}"
pip install pytest-github-actions-annotate-failures
- name: Check with black
run: black --check .

- name: Check with mypy
if: ${{ !startsWith(matrix.python-version, 'pypy') && matrix.python-version >= '3.7' }}
run: mypy
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/resolve_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,7 @@ def process_matrix(args: Namespace) -> None:
for c, o, n, s in matrix:
compatible_versions = get_compatible_versions(c, o, n, s)
if compatible_versions:
# This is because celery 3 depends on use_2to3,
# which is no longer supported by 3.9, 3.10 and 3.11
# and by newer pypy versions.
if (
n == "celery"
and (
c.replace(".", "").startswith("39")
or c.replace(".", "").startswith("310")
or c.replace(".", "").startswith("311")
or c.startswith("pypy-3")
)
and all(cv.startswith("3") for cv in compatible_versions)
) or (
# This is because inspect.getfullargspec has been removed in Python 3.11
# and `vine.five` 4.x was depending on it. This is fixed in 5.x.
n == "celery"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ celery_pubsub.publish('some.very.good.test', 42) # task 3 only
* 2.0.0
* Drop support for CPython 2.7, 3.4, 3.5, 3.6
* Drop support for Pypy 2.7 and 3.6.
* Drop support for Celery 3.
* Add support for Pypy 3.8 and 3.9.
* Add support for CPython 3.11.
* Type hints are now directly in the code. No more stubs files.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
celery>=3.1.0
celery>=4.0.0
41 changes: 15 additions & 26 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,28 @@

import celery
from celery import Task
from celery.worker import WorkController

from celery_pubsub import subscribe, subscribe_to
from celery_pubsub import subscribe
from pkg_resources import get_distribution, parse_version

P = ParamSpec("P")
R = TypeVar("R")
task: Callable[..., Callable[[Callable[P, R]], Task[P, R]]]

if not typing.TYPE_CHECKING:
if get_distribution("celery").parsed_version < parse_version("4.0.0"):
celery.current_app.conf.update(
CELERY_ALWAYS_EAGER=True,
)
task = celery.task
task = celery.shared_task

@pytest.fixture
def celery_worker() -> WorkController:
pass
@pytest.fixture(scope="session")
def celery_config():
return {
"broker_url": "memory://",
"result_backend": "rpc://",
"broker_transport_options": {"polling_interval": 0.05},
}

else: # pragma: no cover
task = celery.shared_task

@pytest.fixture(scope="session")
def celery_config():
return {
"broker_url": "memory://",
"result_backend": "rpc://",
"broker_transport_options": {"polling_interval": 0.05},
}

if get_distribution("celery").parsed_version >= parse_version("5.0.0"):
pytest_plugins = ["celery.contrib.pytest"]
if get_distribution("celery").parsed_version >= parse_version("5.0.0"):
pytest_plugins = ["celery.contrib.pytest"]


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -176,10 +165,10 @@ def subscriber(
job_e: Task[P, str],
job_f: Task[P, str],
job_g: Task[P, str],
job_h: Task[P, str],
job_i: Task[P, str],
job_l: Task[P, str],
job_m: Task[P, str],
job_h: Task[P, str],
job_i: Task[P, str],
job_l: Task[P, str],
job_m: Task[P, str],
) -> None:
subscribe("index.high", job_a)
subscribe("index.low", job_b)
Expand Down

0 comments on commit eefeab4

Please sign in to comment.