Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/test-coverage/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ runs:
repo-token: ${{ inputs.repoToken }}
repo-token-user-login: 'github-actions[bot]'
allow-repeats: true
update-only: true
89 changes: 65 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,82 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package
name: Release

on:
release:
types: [published]
push:
tags:
- '*.*.*'

env:
# Change these for your project's URLs
PYPI_URL: https://pypi.org/p/django-tasks-scheduler
PYPI_TEST_URL: https://test.pypi.org/p/django-tasks-scheduler

jobs:
publish:

build:
name: Build distribution 📦
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache-dependency-path: poetry.lock
python-version: "3.12"
- name: Install pypa/build
run:
python3 -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: ${{ env.PYPI_URL }}
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest

- name: Build package
run: python -m build
environment:
name: testpypi
url: ${{ env.PYPI_TEST_URL }}

- name: Publish package to pypi
uses: pypa/[email protected]
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
repository-url: https://test.pypi.org/legacy/
skip-existing: true
26 changes: 21 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Django CI

on:
pull_request_target:
pull_request:
branches:
- master
push:
Expand Down Expand Up @@ -30,17 +30,17 @@ jobs:
test:
needs: [ 'flake8' ]
runs-on: ubuntu-latest
name: "Run tests ${{ matrix.python-version }}/${{ matrix.django-version }}/${{ matrix.fake-redis }}"
name: "Run tests ${{ matrix.python-version }}/${{ matrix.django-version }}/${{ matrix.broker }}"
strategy:
max-parallel: 6
matrix:
python-version: [ '3.10', '3.11', '3.12' ]
django-version: [ '5.0.7', '5.1.1' ]
fake-redis: ['True', 'False']
broker: [ 'redis', 'fakeredis', 'valkey' ]
include:
- python-version: '3.12'
django-version: '5.1.1'
fake-redis: 'False'
broker: 'redis'
coverage: yes

services:
Expand All @@ -54,6 +54,16 @@ jobs:
--health-timeout 5s
--health-retries 5

valkey:
image: valkey/valkey:8.0
ports:
- 6380:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

outputs:
version: ${{ steps.getVersion.outputs.VERSION }}

Expand Down Expand Up @@ -91,7 +101,12 @@ jobs:
if: ${{ matrix.coverage != 'yes' }}
run: |
cd testproject
export FAKEREDIS=${{ matrix.fake-redis }}
export FAKEREDIS=${{ matrix.broker == 'fakeredis' }}
if [ ${{ matrix.broker == 'valkey' }} == true ]; then
export BROKER_PORT=6380
else
export BROKER_PORT=6379
fi
poetry run python manage.py test scheduler

# Steps for coverage check
Expand All @@ -102,6 +117,7 @@ jobs:
pythonVer: ${{ matrix.python-version }}
djangoVer: ${{ matrix.django-version }}
repoToken: ${{ secrets.GITHUB_TOKEN }}

- name: Create coverage badge
if: ${{ matrix.coverage == 'yes' && github.event_name == 'push' }}
uses: schneegans/[email protected]
Expand Down
13 changes: 13 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## v2.1.0 🌈

### 🚀 Features

- Support for custom job-class for every worker, using `--job-class` option in `rqworker` command.
- Support for integrating with sentry, using `--sentry-dsn`, `--sentry-debug`, and `--sentry-ca-certs` options in
`rqworker` command.
- Support for using ValKey as broker instead of redis.

### 🧰 Maintenance

- Refactor settings module.

## v2.0.0 🌈

### Breaking Changes
Expand Down
41 changes: 39 additions & 2 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,47 @@ If no queues are specified, will run on default queue only.
All queues must have the same redis settings on `SCHEDULER_QUEUES`.

```shell
python manage.py rqworker queue1 queue2 queue3

usage: manage.py rqworker [-h] [--pid PIDFILE] [--burst] [--name NAME] [--worker-ttl WORKER_TTL] [--max-jobs MAX_JOBS]
[--fork-job-execution FORK_JOB_EXECUTION] [--job-class JOB_CLASS] [--sentry-dsn SENTRY_DSN] [--sentry-debug]
[--sentry-ca-certs SENTRY_CA_CERTS] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH]
[--traceback] [--no-color] [--force-color] [--skip-checks]
[queues ...]

positional arguments:
queues The queues to work on, separated by space, all queues should be using the same redis

options:
-h, --help show this help message and exit
--pid PIDFILE file to write the worker`s pid into
--burst Run worker in burst mode
--name NAME Name of the worker
--worker-ttl WORKER_TTL
Default worker timeout to be used
--max-jobs MAX_JOBS Maximum number of jobs to execute before terminating worker
--fork-job-execution FORK_JOB_EXECUTION
Fork job execution to another process
--job-class JOB_CLASS
Jobs class to use
--sentry-dsn SENTRY_DSN
Sentry DSN to use
--sentry-debug Enable Sentry debug mode
--sentry-ca-certs SENTRY_CA_CERTS
Path to CA certs file
--version Show program's version number and exit.
-v {0,1,2,3}, --verbosity {0,1,2,3}
Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
--settings SETTINGS The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided, the
DJANGO_SETTINGS_MODULE environment variable will be used.
--pythonpath PYTHONPATH
A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
--traceback Raise on CommandError exceptions.
--no-color Don't colorize the command output.
--force-color Force colorization of the command output.
--skip-checks Skip system checks.
```



## export

Export all scheduled tasks from django db to json/yaml format.
Expand Down
7 changes: 7 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ SCHEDULER_CONFIG = {
'DEFAULT_RESULT_TTL': 500,
'DEFAULT_TIMEOUT': 300, # 5 minutes
'SCHEDULER_INTERVAL': 10, # 10 seconds
'BROKER': 'redis',
}
SCHEDULER_QUEUES = {
'default': {
Expand Down Expand Up @@ -67,6 +68,12 @@ Enables checking stats using API token.

Default: no tokens allowed.

### SCHEDULER_CONFIG: `BROKER`

Broker driver to use for the scheduler. Can be `redis` or `valkey` or `fakeredis`.

Default: `redis`.

### `SCHEDULER_QUEUES`

You can configure the queues to work with.
Expand Down
12 changes: 10 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,24 @@ sequenceDiagram

## Reporting issues or Features requests

Please report issues via [GitHub Issues](https://github.com/django-commons/django-tasks-scheduler/issues) .
Please report issues via [GitHub Issues][6] .

---

## Acknowledgements

A lot of django-admin views and their tests were adopted from [django-rq](https://github.com/rq/django-rq).
A lot of django-admin views and their tests were adopted from [django-rq][7].

[1]:https://github.com/django-commons/django-tasks-scheduler/actions/workflows/test.yml/badge.svg

[2]:https://github.com/django-commons/django-tasks-scheduler/actions/workflows/test.yml

[3]:https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/cunla/b756396efb895f0e34558c980f1ca0c7/raw/django-tasks-scheduler-4.json

[4]:https://img.shields.io/pypi/dm/django-tasks-scheduler

[5]:https://pypi.org/project/django-tasks-scheduler/

[6]:https://github.com/django-commons/django-tasks-scheduler/issues

[7]:https://github.com/rq/django-rq
1 change: 1 addition & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
'DEFAULT_RESULT_TTL': 500,
'DEFAULT_TIMEOUT': 300, # 5 minutes
'SCHEDULER_INTERVAL': 10, # 10 seconds
'BROKER': 'redis', #
}
```

Expand Down
Loading
Loading