| 1 |
name: django-cte tests |
| 2 |
on: |
| 3 |
push: |
| 4 |
branches: [main] |
| 5 |
pull_request: |
| 6 |
branches: [main] |
| 7 |
workflow_dispatch: |
| 8 |
|
| 9 |
jobs: |
| 10 |
configure: |
| 11 |
runs-on: ubuntu-latest |
| 12 |
steps: |
| 13 |
- uses: actions/checkout@v4 |
| 14 |
- name: Read Python versions from pyproject.toml |
| 15 |
id: read-python-versions |
| 16 |
# produces output like: python_versions=[ "3.9", "3.10", "3.11", "3.12" ] |
| 17 |
run: >- |
| 18 |
echo "python_versions=$( |
| 19 |
grep -oP '(?<=Language :: Python :: )\d\.\d+' pyproject.toml |
| 20 |
| jq --raw-input . |
| 21 |
| jq --slurp . |
| 22 |
| tr '\n' ' ' |
| 23 |
)" >> $GITHUB_OUTPUT |
| 24 |
- name: Read Django versions from pyproject.toml |
| 25 |
id: read-django-versions |
| 26 |
# django_versions=[ "Django~=4.2.0", "Django~=5.1.0", "Django~=5.2.0" ] |
| 27 |
run: >- |
| 28 |
echo "django_versions=$( |
| 29 |
grep -oP '(?<=Framework :: Django :: )\d+\.\d+' pyproject.toml |
| 30 |
| sed -E 's/(.+)/Django~=\1.0/' |
| 31 |
| jq --raw-input . |
| 32 |
| jq --slurp . |
| 33 |
| tr '\n' ' ' |
| 34 |
)" >> $GITHUB_OUTPUT |
| 35 |
outputs: |
| 36 |
python_versions: ${{ steps.read-python-versions.outputs.python_versions }} |
| 37 |
django_versions: ${{ steps.read-django-versions.outputs.django_versions }} |
| 38 |
|
| 39 |
tests: |
| 40 |
needs: [configure] |
| 41 |
runs-on: ubuntu-latest |
| 42 |
strategy: |
| 43 |
fail-fast: false |
| 44 |
matrix: |
| 45 |
python: ${{ fromJSON(needs.configure.outputs.python_versions) }} |
| 46 |
django: ${{ fromJSON(needs.configure.outputs.django_versions) }} |
| 47 |
exclude: |
| 48 |
- {python: '3.10', django: 'Django~=6.0.0'} |
| 49 |
- {python: '3.11', django: 'Django~=6.0.0'} |
| 50 |
- {python: '3.10', django: 'Django~=6.1.0'} |
| 51 |
- {python: '3.11', django: 'Django~=6.1.0'} |
| 52 |
env: |
| 53 |
allowed_python_failure: '3.14' |
| 54 |
services: |
| 55 |
postgres: |
| 56 |
image: postgres:latest |
| 57 |
env: |
| 58 |
POSTGRES_DB: postgres |
| 59 |
POSTGRES_PASSWORD: postgres |
| 60 |
POSTGRES_USER: postgres |
| 61 |
ports: |
| 62 |
- 5432:5432 |
| 63 |
options: >- |
| 64 |
--health-cmd pg_isready |
| 65 |
--health-interval 10s |
| 66 |
--health-timeout 5s |
| 67 |
--health-retries 5 |
| 68 |
steps: |
| 69 |
- uses: actions/checkout@v4 |
| 70 |
- uses: astral-sh/setup-uv@v6 |
| 71 |
with: |
| 72 |
version: '>=0.7' |
| 73 |
python-version: ${{ matrix.python }} |
| 74 |
- name: Setup |
| 75 |
run: | |
| 76 |
uv sync --locked --no-install-package=django |
| 77 |
uv pip install "${{ matrix.django }}" |
| 78 |
- name: Run tests on PostgreSQL |
| 79 |
env: |
| 80 |
DB_SETTINGS: >- |
| 81 |
{ |
| 82 |
"ENGINE":"django.db.backends.postgresql_psycopg2", |
| 83 |
"NAME":"django_cte", |
| 84 |
"USER":"postgres", |
| 85 |
"PASSWORD":"postgres", |
| 86 |
"HOST":"localhost", |
| 87 |
"PORT":"5432" |
| 88 |
} |
| 89 |
run: .venv/bin/pytest -v |
| 90 |
continue-on-error: ${{ matrix.python == env.allowed_python_failure }} |
| 91 |
- name: Run tests on SQLite |
| 92 |
run: .venv/bin/pytest -v |
| 93 |
continue-on-error: ${{ matrix.python == env.allowed_python_failure }} |
| 94 |
- name: Check style |
| 95 |
run: .venv/bin/ruff check |