Skip to content

Commit ae7e94e

Browse files
use nox to generate github job matrix for tests (#133)
1 parent 7679924 commit ae7e94e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-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 "gha_matrix"
3838
3939
test:
4040
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}

noxfile.py

Lines changed: 18 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

@@ -130,3 +131,20 @@ def demo(session):
130131

131132
session.install("django-simple-nav[dev] @ .")
132133
session.run("python", "example/demo.py", "runserver", addrport)
134+
135+
136+
@nox.session
137+
def gha_matrix(session):
138+
sessions = session.run("nox", "-l", "--json", silent=True)
139+
matrix = {
140+
"include": [
141+
{
142+
"python-version": session["python"],
143+
"django-version": session["call_spec"]["django"],
144+
}
145+
for session in json.loads(sessions)
146+
if session["name"] == "tests"
147+
]
148+
}
149+
with Path(os.environ["GITHUB_OUTPUT"]).open("a") as fh:
150+
print(f"matrix={matrix}", file=fh)

0 commit comments

Comments
 (0)