Skip to content
Closed
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
22 changes: 22 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ DJANGO_SUPPORT_UPLOAD_EXTENSIONS=
# Zero keeps everything. Set a window and schedule `manage.py support_prune`;
# nothing deletes a customer's support history until you run it.
DJANGO_SUPPORT_RETENTION_DAYS=0
DJANGO_FILES_ENABLED=true
# DJANGO_FILES_TRANSPORTS=rest,graph,grpc
# A prefix inside STORAGES["default"], not a filesystem path.
DJANGO_FILES_UPLOAD_PATH=files
# The largest file anybody may upload. Zero means no limit.
DJANGO_FILES_MAX_UPLOAD_MB=10
# Where uploads are stored: `filesystem` (MEDIA_ROOT) or `s3` (needs
# `pip install '.[s3]'` and the bucket settings below).
DJANGO_STORAGE_BACKEND=filesystem
DJANGO_AWS_STORAGE_BUCKET_NAME=
DJANGO_AWS_S3_REGION_NAME=
DJANGO_AWS_S3_ENDPOINT_URL=
DJANGO_AWS_ACCESS_KEY_ID=
DJANGO_AWS_SECRET_ACCESS_KEY=
DJANGO_SHOP_ENABLED=true
# DJANGO_SHOP_TRANSPORTS=rest,graph,grpc
DJANGO_SHOP_CURRENCY=USD
Expand Down Expand Up @@ -268,3 +282,11 @@ DJANGO_WEBSOCKET_ALLOWED_ORIGINS=
DJANGO_SECURE_SSL_REDIRECT=true
DJANGO_SECURE_HSTS_SECONDS=31536000
DJANGO_SECURE_HSTS_PRELOAD=true

# Outgoing webhooks. Deliveries are sent by `manage.py webhooks_deliver`; schedule
# it (every minute, say). See docs/webhooks.md.
DJANGO_WEBHOOKS_ENABLED=true
# DJANGO_WEBHOOKS_TRANSPORTS=rest,graph,grpc
DJANGO_WEBHOOKS_MAX_ATTEMPTS=6
DJANGO_WEBHOOKS_BACKOFF_SECONDS=30
DJANGO_WEBHOOKS_TIMEOUT_SECONDS=10
147 changes: 41 additions & 106 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,116 +1,51 @@
# Runs the tests on a pull request into main — and on nothing else.
# The job lives once in CtrlAltDevelop/ci-workflows (python-test.yml).

name: CI

on:
pull_request:
branches: [main]

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
permissions: {}

jobs:
# Every pull request runs the suite, and a pull request into `main` runs this
# and nothing else: the branch has already been through the whole pipeline on
# its way into `develop`, and repeating the packaging, the wheel smoke test
# and the example tour to merge a reviewed branch buys minutes, not safety.
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- run: python -m pip install -e '.[dev]'
- run: make test
name: Test
uses: CtrlAltDevelop/ci-workflows/.github/workflows/python-test.yml@v1.2.0
permissions:
contents: read
with:
python-version: "3.12"
install: uv venv && uv pip install -e '.[dev]'
test-command: uv run --no-sync make test

# The wallet's safety rests on `select_for_update`, and SQLite compiles that
# away -- so on the default backend the race tests skip and the whole "no
# double withdrawal" claim is untested. This job is the one place it is
# actually exercised: a real Postgres, and the wallet suite run against it.
# Scoped to the wallet rather than the whole suite because row locking is the
# only thing this proves that the job above does not.
# The wallet's row-lock tests need a real PostgreSQL; on SQLite they skip.
locks:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: wallet
POSTGRES_PASSWORD: wallet
POSTGRES_DB: wallet
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DJANGO_DB_ENGINE: django.db.backends.postgresql
DJANGO_DB_NAME: wallet
DJANGO_DB_USER: wallet
DJANGO_DB_PASSWORD: wallet
DJANGO_DB_HOST: localhost
DJANGO_DB_PORT: "5432"
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- run: python -m pip install -e '.[dev]' 'psycopg[binary]'
# `-p no:randomly` because the race tests run real threads against real
# rows: an ordering that leaves a wallet behind from another test is a
# flake nobody can reproduce.
- run: pytest src/apps/wallet -p no:randomly --no-cov
# Fails the job if the race tests were skipped after all -- a silent skip
# here would put this workflow back exactly where it started.
- name: The row-lock tests must actually have run
run: |
# pipefail, or `tee` succeeding would hide pytest failing.
set -o pipefail
pytest src/apps/wallet/tests/test_concurrency.py -p no:randomly --no-cov -q \
| tee /tmp/locks.txt
if grep -qi "skipped" /tmp/locks.txt; then
echo "::error::the row-lock tests skipped, so nothing proved the locks work"
exit 1
fi

# Everything else a merge could break: the linters and the type checker, the
# wheel, and the published generator building and touring a real project.
# Skipped for a pull request into `main`.
verify:
if: github.base_ref != 'main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- run: python -m pip install -e '.[dev]'
- run: make check
- run: make package
- name: Smoke-test the built wheel
run: |
python -m venv /tmp/django-ninja-starter-wheel
/tmp/django-ninja-starter-wheel/bin/pip install dist/*.whl
cd /tmp
/tmp/django-ninja-starter-wheel/bin/django-ninja-starter example-api
/tmp/django-ninja-starter-wheel/bin/pip install -e 'example-api[dev]'
cd example-api
/tmp/django-ninja-starter-wheel/bin/python manage.py startapi example --api-version v2
# `startapi` scaffolds a gRPC service and says so; its stubs do not
# exist until this runs, and `make check` type-checks the import of
# them. Doing it here is the workflow the command itself prints.
/tmp/django-ninja-starter-wheel/bin/python manage.py protos
PATH="/tmp/django-ninja-starter-wheel/bin:$PATH" make check
PATH="/tmp/django-ninja-starter-wheel/bin:$PATH" make test
- name: Build and tour the example project from that wheel
# The wheel's own django-ninja-starter is first on the path here, so
# this is the published generator building the example, not the
# checkout's copy of it.
run: |
/tmp/django-ninja-starter-wheel/bin/python examples/build.py \
--into /tmp/example-tour --rebuild
/tmp/django-ninja-starter-wheel/bin/python examples/walkthrough.py \
--project /tmp/example-tour
name: Row locks (PostgreSQL)
uses: CtrlAltDevelop/ci-workflows/.github/workflows/python-test.yml@v1.2.0
permissions:
contents: read
with:
python-version: "3.12"
postgres: true
install: uv venv && uv pip install -e '.[dev]' 'psycopg[binary]'
env: |
DJANGO_DB_ENGINE=django.db.backends.postgresql
DJANGO_DB_NAME=test_db
DJANGO_DB_USER=test_user
DJANGO_DB_PASSWORD=test_pass
DJANGO_DB_HOST=localhost
DJANGO_DB_PORT=5432
test-command: |
set -o pipefail
uv run --no-sync pytest src/apps/wallet -p no:randomly --no-cov
uv run --no-sync pytest src/apps/wallet/tests/test_concurrency.py -p no:randomly --no-cov -q | tee /tmp/locks.txt
if grep -qi "skipped" /tmp/locks.txt; then
echo "::error::the row-lock tests skipped, so nothing proved the locks work"
exit 1
fi
69 changes: 54 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,69 @@
name: Publish to PyPI
# =============================================================================
# Release: build once, publish to PyPI with trusted publishing.
# =============================================================================
# Runs when a GitHub Release is published; its tag must be v<__version__>.
# No API token exists anywhere: PyPI trusts this
# workflow's OIDC identity, configured once under the project's "Publishing"
# settings (owner CtrlAltDevelop, repo django-ninja-starter, workflow
# release.yml, environment pypi).
#
# The publish job lives in this file on purpose: PyPI's trusted publishing
# does not accept the same job run from the shared reusable workflow
# (CtrlAltDevelop/ci-workflows python-publish.yml); it fails with
# `invalid-publisher`, as it did for mdp-outbox v0.2.0.

name: Release

on:
release:
types: [published]

permissions:
contents: read
permissions: {}

jobs:
publish:
build:
name: Build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/django-ninja-starter
timeout-minutes: 10
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-python@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: "3.12"
- name: Build distributions
- name: Tag matches the package version
run: |
python -m pip install build
python -m build
- name: Publish distributions
uses: pypa/gh-action-pypi-publish@release/v1
version=$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' src/django_ninja_starter/__init__.py)
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
echo "::error::Tag $GITHUB_REF_NAME does not match __version__ $version"
exit 1
fi
- run: uv build
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
if-no-files-found: error

publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
environment:
name: pypi
url: https://pypi.org/project/django-ninja-starter/
permissions:
id-token: write # the OIDC token PyPI exchanges for a short-lived upload credential
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
# Don't fail on a re-run: files PyPI already has are skipped.
skip-existing: true
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project are documented here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project
follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.2.0] - 2026-11-26

### Changed

- **Relicensed from MIT to AGPL-3.0-only.** Releases from 2.2.0 on are under the
GNU Affero General Public License v3; earlier releases keep their MIT license.
- **Releases publish from this repository's own workflow.** PyPI's
trusted publishing rejects the shared reusable publish workflow with
`invalid-publisher`, so the build and publish jobs live in `release.yml`, still run by
publishing a GitHub Release.

## [2.1.1] - 2026-10-15

### Changed
Expand Down
Loading
Loading