Skip to content

Commit 4809caa

Browse files
committed
Refactor tox workflow matrix into separate step
1 parent 9d74c4d commit 4809caa

File tree

1 file changed

+81
-24
lines changed

1 file changed

+81
-24
lines changed

.github/workflows/tox.yml

Lines changed: 81 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,95 @@ name: Tox Workflow
33
'on':
44
workflow_call:
55
jobs:
6-
tox:
7-
runs-on: ubuntu-latest
8-
strategy:
9-
fail-fast: false
10-
matrix:
11-
environment: [pep8,py3]
12-
python-minor-version: [8,10,12]
13-
is-not-python38:
14-
- ${{
15-
((github.repository == 'stackhpc/kayobe') &&
16-
((github.base_ref == 'stackhpc/2024.1') ||
17-
(github.ref == 'refs/heads/stackhpc/2024.1'))) ||
6+
7+
define-matrix:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
tox-matrix: ${{ steps.matrix.outputs.tox-matrix }}
11+
steps:
12+
- name: Define Tox matrix
13+
id: matrix
14+
env:
15+
PY3_8: ${{
16+
(github.base_ref == 'stackhpc/yoga') ||
17+
(github.ref == 'refs/heads/stackhpc/yoga') ||
18+
(github.base_ref == 'stackhpc/zed') ||
19+
(github.ref == 'refs/heads/stackhpc/zed') ||
20+
(github.base_ref == 'stackhpc/2023.1') ||
21+
(github.ref == 'refs/heads/stackhpc/2023.1') ||
22+
(((github.base_ref == 'stackhpc/2024.1') ||
23+
(github.ref == 'refs/heads/stackhpc/2024.1')) &&
24+
(github.repository != 'stackhpc/kayobe'))
25+
}}
26+
PY3_10: ${{
27+
(github.base_ref == 'stackhpc/zed') ||
28+
(github.ref == 'refs/heads/stackhpc/zed') ||
29+
(github.base_ref == 'stackhpc/2023.1') ||
30+
(github.ref == 'refs/heads/stackhpc/2023.1') ||
31+
(github.base_ref == 'stackhpc/2024.1') ||
32+
(github.ref == 'refs/heads/stackhpc/2024.1') ||
1833
(github.base_ref == 'stackhpc/2025.1') ||
1934
(github.ref == 'refs/heads/stackhpc/2025.1') ||
2035
(github.base_ref == 'stackhpc/master') ||
2136
(github.ref == 'refs/heads/stackhpc/master')
22-
}}
23-
is-primarily-python312:
24-
- ${{
37+
}}
38+
PY3_12: ${{
2539
(github.base_ref == 'stackhpc/2025.1') ||
2640
(github.ref == 'refs/heads/stackhpc/2025.1') ||
2741
(github.base_ref == 'stackhpc/master') ||
2842
(github.ref == 'refs/heads/stackhpc/master')
29-
}}
30-
exclude:
31-
- is-not-python38: true
32-
python-minor-version: 8
33-
- is-primarily-python312: true
34-
environment: pep8
35-
python-minor-version: 10
36-
- is-primarily-python312: false
37-
python-minor-version: 12
43+
}}
44+
PEP8_8: ${{
45+
(github.base_ref == 'stackhpc/yoga') ||
46+
(github.ref == 'refs/heads/stackhpc/yoga')
47+
}}
48+
PEP8_10: ${{
49+
(github.base_ref == 'stackhpc/zed') ||
50+
(github.ref == 'refs/heads/stackhpc/zed') ||
51+
(github.base_ref == 'stackhpc/2023.1') ||
52+
(github.ref == 'refs/heads/stackhpc/2023.1') ||
53+
(github.base_ref == 'stackhpc/2024.1') ||
54+
(github.ref == 'refs/heads/stackhpc/2024.1')
55+
}}
56+
PEP8_12: ${{
57+
(github.base_ref == 'stackhpc/2025.1') ||
58+
(github.ref == 'refs/heads/stackhpc/2025.1') ||
59+
(github.base_ref == 'stackhpc/master') ||
60+
(github.ref == 'refs/heads/stackhpc/master')
61+
}}
62+
run: |
63+
# Create a matrix based on the environment and Python minor version
64+
output="["
65+
if [[ $PY3_8 == 'true' ]]; then
66+
output+="{'environment': 'py3', 'python-minor-version': 8},"
67+
fi
68+
if [[ $PY3_10 == 'true' ]]; then
69+
output+="{'environment': 'py3', 'python-minor-version': 10},"
70+
fi
71+
if [[ $PY3_12 == 'true' ]]; then
72+
output+="{'environment': 'py3', 'python-minor-version': 12},"
73+
fi
74+
if [[ $PEP8_8 == 'true' ]]; then
75+
output+="{'environment': 'pep8', 'python-minor-version': 8},"
76+
fi
77+
if [[ $PEP8_10 == 'true' ]]; then
78+
output+="{'environment': 'pep8', 'python-minor-version': 10},"
79+
fi
80+
if [[ $PEP8_12 == 'true' ]]; then
81+
output+="{'environment': 'pep8', 'python-minor-version': 12},"
82+
fi
83+
# remove trailing comma
84+
output="${output%,}"
85+
output+="]"
86+
echo "tox-matrix=$output" >> $GITHUB_OUTPUT
87+
88+
tox:
89+
runs-on: ubuntu-latest
90+
needs: define-matrix
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
include: ${{ fromJSON(needs.define-matrix.outputs.tox-matrix) }}
3895

3996
name: Tox ${{ matrix.environment }} with Python 3.${{ matrix.python-minor-version }}
4097
steps:

0 commit comments

Comments
 (0)