Skip to content

Commit

Permalink
Release v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TGoddessana committed Sep 25, 2024
2 parents e7cd5ef + 842fd58 commit 359ee48
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 76 deletions.
106 changes: 49 additions & 57 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,54 @@
name: Python package

on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
push:
branches: [ develop ]
pull_request:
branches: [ develop ]

jobs:
lint:
name: Check code style
runs-on: ubuntu-latest
container: python:3-slim
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 black
- name: Blacken code
run: black . --safe --quiet
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# 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
test:
name: Test (Python, Django)
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python-version: [ 3.8, 3.9, "3.10" ]
django-version: [ "3.2", "4.0" ]
env:
PYTHON: ${{ matrix.python-version }}
DJANGO: ${{ matrix.django-version }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade django~=${{ matrix.django-version }}
if [ -f requirements/local.txt ]; then pip install -r requirements/local.txt; fi
- name: Test with pytest and update coverage
run: |
coverage run -m pytest
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
flags: unittests
env_vars: PYTHON, DJANGO
fail_ci_if_error: true
verbose: true
lint:
name: Check code style
runs-on: ubuntu-latest
container: python:3-slim
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 black
- name: Blacken code
run: black . --safe --quiet
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# 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
tests:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-20.04
strategy:
matrix:
python-version:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'requirements/*.txt'
- name: Upgrade packaging tools
run: python -m pip install --upgrade pip setuptools virtualenv wheel
- name: Install dependencies
run: python -m pip install --upgrade codecov tox
- name: Run tox targets for ${{ matrix.python-version }}
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d . | cut -f 1 -d '-')
- name: Upload coverage
run: |
codecov -e TOXENV,DJANGO
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Jarek Glowacki <[email protected]>
- Stas Kaledin <[email protected]>
- John Cass <[email protected]>
- JAEGYUN JUNG <[email protected]>
11 changes: 6 additions & 5 deletions django_apscheduler/jobstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def update_job(self, job: AppSchedulerJob):
# Acquire lock for update
with transaction.atomic():
try:
db_job = DjangoJob.objects.get(id=job.id)
db_job = DjangoJob.objects.select_for_update().get(id=job.id)

db_job.next_run_time = get_django_internal_datetime(job.next_run_time)
db_job.job_state = pickle.dumps(
Expand All @@ -262,10 +262,11 @@ def update_job(self, job: AppSchedulerJob):

@util.retry_on_db_operational_error
def remove_job(self, job_id: str):
try:
DjangoJob.objects.get(id=job_id).delete()
except DjangoJob.DoesNotExist:
raise JobLookupError(job_id)
with transaction.atomic():
try:
DjangoJob.objects.select_for_update().get(id=job_id).delete()
except DjangoJob.DoesNotExist:
raise JobLookupError(job_id)

@util.retry_on_db_operational_error
def remove_all_jobs(self):
Expand Down
14 changes: 14 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Changelog

This changelog is used to track all major changes to django-apscheduler.

## v0.7.0(2024-09-24)

**Enhancements**
- Drop support for Python 3.8 and Django 3.2.
- Add support for Python 3.9 to 3.12, Django 4.2 to 5.1
- Bump pytest to >7, remove pytest-pythonpath as it is no longer needed.
- Add tox.ini file to run tests against all supported versions of Python and Django.
- Update CI configuration to use tox.

**Fixes**

- Take a database lock before updating / deleting job store entries to prevent duplicate key violation errors (thanks
@calledbert).

## v0.6.2 (2022-03-06)

Expand Down
6 changes: 1 addition & 5 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
[pytest]
pythonpath = .
python_files = tests.py test_*.py *_tests.py

;https://github.com/bigsassy/pytest-pythonpath#usage
python_paths = tests/

addopts = --ds=tests.settings

norecursedirs = django_apscheduler
4 changes: 2 additions & 2 deletions requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

# Testing
# ------------------------------------------------------------------------------
pytest~=6.2 # https://github.com/pytest-dev/pytest
tox==4.19.0 # https://github.com/tox-dev/tox
pytest>7.0.0 # https://github.com/pytest-dev/pytest
pytest-sugar~=0.9 # https://github.com/Frozenball/pytest-sugar
pytest-pythonpath~=0.7 # https://github.com/bigsassy/pytest-pythonpath

# Django
# ------------------------------------------------------------------------------
Expand Down
12 changes: 7 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="django-apscheduler",
version="0.6.2",
version="0.7.0",
description="APScheduler for Django",
long_description=long_description,
long_description_content_type="text/markdown",
Expand All @@ -26,17 +26,19 @@
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
],
keywords="django apscheduler django-apscheduler",
packages=find_packages(exclude=("tests",)),
install_requires=[
"django>=3.2",
"django>=4.2",
"apscheduler>=3.2,<4.0",
],
zip_safe=False,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_jobstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def test_update_job_does_retry_on_db_operational_error(self, jobstore, create_jo
with mock.patch.object(db.connection, "close") as close_mock:
with pytest.raises(db.OperationalError, match="Some DB-related error"):
with mock.patch(
"django_apscheduler.jobstores.DjangoJob.objects.get",
"django_apscheduler.jobstores.DjangoJob.objects.select_for_update",
side_effect=conftest.raise_db_operational_error,
):
jobstore.update_job(job)
Expand All @@ -249,7 +249,7 @@ def test_remove_job_does_retry_on_db_operational_error(self, jobstore):
with mock.patch.object(db.connection, "close") as close_mock:
with pytest.raises(db.OperationalError, match="Some DB-related error"):
with mock.patch(
"django_apscheduler.jobstores.DjangoJob.objects.get",
"django_apscheduler.jobstores.DjangoJob.objects.select_for_update",
side_effect=conftest.raise_db_operational_error,
):
jobstore.remove_job("some job")
Expand Down
19 changes: 19 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tox]
envlist =
{py39}-{django42}
{py310}-{django42,django50,django51,djangomain}
{py311}-{django42,django50,django51,djangomain}
{py312}-{django42,django50,django51,djangomain}

[testenv]
setenv =
PYTHONPATH = {toxinidir}
deps =
pytest
pytest-django
django42: django>=4.2,<5.0
django50: django>=5.0,<5.1
django51: django>=5.1,<5.2
djangomain: https://github.com/django/django/archive/main.tar.gz
commands =
pytest

0 comments on commit 359ee48

Please sign in to comment.