Skip to content

Commit 54944c7

Browse files
committed
updates packaging, release process and django support
1 parent c09fd1a commit 54944c7

File tree

25 files changed

+304
-246
lines changed

25 files changed

+304
-246
lines changed

.flake8

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/issues.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: 'Close stale issues and PRs'
2+
on:
3+
schedule:
4+
- cron: '30 1 * * *'
5+
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@v9
11+
with:
12+
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
13+
days-before-stale: 60
14+
days-before-close: 10

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release to PyPI
2+
on:
3+
push:
4+
tags: ["*"]
5+
6+
env:
7+
dists-artifact-name: python-package-distributions
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- name: Install the latest version of uv
17+
uses: astral-sh/setup-uv@v5
18+
with:
19+
enable-cache: true
20+
cache-dependency-glob: "pyproject.toml"
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
- name: Build package
23+
run: uv build --python 3.13 --python-preference only-managed --sdist --wheel . --out-dir dist
24+
- name: Store the distribution packages
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: ${{ env.dists-artifact-name }}
28+
path: dist/*
29+
30+
release:
31+
needs:
32+
- build
33+
runs-on: ubuntu-latest
34+
environment:
35+
name: release
36+
url: https://pypi.org/project/django-strategy-fields/${{ github.ref_name }}
37+
permissions:
38+
id-token: write
39+
steps:
40+
- name: Download all the dists
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: ${{ env.dists-artifact-name }}
44+
path: dist/
45+
- name: Publish to PyPI
46+
uses: pypa/[email protected]
47+
with:
48+
attestations: true

.github/workflows/test.yml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ jobs:
6161
strategy:
6262
max-parallel: 1
6363
matrix:
64-
python-version: [ "3.11", "3.12", "3.13" ]
65-
django-version: [ "4.2", "5.1" ]
64+
cfg: [ "d52-py310", "d42-py39" ]
65+
6666
fail-fast: true
6767
needs: [ changes ]
6868
if: needs.changes.outputs.run_tests || needs.changes.outputs.lint
@@ -72,6 +72,7 @@ jobs:
7272
DB_PORT: 15432
7373
DB_USER: "postgres"
7474
DB_PASSWORD: "postgres"
75+
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/celery_model"
7576
steps:
7677
- name: Checkout code
7778
uses: actions/checkout@v4
@@ -87,40 +88,39 @@ jobs:
8788
path: |
8889
.cache-uv/
8990
.venv/
90-
key: ${{ matrix.python-version }}-${{matrix.django-version}}-${{ hashFiles('pyproject.toml') }}-venv
91+
key: ${{ matrix.cfg}}-${{ hashFiles('pyproject.toml') }}-venv
9192

9293
- uses: yezz123/setup-uv@v4
93-
with:
94-
python: ${{ matrix.python-version }}
9594

96-
- name: Test
97-
# if: needs.changes.outputs.run_tests
98-
run: |
99-
uv add "django==${{ matrix.django-version }}.*"
100-
uv run --cache-dir .cache-uv/ \
101-
python -m pytest tests/ \
102-
--junit-xml junit-${{ matrix.python-version }}-${{matrix.django-version}}.xml \
103-
--cov --cov-report xml
104-
- name: Cache venv
105-
if: steps.cache-venv-restore.outputs.cache-hit != 'true'
106-
id: cache-venv-save
107-
uses: actions/cache/save@v4
95+
- name: Install the latest version of uv
96+
uses: astral-sh/setup-uv@v5
10897
with:
109-
path: |
110-
.cache-uv/
111-
.venv/
112-
key: ${{ matrix.python-version }}-${{matrix.django-version}}-${{ hashFiles('pyproject.toml') }}-venv
98+
version: "latest"
99+
enable-cache: true
100+
cache-dependency-glob: |
101+
pyproject.toml
102+
uv.lock
103+
cache-suffix: ${{ matrix.cfg }}
104+
github-token: ${{ secrets.GITHUB_TOKEN }}
105+
106+
- name: Install tox
107+
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv --with tox-gh-actions
108+
109+
- name: Setup test suite
110+
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.cfg }}
111+
112+
- name: Run test suite ${{ matrix.cfg }}
113+
run: tox -e ${{ matrix.cfg }}
113114

114115
- name: Upload pytest test results
115116
uses: actions/upload-artifact@v4
116117
with:
117-
name: pytest-results-${{ matrix.python-version }}-${{matrix.django-version}}
118-
path: junit-${{ matrix.python-version }}-${{matrix.django-version}}.xml
118+
name: pytest-results-${{ matrix.cfg }}
119+
path: junit-${{ matrix.cfg }}.xml
119120
if: ${{ always() }}
120121

121122
- name: Upload coverage to Codecov
122123
uses: codecov/codecov-action@v5
123-
if: matrix.python-version == 3.12
124124
continue-on-error: true
125125
with:
126126
env_vars: OS,PYTHON

.mypy.ini

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,10 @@ mypy_path = "$MYPY_CONFIG_FILE_DIR/stubs/:$MYPY_CONFIG_FILE_DIR/src/:"
99
strict = false
1010
ignore_missing_imports = True
1111
namespace_packages = true
12-
;plugins =
13-
; mypy_django_plugin.main
1412

15-
;[mypy.plugins.django-stubs]
16-
;django_settings_module = "bitcaster.config.settings"
17-
18-
[mypy-smart_env.*]
13+
[mypy-sdjango_celery_boost.*]
1914
ignore_missing_imports = True
2015
follow_imports = skip
21-
disable_error_code = type-var,
22-
attr-defined,
23-
truthy-function,
24-
union-attr,
25-
var-annotated,
26-
valid-type,
27-
misc,
28-
attr-defined,
29-
no-any-return,
30-
return,
16+
3117
[mypy-environ.*]
3218
ignore_errors = True

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: trailing-whitespace
7+
- repo: https://github.com/python-jsonschema/check-jsonschema
8+
rev: 0.31.2
9+
hooks:
10+
- id: check-github-workflows
11+
args: [ "--verbose" ]
12+
- repo: https://github.com/tox-dev/tox-ini-fmt
13+
rev: "1.5.0"
14+
hooks:
15+
- id: tox-ini-fmt
16+
args: [ "-p", "lint" ]
17+
- repo: https://github.com/tox-dev/pyproject-fmt
18+
rev: "v2.5.1"
19+
hooks:
20+
- id: pyproject-fmt
21+
- repo: https://github.com/astral-sh/ruff-pre-commit
22+
rev: "v0.9.9"
23+
hooks:
24+
- id: ruff-format
25+
- id: ruff
26+
args: [ "--fix", "--unsafe-fixes", "--exit-non-zero-on-fix" ]
27+
- repo: https://github.com/adamchainz/djade-pre-commit
28+
rev: "1.3.2"
29+
hooks:
30+
- id: djade
31+
args: [ --check, --target-version, "5.1" ]
32+
- repo: meta
33+
hooks:
34+
- id: check-hooks-apply
35+
- id: check-useless-excludes

MANIFEST.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ include CHANGES
33
include LICENSE
44
include MANIFEST.in
55

6-
recursive-include docs *
7-
recursive-include src/ *
6+
recursive-include src *
7+
8+
89
recursive-exclude tests *
10+
recursive-exclude docs *

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99

1010

11-
django-celery-boost is a small Django Abstract Model that provides some useful methods to manage
12-
Models that represents the "context" of a Celery task.
11+
django-celery-boost is a small Django Abstract Model that provides some useful methods to manage
12+
Models that represents the "context" of a Celery task.
1313

1414
## Links
1515

@@ -23,7 +23,7 @@ Models that represents the "context" of a Celery task.
2323
## Features
2424

2525
- Easy control Django Model records to celery task
26-
- Business View of Celery Task
26+
- Business View of Celery Task
2727
- Revoke tasks with to running workers
2828
- Retrieve task position in the queue
2929
- Admin integration to inspect task status (running/result/error)

docs/_theme/css/style.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/best_practices.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
!!! note "General best practices"
55

66
- Always return any "readable" value (es. True)
7-
- Uses [Persistent revokes](https://docs.celeryq.dev/en/stable/userguide/workers.html#worker-persistent-revokes)
7+
- Uses [Persistent revokes](https://docs.celeryq.dev/en/stable/userguide/workers.html#worker-persistent-revokes)
88

99

1010
## Display progress
@@ -24,17 +24,17 @@ Inform what is happening inside your task
2424
## Sentry Integration
2525

2626
In case you use [Sentry](https://sentry.io/), add some useful information
27-
27+
2828
from functools import wraps
29-
30-
def sentry_tags(func: Callable) -> Callable:
29+
30+
def sentry_tags(func: Callable) -> Callable:
3131
@wraps(func)
3232
def wrapper(*args: Any, **kwargs: Any) -> Any:
3333
with configure_scope() as scope:
3434
scope.set_tag("celery", True)
3535
scope.set_tag("celery_task", func.__name__)
3636
return func(*args, **kwargs)
37-
37+
3838
return wrapper
3939

4040
@celery.task(bind=True)

0 commit comments

Comments
 (0)