|
7 | 7 | branches: [ main ] |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - # Define the job to run before your matrix job |
| 10 | + # -------------------------------------------------------- |
| 11 | + # Collect available Python versions |
| 12 | + # -------------------------------------------------------- |
11 | 13 | get-python-versions: |
12 | 14 | runs-on: ubuntu-latest |
13 | 15 | outputs: |
14 | | - python-matrix: ${{ steps.get-python-versions-action.outputs.latest-python-versions }} |
| 16 | + python-matrix: ${{ steps.trim.outputs.matrix }} |
15 | 17 | steps: |
16 | | - - uses: snok/latest-python-versions@v1 |
17 | | - id: get-python-versions-action |
18 | | - with: |
19 | | - min-version: '3.12' |
| 18 | + - uses: snok/latest-python-versions@v1 |
| 19 | + id: get-python-versions-action |
| 20 | + with: |
| 21 | + min-version: '3.12' |
| 22 | + |
| 23 | + # 👇 keep only major.minor and remove duplicates |
| 24 | + - name: Keep only major.minor |
| 25 | + id: trim |
| 26 | + shell: bash |
| 27 | + run: | |
| 28 | + versions='${{ steps.get-python-versions-action.outputs.latest-python-versions }}' |
| 29 | + # → ["3.13.5","3.12.11", ...] |
| 30 | + matrix=$(echo "$versions" \ |
| 31 | + | jq -c 'map(split(".")[:2] | join(".")) | unique') |
| 32 | + echo "matrix=$matrix" >> "$GITHUB_OUTPUT" |
20 | 33 |
|
| 34 | + # -------------------------------------------------------- |
| 35 | + # Use the trimmed versions list in matrix |
| 36 | + # -------------------------------------------------------- |
21 | 37 | test: |
22 | 38 | needs: [get-python-versions] |
23 | 39 | runs-on: ${{ matrix.operating-system }} |
24 | 40 | strategy: |
25 | 41 | matrix: |
26 | 42 | operating-system: [ ubuntu-latest, windows-latest, macOS-latest ] |
27 | | - # python-version: ${{ fromJson(needs.get-python-versions.outputs.python-matrix) }} |
28 | | - python-version: [3.13.5, 3.12.10] |
29 | | - |
| 43 | + python-version: ${{ fromJson(needs.get-python-versions.outputs.python-matrix) }} |
30 | 44 | continue-on-error: true |
31 | 45 |
|
32 | 46 | steps: |
|
0 commit comments