Skip to content

Commit e108420

Browse files
committed
chore: streamline CI with UV and tox-gh-actions
1 parent 27e8773 commit e108420

File tree

2 files changed

+37
-61
lines changed

2 files changed

+37
-61
lines changed

.github/workflows/test.yml

Lines changed: 37 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,78 +8,62 @@ 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'
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'}
2930
include:
30-
# https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django
31-
- python-version: '3.8'
32-
django-version: '4.2'
33-
- python-version: '3.9'
34-
django-version: '4.2'
35-
- python-version: '3.14'
36-
django-version: '5.2'
37-
- python-version: '3.14'
38-
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' }
3940
exclude:
40-
- python-version: '3.13'
41-
django-version: '5.0'
42-
- python-version: '3.13'
43-
django-version: '4.2'
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' }
4445

4546
steps:
4647
- uses: actions/checkout@v4
4748

48-
- name: Set up Python ${{ matrix.python-version }}
49+
- name: Set up Python ${{ matrix.python.version }}
4950
uses: actions/setup-python@v5
5051
with:
51-
python-version: ${{ matrix.python-version }}
52+
python-version: ${{ matrix.python.version }}
5253

54+
- name: Install uv
55+
uses: hynek/setup-cached-uv@v2
5356

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

8569
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)