Skip to content

Commit 44401ca

Browse files
use nox to generate job matrix (#3)
1 parent 7d0f184 commit 44401ca

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
3535
- id: set-matrix
3636
run: |
37-
echo "matrix=$(python -m nox -l --json | jq -c '[.[] | select(.name == "tests") | {"python-version": .python, "django-version": .call_spec.django}] | {include: .}')" >> $GITHUB_OUTPUT
37+
python -m nox --session "matrix"
3838
3939
test:
4040
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}

Justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ pup:
2121
# TESTING/TYPES
2222
# ----------------------------------------------------------------------
2323

24+
nox SESSION *ARGS:
25+
python -m nox --session "{{ SESSION }}" -- "{{ ARGS }}"
26+
2427
test *ARGS:
2528
python -m nox --session "test" -- "{{ ARGS }}"
2629

noxfile.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import json
34
import os
45
from pathlib import Path
56

@@ -112,3 +113,21 @@ def lint(session):
112113
def mypy(session):
113114
session.install("django-bird[types] @ .")
114115
session.run("uv", "run", "mypy", ".")
116+
117+
118+
@nox.session
119+
def matrix(session):
120+
sessions_json = session.run("nox", "-l", "--json", silent=True)
121+
sessions = json.loads(sessions_json)
122+
matrix = {
123+
"include": [
124+
{
125+
"python-version": session["python"],
126+
"django-version": session["call_spec"]["django"],
127+
}
128+
for session in sessions
129+
if session["name"] == "tests"
130+
]
131+
}
132+
with Path(os.environ["GITHUB_OUTPUT"]).open("a") as fh:
133+
print(f"matrix={matrix}", file=fh)

0 commit comments

Comments
 (0)