-
Notifications
You must be signed in to change notification settings - Fork 2
151 lines (114 loc) · 3.69 KB
/
main.yml
File metadata and controls
151 lines (114 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: CI
on: push
env:
DEFAULT_PYTHON_VERSION: "3.14"
PYTHON_VERSIONS: '[ "3.11", "3.12", "3.13", "3.14" ]'
jobs:
set-python-matrix:
runs-on: ubuntu-latest
outputs:
python_versions: ${{ env.PYTHON_VERSIONS }} # Pass the env variable as an output
steps:
- name: Export PYTHON_VERSIONS
run: echo "PYTHON_VERSIONS=$PYTHON_VERSIONS" >> $GITHUB_ENV
static:
name: Static analysis on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: set-python-matrix
env:
PYTHON: ${{ matrix.python-version }}
strategy:
fail-fast: false # Ensure all matrix jobs run to completion
matrix:
python-version: ${{ fromJSON(needs.set-python-matrix.outputs.python_versions) }}
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v6
- name: Install
run: make install-dev
- name: Run
run: make lint
test:
name: Testing on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: set-python-matrix
env:
PYTHON: ${{ matrix.python-version }}
strategy:
fail-fast: false # Ensure all matrix jobs run to completion
matrix:
python-version: ${{ fromJSON(needs.set-python-matrix.outputs.python_versions) }}
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v6
- name: Install
run: make install-dev
- name: Run
run: make coverage
check-static-and-test-status:
name: Verify All Jobs Succeeded
runs-on: ubuntu-latest
needs: [ static, test ] # Ensure all jobs complete before checking
if: always() # This ensures the job runs even if previous jobs failed
steps:
- name: Check Job Results
run: |
# Initialize a flag to track failures
FAILED=0
# Check the result of the 'static' job
if [ "${{ needs.static.result }}" == "failure" ]; then
echo "Static analysis job failed."
FAILED=1
fi
# Check the result of the 'test' job
if [ "${{ needs.test.result }}" == "failure" ]; then
echo "Test job failed."
FAILED=1
fi
# Exit with status 1 if any job failed
if [ "$FAILED" -ne 0 ]; then
echo "One or more jobs failed."
exit 1
else
echo "All jobs passed successfully."
fi
deploy:
name: Build and publish to PyPI
needs: check-static-and-test-status
if: contains(github.ref, 'tags/v') # both v1.x.x & v2.X.X
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- uses: astral-sh/setup-uv@v6
- name: Build the package
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
docs:
name: Build and publish docs
if: contains(github.ref, 'tags/v2.') # Only for version 2.X.X
needs: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Build
run: make docs
- name: Deploy
uses: JamesIves/github-pages-deploy-action@4.1.1
with:
branch: gh-pages
folder: docs/build/site