Skip to content
Draft
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
25 changes: 16 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
db_url: [ '', 'postgresql://pg:pgpass@localhost/bdmodels' ]
db-backend: ["sqlt", "pg2", "pg3"]

steps:
- name: Update Sqlite
Expand All @@ -46,11 +46,18 @@ jobs:
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Tox me
run: |
TOXPY="py$( echo ${{ matrix.python-version }} | sed s/\\.// )"
# Skip envs with the wrong Python using TOX_SKIP_ENV var.
# The below constructs, e.g. for py310, the string '(?!py310).*'
# (?!...) is negative lookahead; the expr matches anything which doed _not_
# start with 'py310'; and all the matched envs are excluded, so this ensures
# we only run the envs defined for the given Python.
export TOX_SKIP_ENV='(?!'"${TOXPY}).*"
BDMODELS_DB=${{ matrix.db_url }} tox
TOXDB="${{ matrix.db-backend }}"
# Skip envs with the wrong db-backend using TOX_SKIP_ENV var.
# The below constructs, e.g. for sqlt the string '.*(?<!sqlt)$'
# (?<!...) is negative lookbehind;
# the expr matches anything which does _not_ end with sqlt.
# All the matched envs are excluded, so this ensures
# we only run the envs defined for the given db-backend.
# The missing Python versions are skipped by the invocation flag
export TOX_SKIP_ENV='.*(?<!'"${TOXDB}"')$'
BDMODELS_DB=''
if (echo ${{ matrix.db-backend }} | grep pg > /dev/null); then
BDMODELS_DB='postgresql://pg:pgpass@localhost/bdmodels'
fi
export BDMODELS_DB
tox --skip-missing-interpreters true
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ sphinx-rtd-theme = "~3.0.2"
dj-database-url = "^2.3.0"

[tool.tox]
# Note: Per https://github.com/tox-dev/tox/discussions/3648 the legacy ini cannot be
# replaced by native pyproject.toml without duplicating definitions for factors
# (i.e. explicitly listing combinations of Python and Django etc)
legacy_tox_ini = """
[tox]
envlist = py39-django42, py{310,311,312}-django{42,50,51,52}, py313-django{51,52,main}
envlist = py39-django42-{sqlt,pg2,pg3}, py{310,311,312}-django{42,50,51,52}-{sqlt,pg2,pg3}, py313-django{51,52,main}-{sqlt,pg2,pg3}
isolated_build = True
skipsdist = True

Expand All @@ -53,7 +56,8 @@ deps =
django51: Django>=5.1,<5.2
django52: Django>=5.2,<5.3
djangomain: git+https://github.com/django/django.git@main#egg=django
psycopg2-binary
pg2: psycopg2-binary
pg3: psycopg[binary]
dj-database-url>=2.3.0,<3.0

changedir = test_bdmodels
Expand Down
Loading