Skip to content

Commit 886ad0e

Browse files
committed
chore: streamline CI with UV and tox-gh-actions
1 parent 32c601a commit 886ad0e

File tree

2 files changed

+41
-66
lines changed

2 files changed

+41
-66
lines changed

.github/workflows/test.yml

Lines changed: 41 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,83 +8,66 @@ concurrency:
88

99
jobs:
1010
test-package:
11-
name: Test Package (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }})
11+
name: Test Package (Python ${{ matrix.python.version }}, Django ${{ matrix.django.version }})
1212
runs-on: ubuntu-latest
1313
permissions:
1414
id-token: write # Required for Codecov OIDC token
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version:
19-
- '3.10'
20-
- '3.11'
21-
- '3.12'
22-
- '3.13'
23-
django-version:
24-
- '4.2'
25-
- '5.0'
26-
- '5.1'
27-
- '5.2'
28-
- 'main'
29-
## include/exclude combinations, typically for the newest and oldest django/python versions.
18+
# needs to included every supported python version
19+
python:
20+
- { version: '3.10', toxenv: 'py310' }
21+
- { version: '3.11', toxenv: 'py311' }
22+
- { version: '3.12', toxenv: 'py312' }
23+
- { version: '3.13', toxenv: 'py313' }
24+
django:
25+
- {version: '4.2', toxenv: 'dj42'}
26+
- {version: '5.0', toxenv: 'dj50'}
27+
- {version: '5.1', toxenv: 'dj51'}
28+
- {version: '5.2', toxenv: 'dj52'}
29+
- {version: 'main', toxenv: 'djmain'}
3030
include:
31-
# https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django
32-
- python-version: '3.8'
33-
django-version: '4.2'
34-
- python-version: '3.9'
35-
django-version: '4.2'
36-
- python-version: '3.14'
37-
django-version: '5.2'
38-
- python-version: '3.14'
39-
django-version: 'main'
31+
# https://docs.djangoproject.com/en/dev/faq/install/#what-python-can-i-use-with-django
32+
- python: { version: '3.8', toxenv: 'py38' }
33+
django: { version: '4.2', toxenv: 'dj42' }
34+
- python: { version: '3.9', toxenv: 'py39' }
35+
django: { version: '4.2', toxenv: 'dj42' }
36+
- python: { version: '3.14', toxenv: 'py314' }
37+
django: { version: '5.2', toxenv: 'dj52' }
38+
- python: { version: '3.14', toxenv: 'py314' }
39+
django: { version: 'main', toxenv: 'djmain' }
4040
exclude:
41-
- python-version: '3.13'
42-
django-version: '5.0'
43-
- python-version: '3.13'
44-
django-version: '4.2'
45-
- python-version: '3.10'
46-
django-version: 'main'
47-
- python-version: '3.11'
48-
django-version: 'main'
41+
- python: { version: '3.13', toxenv: 'py313' }
42+
django: { version: '5.0', toxenv: 'dj50' }
43+
- python: { version: '3.13', toxenv: 'py313' }
44+
django: { version: '4.2', toxenv: 'dj42' }
45+
- python: { version: '3.10', toxenv: 'py310' }
46+
django: { version: 'main', toxenv: 'djmain' }
47+
- python: { version: '3.11', toxenv: 'py311' }
48+
django: { version: 'main', toxenv: 'djmain' }
4949

5050
steps:
5151
- uses: actions/checkout@v4
5252

53-
- name: Set up Python ${{ matrix.python-version }}
53+
- name: Set up Python ${{ matrix.python.version }}
5454
uses: actions/setup-python@v5
5555
with:
56-
python-version: ${{ matrix.python-version }}
56+
python-version: ${{ matrix.python.version }}
5757

58+
- name: Install uv
59+
uses: hynek/setup-cached-uv@v2
5860

59-
- name: Get pip cache dir
60-
id: pip-cache
61-
run: |
62-
echo "::set-output name=dir::$(pip cache dir)"
63-
64-
- name: Cache
65-
uses: actions/cache@v4
66-
with:
67-
path: ${{ steps.pip-cache.outputs.dir }}
68-
key:
69-
${{ matrix.python-version }}-v1-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/tox.ini') }}
70-
restore-keys: |
71-
${{ matrix.python-version }}-v1-
72-
73-
- name: Install Python dependencies
74-
run: |
75-
python -m pip install --upgrade pip
76-
python -m pip install --upgrade tox tox-gh-actions
77-
78-
- name: Tox tests
79-
run: |
80-
tox -v
81-
env:
82-
DJANGO: ${{ matrix.django-version }}
83-
61+
- name: 🧪 Run tox targets for Python ${{ matrix.python.version }}, Django ${{ matrix.django.version }}
62+
# we are not using tox-gh-actions to run our tests because it runs the tests for the django versions
63+
# in sequence rather than in parallel, which slows down the test suite significantly. We use the matrix
64+
# feature of GitHub Actions to run the tests in parallel instead.
65+
run: uvx --with tox-uv tox -v -e ${{ matrix.python.toxenv }}-${{ matrix.django.toxenv }}
66+
8467
- name: Upload coverage
8568
uses: codecov/codecov-action@v5
8669
with:
87-
name: Python ${{ matrix.python-version }}
70+
name: Python ${{ matrix.python.version }}, Django ${{ matrix.django.version }}
8871
use_oidc: true
8972

9073
test-demo-rp:

tox.ini

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ python =
2222
3.13: py313
2323
3.14: py314
2424

25-
[gh-actions:env]
26-
DJANGO =
27-
4.2: dj42
28-
5.0: dj50
29-
5.1: dj51
30-
5.2: dj52
31-
main: djmain
32-
3325
[testenv]
3426
commands =
3527
pytest {posargs}

0 commit comments

Comments
 (0)