Skip to content

Commit 4407a0d

Browse files
committed
ci: configure pr's matrix from hatch env json file
1 parent 47ccdad commit 4407a0d

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

.github/workflows/hatch-matrix.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"include": [
3+
{
4+
"hatch-env-name": "test.py3.10-numpy-version=1",
5+
"python-version": "3.10"
6+
},
7+
{
8+
"hatch-env-name": "test.py3.10-numpy-version=2",
9+
"python-version": "3.10"
10+
},
11+
{
12+
"hatch-env-name": "test.py3.11-numpy-version=1",
13+
"python-version": "3.11"
14+
},
15+
{
16+
"hatch-env-name": "test.py3.11-numpy-version=2",
17+
"python-version": "3.11"
18+
},
19+
{
20+
"hatch-env-name": "test.py3.12-numpy-version=1",
21+
"python-version": "3.12"
22+
},
23+
{
24+
"hatch-env-name": "test.py3.12-numpy-version=2",
25+
"python-version": "3.12"
26+
},
27+
{
28+
"hatch-env-name": "test.py3.13-numpy-version=1",
29+
"python-version": "3.13"
30+
},
31+
{
32+
"hatch-env-name": "test.py3.13-numpy-version=2",
33+
"python-version": "3.13"
34+
}
35+
]
36+
}

.github/workflows/pr.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@ on:
66
branches: ["main", "v1"]
77

88
jobs:
9+
prepare-matrix:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
matrix: ${{ steps.set-matrix.outputs.matrix }}
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set matrix
16+
id: set-matrix
17+
run: echo "matrix=$(cat .github/workflows/hatch-matrix.json | jq -c )" >> $GITHUB_OUTPUT
918
test:
1019
runs-on: ubuntu-latest
20+
needs: prepare-matrix
1121
strategy:
1222
fail-fast: false
13-
matrix:
14-
python-version: ["3.10", "3.11", "3.12", "3.13"]
23+
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
1524

1625
steps:
1726
- uses: actions/checkout@v4
@@ -24,6 +33,6 @@ jobs:
2433
python -m pip install --upgrade pip
2534
python -m pip install hatch
2635
- name: Pytest
27-
run: hatch run +py=${{ matrix.python-version }} test:test-cov
36+
run: hatch -e ${{ matrix.hatch-env-name }} run test-cov
2837
- name: Coverage report
29-
run: hatch run +py=${{ matrix.python-version }} test:cov-report
38+
run: hatch run cov-report

0 commit comments

Comments
 (0)