Skip to content

Commit 682cb23

Browse files
committed
Fix matrix configuration
1 parent 7878b4f commit 682cb23

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

.github/workflows/pytest.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,21 @@ env:
3232
jobs:
3333
setup:
3434
runs-on: "ubuntu-latest"
35-
strategy:
36-
matrix:
37-
python-version: ["3.10", "3.14"]
38-
runner: ["ubuntu-latest"]
39-
4035
steps:
41-
- name: Check conditions
42-
id: conditions
43-
run: echo "run-tests=${{ github.ref == 'refs/heads/main' || (matrix.runner == 'ubuntu-20.04' && matrix.python-version == '3.10') }}" >> "$GITHUB_OUTPUT"
44-
36+
- name: Create config output
37+
id: config
38+
run: |
39+
py_min="3.10"
40+
py_max="3.14"
41+
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
42+
python_versions=$(jq -c -n --arg py_min $py_min --arg py_max $py_max '{version: [ $py_min, $py_max ]}')
43+
else
44+
python_versions=$(jq -c -n --arg py_min $py_min '{version: [ $py_min ]}')
45+
fi
46+
echo "${python_versions}"
47+
echo "python-versions=${python_versions}" >> "$GITHUB_OUTPUT"
4548
outputs:
46-
python-version: ${{ matrix.python-version }}
47-
runner: ${{ matrix.runner }}
48-
run-tests: ${{ steps.conditions.outputs.run-tests }}
49+
python-versions: ${{ steps.config.outputs.python-versions }}
4950

5051
# create a test matrix based on all python files in /tests
5152
list_tests:
@@ -63,14 +64,15 @@ jobs:
6364
tests: ${{ steps.list_tests.outputs.tests }}
6465

6566
test:
66-
name: Run ${{matrix.test}} with Python ${{ needs.setup.outputs.python-version }} on ${{ needs.setup.outputs.runner }}
67+
name: Run ${{matrix.test}} with Python ${{ matrix.python-version }} on ubuntu-latest
6768
needs: [setup, list_tests]
68-
if: ${{ needs.setup.outputs.run-tests == 'true' }}
6969
runs-on:
7070
- runs-on=${{ github.run_id }}-run-test
7171
- runner=4cpu-linux-x64
7272
strategy:
73-
matrix: ${{ fromJson(needs.list_tests.outputs.tests) }}
73+
matrix:
74+
python-version: ${{ fromJson(needs.setup.outputs.python-versions).version }}
75+
test: ${{ fromJson(needs.list_tests.outputs.tests).test }}
7476
fail-fast: false # run all tests even if one fails
7577
steps:
7678
- name: go to subdirectory and change nextflow workdir
@@ -82,10 +84,10 @@ jobs:
8284
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
8385
name: Check out source-code repository
8486

85-
- name: Set up Python ${{ needs.setup.outputs.python-version }}
87+
- name: Set up Python ${{ matrix.python-version }}
8688
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6
8789
with:
88-
python-version: ${{ needs.setup.outputs.python-version }}
90+
python-version: ${{ matrix.python-version }}
8991
cache: "pip"
9092
token: ${{ secrets.GITHUB_TOKEN }}
9193

0 commit comments

Comments
 (0)