Skip to content

Commit

Permalink
bump template to 2024.24 (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadavidthomas authored Aug 1, 2024
1 parent cc90ef8 commit a5bb5c3
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 114 deletions.
3 changes: 2 additions & 1 deletion .copier/package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: v2024.18
_commit: v2024.24
_src_path: gh:westerveltco/django-twc-package
author_email: [email protected]
author_name: Josh Thomas
Expand All @@ -19,5 +19,6 @@ python_versions:
- '3.10'
- '3.11'
- '3.12'
- '3.13'
test_django_main: true
versioning_scheme: SemVer
19 changes: 0 additions & 19 deletions .github/workflows/labels.yml

This file was deleted.

45 changes: 12 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,32 @@ on:
release:
types: [released]

jobs:
check:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
permissions:
contents: write

- name: Check most recent test run on `main`
id: latest-test-result
run: |
echo "result=$(gh run list \
--branch=main \
--workflow=test.yml \
--json headBranch,workflowName,conclusion \
--jq '.[] | select(.headBranch=="main" and .conclusion=="success") | .conclusion' \
| head -n 1)" >> $GITHUB_OUTPUT
- name: OK
if: ${{ (contains(steps.latest-test-result.outputs.result, 'success')) }}
run: exit 0

- name: Fail
if: ${{ !contains(steps.latest-test-result.outputs.result, 'success') }}
run: exit 1
jobs:
test:
uses: ./.github/workflows/test.yml

pypi:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
needs: check
needs: test
environment: release
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: westerveltco/setup-ci-action@v0
- uses: actions/setup-python@v5
with:
python-version: 3.12
extra-python-dependencies: hatch
use-uv: true

- name: Install dependencies
run: |
python -m pip install -U pip uv
python -m uv pip install --system hatch
- name: Build package
run: |
Expand Down
48 changes: 27 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: test

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

concurrency:
group: test-${{ github.head_ref }}
Expand All @@ -20,14 +21,15 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: westerveltco/setup-ci-action@v0
- uses: actions/setup-python@v5
with:
python-version: 3.8
extra-python-dependencies: nox
use-uv: true

- name: Install dependencies
run: |
python -m pip install -U pip uv
python -m uv pip install --system nox
- id: set-matrix
run: |
Expand All @@ -42,14 +44,16 @@ jobs:
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: westerveltco/setup-ci-action@v0
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
extra-python-dependencies: nox
use-uv: true
allow-prereleases: true

- name: Install dependencies
run: |
python -m pip install -U pip uv
python -m uv pip install --system nox
- name: Run tests
run: |
Expand All @@ -71,14 +75,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: westerveltco/setup-ci-action@v0
- uses: actions/setup-python@v5
with:
python-version: 3.8
extra-python-dependencies: nox
use-uv: true

- name: Install dependencies
run: |
python -m pip install -U pip uv
python -m uv pip install --system nox
- name: Run mypy
run: |
Expand All @@ -88,14 +93,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: westerveltco/setup-ci-action@v0
- uses: actions/setup-python@v5
with:
python-version: 3.8
extra-python-dependencies: nox
use-uv: true

- name: Install dependencies
run: |
python -m pip install -U pip uv
python -m uv pip install --system nox
- name: Run coverage
run: |
Expand Down
53 changes: 31 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,77 +18,86 @@ and this project attempts to adhere to [Semantic Versioning](https://semver.org/

## [Unreleased]

### Added

- Support for Python 3.13.

### Changed

- Bumped `django-twc-package` template version to 2024.24.
- Refactored how app settings are accessed within library to use a frozen `dataclass`.

## [0.3.2]

### Added

- Added a `py.typed` file for static type checkers.
- Added a `py.typed` file for static type checkers.

## [0.3.1]

### Fixed

- Correctly JSON serialize `Task` kwargs when going from the in-memory representation contained in the task registry to actual model instances in the database. First reported by [@joshuadavidthomas](https://github.com/joshuadavidthomas) in [#30](https://github.com/westerveltco/django-q-registry/issues/30).
- Correctly JSON serialize `Task` kwargs when going from the in-memory representation contained in the task registry to actual model instances in the database. First reported by [@joshuadavidthomas](https://github.com/joshuadavidthomas) in [#30](https://github.com/westerveltco/django-q-registry/issues/30).

## [0.3.0]

### Changed

- Now using v2024.18 of `django-twc-package`.
- Now using v2024.18 of `django-twc-package`.

### Removed

- Dropped support for Django 3.2.
- Dropped support for Django 3.2.

## [0.2.1]

### Added

- Added a `TaskRegistry.created_tasks` attribute to store the `Task` instances created by the `TaskRegistry`.
- Added a `TaskRegistry.created_tasks` attribute to store the `Task` instances created by the `TaskRegistry`.

### Changed

- Now using v2024.12 of `django-twc-package`.
- Now using v2024.12 of `django-twc-package`.

### Fixed

- Fixed a bug in the `setup_periodic_tasks` management command where newly created tasks via `Task.objects.create_from_registry` were immediately deleted via `Task.objects.delete_dangling_objects`. Newly created tasks are now added to the `TaskRegistry.created_tasks` attribute and are only deleted if they are not in the `TaskRegistry.created_tasks` attribute.
- Fixed a bug in the `setup_periodic_tasks` management command where newly created tasks via `Task.objects.create_from_registry` were immediately deleted via `Task.objects.delete_dangling_objects`. Newly created tasks are now added to the `TaskRegistry.created_tasks` attribute and are only deleted if they are not in the `TaskRegistry.created_tasks` attribute.

## [0.2.0]

### Added

- Refactored the `django_q_registry.registry.Task` dataclass into a `django_q_registry.models.Task` Django model. This should make it more flexible and robust for registering tasks and the associated `django_q.models.Schedule` instances.
- Refactored the `django_q_registry.registry.Task` dataclass into a `django_q_registry.models.Task` Django model. This should make it more flexible and robust for registering tasks and the associated `django_q.models.Schedule` instances.

### Changed

- Now using [`django-twc-package`](https://github.com/westerveltco/django-twc-package) template for repository and package structure.
- The default for the `Q_REGISTRY["PERIOIDIC_TASK_SUFFIX"]` app setting has been changed from `"- CRON"` to `"- QREGISTRY"`.
- All database logic has been moved from the `TaskRegistry` to the `setup_periodic_tasks` management command.
- GitHub Actions `test` workflow now uses the output of `nox -l --json` to dynamically generate the test matrix.
- Now using [`django-twc-package`](https://github.com/westerveltco/django-twc-package) template for repository and package structure.
- The default for the `Q_REGISTRY["PERIOIDIC_TASK_SUFFIX"]` app setting has been changed from `"- CRON"` to `"- QREGISTRY"`.
- All database logic has been moved from the `TaskRegistry` to the `setup_periodic_tasks` management command.
- GitHub Actions `test` workflow now uses the output of `nox -l --json` to dynamically generate the test matrix.

### Fixed

- Fixed a bug in the hashing of a `Task` where the `hash` function was passed unhashable values (e.g. a `dict`). Thanks to [@Tobi-De](https://github.com/Tobi-De) for the bug report ([#6](https://github.com/westerveltco/django-q-registry/issues/6)).
- Fixed a bug in the hashing of a `Task` where the `hash` function was passed unhashable values (e.g. a `dict`). Thanks to [@Tobi-De](https://github.com/Tobi-De) for the bug report ([#6](https://github.com/westerveltco/django-q-registry/issues/6)).

## [0.1.0]

Initial release!

### Added

- Initial documentation.
- Initial tests.
- Initial CI/CD (GitHub Actions).
- A registry for Django Q2 periodic tasks.
- `registry.register` function for registering periodic tasks with a convenience decorator `register_task`.
- A `TASKS` setting for registering periodic tasks from Django settings.
- Autodiscovery of periodic tasks from a Django project's `tasks.py` files.
- A `setup_periodic_tasks` management command for setting up periodic tasks in the Django Q2 broker.
- Initial documentation.
- Initial tests.
- Initial CI/CD (GitHub Actions).
- A registry for Django Q2 periodic tasks.
- `registry.register` function for registering periodic tasks with a convenience decorator `register_task`.
- A `TASKS` setting for registering periodic tasks from Django settings.
- Autodiscovery of periodic tasks from a Django project's `tasks.py` files.
- A `setup_periodic_tasks` management command for setting up periodic tasks in the Django Q2 broker.

### New Contributors

- Josh Thomas <[email protected]> (maintainer)
- Josh Thomas <[email protected]> (maintainer)

[unreleased]: https://github.com/westerveltco/django-q-registry/compare/v0.3.2...HEAD
[0.1.0]: https://github.com/westerveltco/django-q-registry/releases/tag/v0.1.0
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ A Django app to register periodic Django Q tasks.

## Requirements

- Python 3.8, 3.9, 3.10, 3.11, 3.12
- Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
- Django 4.2, 5.0
- Django Q2 1.4.3+
- This package has only been tested with the Django ORM broker.

## Getting Started
## Installation

1. Install the package from PyPI:

Expand All @@ -34,7 +34,7 @@ INSTALLED_APPS = [
]
```

## Usage
## Getting Started

### Registering Periodic Tasks

Expand Down
3 changes: 2 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
PY310 = "3.10"
PY311 = "3.11"
PY312 = "3.12"
PY_VERSIONS = [PY38, PY39, PY310, PY311, PY312]
PY313 = "3.13"
PY_VERSIONS = [PY38, PY39, PY310, PY311, PY312, PY313]
PY_DEFAULT = PY_VERSIONS[0]
PY_LATEST = PY_VERSIONS[-1]

Expand Down
24 changes: 21 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython"
]
dependencies = ["django>=4.2", "django_q2>=1.4.3"]
Expand Down Expand Up @@ -48,7 +49,8 @@ dev = [
"pytest-django",
"pytest-randomly",
"pytest-reverse",
"pytest-xdist"
"pytest-xdist",
"ruff"
]
docs = [
"cogapp",
Expand Down Expand Up @@ -102,7 +104,12 @@ django_settings_module = "tests.settings"
strict_settings = false

[tool.djlint]
blank_line_after_tag = "endblock,endpartialdef,extends,load"
blank_line_before_tag = "block,partialdef"
custom_blocks = "partialdef"
ignore = "H031" # Don't require `meta` tag keywords
indent = 2
profile = "django"

[tool.hatch.build]
exclude = [".*", "Justfile"]
Expand All @@ -115,7 +122,13 @@ path = "src/django_q_registry/__init__.py"

[tool.mypy]
check_untyped_defs = true
exclude = "docs/.*\\.py$"
exclude = [
"docs",
"tests",
"migrations",
"venv",
".venv"
]
mypy_path = "src/"
no_implicit_optional = true
plugins = ["mypy_django_plugin.main"]
Expand All @@ -126,7 +139,12 @@ warn_unused_ignores = true
[[tool.mypy.overrides]]
ignore_errors = true
ignore_missing_imports = true
module = ["django_q.*", "django_q_registry.*.migrations.*", "tests.*"]
module = [
"*.migrations.*",
"django_q.*",
"docs.*",
"tests.*"
]

[tool.mypy_django_plugin]
ignore_missing_model_attributes = true
Expand Down
Loading

0 comments on commit a5bb5c3

Please sign in to comment.