Skip to content

Commit

Permalink
Release v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jcass77 committed Sep 28, 2024
2 parents e7cd5ef + 5313f24 commit 40139e1
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 78 deletions.
112 changes: 55 additions & 57 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,60 @@
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-latest
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 reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
flags: unittests
env_vars: TOXENV, PYTHON, DJANGO
fail_ci_if_error: true
verbose: true
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Jarek Glowacki <jarekwg@gmail.com>
- Stas Kaledin <staskaledin@gmail.com>
- John Cass <john.cass77@gmail.com>
- JAEGYUN JUNG <twiecgoddessana1229@gmail.com>
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
16 changes: 16 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

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

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

**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 dependencies to latest available versions.
- 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)

**Fixes**
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 = tests/
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
8 changes: 4 additions & 4 deletions requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# Testing
# ------------------------------------------------------------------------------
pytest~=6.2 # https://github.com/pytest-dev/pytest
tox~=4.19 # https://github.com/tox-dev/tox
pytest~=7.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
# ------------------------------------------------------------------------------
django # https://www.djangoproject.com/
django-coverage-plugin~=2.0 # https://github.com/nedbat/django_coverage_plugin
pytest-django~=4.5 # https://github.com/pytest-dev/pytest-django
django-coverage-plugin~=3.1 # https://github.com/nedbat/django_coverage_plugin
pytest-django~=4.9 # https://github.com/pytest-dev/pytest-django
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
20 changes: 20 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[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-cov
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 --cov=./ --cov-report=xml

0 comments on commit 40139e1

Please sign in to comment.