@@ -2,18 +2,35 @@ name: CI
22
33on : push
44
5+ env :
6+ PYTHON_VERSIONS : ' [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]'
7+
58jobs :
6- static :
7- name : Static analysis
89
10+ set-python-matrix :
11+ runs-on : ubuntu-latest
12+ outputs :
13+ python_versions : ${{ env.PYTHON_VERSIONS }} # Pass the env variable as an output
14+ steps :
15+ - name : Export PYTHON_VERSIONS
16+ run : echo "PYTHON_VERSIONS=$PYTHON_VERSIONS" >> $GITHUB_ENV
17+
18+ static :
19+ name : Static analysis on Python ${{ matrix.python-version }}
920 runs-on : ubuntu-latest
21+ needs : set-python-matrix
22+ strategy :
23+ fail-fast : false # Ensure all matrix jobs run to completion
24+ matrix :
25+ python-version : ${{ fromJSON(needs.set-python-matrix.outputs.python_versions) }}
1026
1127 steps :
1228 - uses : actions/checkout@v2
1329
14- - uses : actions/setup-python@v2
30+ - name : Set up Python ${{ matrix.python-version }}
31+ uses : actions/setup-python@v2
1532 with :
16- python-version : 3.8
33+ python-version : ${{ matrix.python-version }}
1734
1835 - name : Install
1936 run : make install-lint
@@ -22,27 +39,64 @@ jobs:
2239 run : make lint
2340
2441 test :
25- name : Automated testing
26-
42+ name : Testing on Python ${{ matrix.python-version }}
2743 runs-on : ubuntu-latest
44+ needs : set-python-matrix
45+ strategy :
46+ fail-fast : false # Ensure all matrix jobs run to completion
47+ matrix :
48+ python-version : ${{ fromJSON(needs.set-python-matrix.outputs.python_versions) }}
2849
2950 steps :
3051 - uses : actions/checkout@v2
3152
32- - uses : actions/setup-python@v2
53+ - name : Set up Python ${{ matrix.python-version }}
54+ uses : actions/setup-python@v2
3355 with :
34- python-version : 3.8
56+ python-version : ${{ matrix.python-version }}
3557
3658 - name : Install
3759 run : make install-test
3860
3961 - name : Run
4062 run : make coverage
4163
64+ check-static-and-test-status :
65+ name : Verify All Jobs Succeeded
66+ runs-on : ubuntu-latest
67+ needs : [ static, test ] # Ensure all jobs complete before checking
68+ if : always() # This ensures the job runs even if previous jobs failed
69+
70+ steps :
71+ - name : Check Job Results
72+ run : |
73+ # Initialize a flag to track failures
74+ FAILED=0
75+
76+ # Check the result of the 'static' job
77+ if [ "${{ needs.static.result }}" == "failure" ]; then
78+ echo "Static analysis job failed."
79+ FAILED=1
80+ fi
81+
82+ # Check the result of the 'test' job
83+ if [ "${{ needs.test.result }}" == "failure" ]; then
84+ echo "Test job failed."
85+ FAILED=1
86+ fi
87+
88+ # Exit with status 1 if any job failed
89+ if [ "$FAILED" -ne 0 ]; then
90+ echo "One or more jobs failed."
91+ exit 1
92+ else
93+ echo "All jobs passed successfully."
94+ fi
95+
4296 deploy :
4397 name : Build and publish to PyPI
4498
45- needs : [ static, test ]
99+ needs : check- static-and- test-status
46100
47101 if : contains(github.ref, 'tags/v')
48102
0 commit comments