Skip to content

Commit c30d341

Browse files
stefanfoulisjuanifioren
authored andcommitted
Run tests in matrix on github
1 parent 348db3c commit c30d341

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

.github/workflows/main.yml

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
name: Django Tests CI
2-
1+
name: "CI"
32
on:
43
push:
54
branches: ["master", "develop"]
65
pull_request:
7-
branches: ["develop"]
6+
7+
concurrency:
8+
group: check-${{ github.ref }}
9+
cancel-in-progress: true
810

911
jobs:
1012
formatting:
13+
name: "Check Code Formatting"
1114
runs-on: ubuntu-latest
1215
steps:
1316
- uses: actions/checkout@v4
@@ -17,6 +20,7 @@ jobs:
1720
- run: "ruff format --check --diff"
1821

1922
linting:
23+
name: "Check Code Linting"
2024
runs-on: ubuntu-latest
2125
steps:
2226
- uses: actions/checkout@v4
@@ -25,24 +29,33 @@ jobs:
2529
args: "--version"
2630
- run: "ruff check --diff"
2731

28-
tests:
32+
test_matrix_prep:
33+
name: "Prepare Test Matrix"
34+
runs-on: ubuntu-latest
35+
outputs:
36+
matrix: "${{ steps.set-matrix.outputs.matrix }}"
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: astral-sh/setup-uv@v3
40+
- run: uv tool install tox
41+
- id: set-matrix
42+
run: |
43+
matrix=$(tox -l | jq -Rc 'select(test("^py\\d+.*django\\d+")) | capture("^py(?<python>\\d+).*django(?<django>\\d+)") | {"python": (.python | tostring | .[0:1] + "." + .[1:]), "django": (.django | tostring | .[0:1] + "." + .[1:])}' | jq -sc '{include: .}')
44+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
45+
46+
test:
47+
name: "Test Django ${{ matrix.django }} | Python ${{ matrix.python }}"
48+
needs: test_matrix_prep
2949
runs-on: ubuntu-latest
50+
strategy:
51+
fail-fast: false
52+
matrix: ${{ fromJson(needs.test_matrix_prep.outputs.matrix) }}
3053
steps:
3154
- uses: actions/checkout@v4
55+
- uses: astral-sh/setup-uv@v3
56+
- run: uv tool install tox
3257
- uses: actions/setup-python@v4
3358
with:
34-
python-version: |
35-
3.8
36-
3.9
37-
3.10
38-
3.11
39-
3.12
40-
3.13
41-
- name: Install tox
42-
run: |
43-
python -m pip install --upgrade pip
44-
pip install tox
59+
python-version: ${{ matrix.python }}
4560
- name: Run tox
46-
# we skip the 'ruff' env here, because we are running it in a separate
47-
# parallel job already
48-
run: tox --skip-env ruff
61+
run: tox run -e py$(echo "${{ matrix.python }}" | tr -d '.')-django$(echo "${{ matrix.django }}" | tr -d '.')

0 commit comments

Comments
 (0)