Skip to content

Commit

Permalink
ci: Migrate to Poetry
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Giffard <[email protected]>
  • Loading branch information
Mulugruntz committed Jan 17, 2024
1 parent 6edea1f commit 86914ea
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 25 deletions.
49 changes: 29 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,53 +96,62 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Show system
run: |
python --version
uname -a
lsb_release -a
- name: Install Poetry
uses: snok/install-poetry@v1
with:
# Use 1.5.1 for Python 3.7, otherwise use latest.
version: ${{ matrix.python-version == '3.7' && '1.5.1' || 'latest' }}
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.celery }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_test.txt
pip install "celery${{ matrix.celery }}"
pip install pytest-github-actions-annotate-failures
poetry add "celery${{ matrix.celery }}"
poetry install --no-interaction --no-root --with=ci --with=dev
- name: Install project
run: poetry install --no-interaction

- name: Check with black
run: black --check .
run: poetry run black --check .

- name: Check with mypy
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
run: mypy
run: poetry run mypy

- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude .github
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude .github --exclude .venv
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude .github
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude .github --exclude .venv
- name: Test with pytest
run: |
coverage run -m pytest -v -s tests
coverage report
poetry run coverage run -m pytest -v -s tests
poetry run coverage report
- name: Code Climate Coverage Action
uses: paambaati/codeclimate-action@v3.2.0
uses: paambaati/codeclimate-action@v5.0.0
env:
# According to CodeClimate documentation, this is not considered a sensitive value.
# https://docs.codeclimate.com/docs/finding-your-test-coverage-token#regenerating-a-repos-test-reporter-id
CC_TEST_REPORTER_ID: 4967416d540739937e0eebfb13a3cf2f8dfbddd762f2b1ec800e83d18fb5efbb
with:
coverageCommand: coverage xml
coverageCommand: poetry run coverage xml
debug: true

- name: Prepare badges
Expand Down
39 changes: 35 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[tool.poetry]
name = "celery-pubsub"
version = "2.0.0-beta3"
version = "2.0.0-beta4"
description = "A Publish and Subscribe library for Celery"
authors = ["Samuel Giffard <[email protected]>"]
license = "MIT"
authors = ["Samuel GIFFARD <[email protected]>"]
readme = "README.md"
homepage = "https://github.com/Mulugruntz/celery-pubsub"
repository = "https://github.com/Mulugruntz/celery-pubsub"
Expand All @@ -17,17 +17,48 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries",
"Topic :: System :: Distributed Computing",
"Topic :: Utilities",
]
packages = [
{include = "celery_pubsub"},
]
include = [
{ path = "LICENSE", format = "sdist" },
]

[tool.poetry.urls]
"Download" = "https://github.com/Mulugruntz/celery-pubsub/tarball/2.0.0-beta4"

[tool.poetry.dependencies]
python = ">=3.7"
celery = ">=4.0.0"
python = ">=3.7,<3.13"
celery = {version = ">=4.0,<6.0"}
# In python 3.12, we have to use kombu 5.3.5 or higher.
# This is not ideal, as it's celery's own dependency.
# https://github.com/celery/kombu/pull/1509
kombu = [
{version = ">=4.0,<6.0", python = ">=3.7,<3.12"},
{version = "^5.3.0", python = ">=3.12"}
]

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"
coverage = "5.5"
black = "23.3.0"
flake8 = ">=5.0.0"
typing-extensions = "4.7.1"
# Only for CPython (exclude pypy).
celery-types = {version = "0.14.0", markers = "implementation_name != 'pypy'"}
mypy = {version = "1.0.0", markers = "implementation_name != 'pypy'"}
types-setuptools = {version = "67.6.0.6", markers = "implementation_name != 'pypy'"}


[tool.poetry.group.ci.dependencies]
pytest-github-actions-annotate-failures = "^0.2.0"

[build-system]
requires = ["poetry-core"]
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import pytest

import celery
from celery import Task
from celery.app.task import Task

from celery_pubsub import subscribe, subscribe_to
from packaging.version import parse, Version
Expand Down

0 comments on commit 86914ea

Please sign in to comment.