-
-
Notifications
You must be signed in to change notification settings - Fork 6
372 lines (326 loc) · 11 KB
/
CI.yml
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
name: CI
# Minimal permissions following the principle of least privilege
permissions:
contents: read
# Trigger CI on pushes to main and pull requests targeting main or release branches
on:
push:
branches:
- main
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/CI.yml'
- 'pyproject.toml'
- 'docs/**'
pull_request:
branches:
- main
- 'release**'
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/CI.yml'
- 'pyproject.toml'
- 'docs/**'
jobs:
# Job to test core dependencies without optional (soft) dependencies
test-core-dependencies:
name: Test Core Dependencies
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure full history for accurate branch information
# Step 2: Set up Python 3.11
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
# Step 3: Cache pip dependencies to speed up builds
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
# Step 4: Setup virtual environment using the composite action
- name: Setup Virtual Environment
uses: ./.github/actions/setup-venv
with:
python-version: '3.11'
# Step 5: Install package without optional dependencies
- name: Install Package and Core Dependencies (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
uv pip install . --no-cache-dir
shell: bash
- name: Install Package and Core Dependencies (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
uv pip install . --no-cache-dir
shell: pwsh
# Step 6: Display installed dependencies for verification
- name: Show Dependencies (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
uv pip list
shell: bash
- name: Show Dependencies (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
uv pip list
shell: pwsh
# Step 7: Run pytest-free tests
- name: Run pytest-free Tests (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
python tests/_nopytest_tests.py
shell: bash
- name: Run pytest-free Tests (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
python tests/_nopytest_tests.py
shell: pwsh
# Job to test without optional dependencies across multiple Python versions and OSes
test-no-optional-dependencies:
name: Test Without Optional Dependencies
needs: test-core-dependencies
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, macos-13, windows-latest]
steps:
# Step 1: Checkout the repository
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Step 2: Set up Python with the specified version
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Step 3: Cache pip dependencies to speed up builds
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
# Step 4: Setup virtual environment using the composite action
- name: Setup Virtual Environment
uses: ./.github/actions/setup-venv
with:
python-version: ${{ matrix.python-version }}
# Step 5: Install package and dev dependencies
- name: Install Package and Dev Dependencies (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
uv pip install .[dev] --no-cache-dir
shell: bash
- name: Install Package and Dev Dependencies (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
uv pip install .[dev] --no-cache-dir
shell: pwsh
# Step 6: Display installed dependencies for verification
- name: Show Dependencies (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
uv pip list
shell: bash
- name: Show Dependencies (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
uv pip list
shell: pwsh
# Step 7: Show available branches for debugging
- name: Show Available Branches
run: git branch -a
# Step 8: Run tests using pytest
- name: Run Tests (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
python -m pytest src/ tests/ -vv
shell: bash
- name: Run Tests (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
python -m pytest src/ tests/ -vv
shell: pwsh
# Job to test with all optional dependencies across multiple Python versions and OSes
test-all-optional-dependencies:
name: Test With All Optional Dependencies
needs: test-no-optional-dependencies
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, macos-13, windows-latest]
steps:
# Step 1: Checkout the repository
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Step 2: Set up Python with the specified version
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Step 3: Cache pip dependencies to speed up builds
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
# Step 4: Setup virtual environment using the composite action
- name: Setup Virtual Environment
uses: ./.github/actions/setup-venv
with:
python-version: ${{ matrix.python-version }}
# Step 5: Install package and all dependencies including optional ones
- name: Install Package and All Dependencies (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
uv pip install .[all_extras,dev] --no-cache-dir
shell: bash
- name: Install Package and All Dependencies (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
uv pip install .[all_extras,dev] --no-cache-dir
shell: pwsh
# Step 6: Display installed dependencies for verification
- name: Show Dependencies (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
uv pip list
shell: bash
- name: Show Dependencies (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
uv pip list
shell: pwsh
# Step 7: Show available branches for debugging
- name: Show Available Branches
run: git branch -a
# Step 8: Run tests using pytest
- name: Run Tests (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
python -m pytest src/ tests/ -vv
shell: bash
- name: Run Tests (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
python -m pytest src/ tests/ -vv
shell: pwsh
# Step 9: Upload code coverage report to GitHub artifacts
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}-${{ runner.os }}
path: coverage.md
# Step 10: Publish code coverage to Codecov
- name: Publish Code Coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }} # Ensure this secret is set in your repository
fail_ci_if_error: true
verbose: true
# Job to build and test documentation
docs:
name: Test Docs Build
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Step 2: Set up Python 3.11
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
# Step 3: Cache pip dependencies to speed up builds
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
# Step 4: Install uv and update PATH
- name: Install uv and Update PATH
run: |
pip install uv
echo "$(python -m site --user-base)/bin" >> $GITHUB_PATH
shell: bash
# Step 5: Setup virtual environment using the composite action
- name: Setup Virtual Environment
uses: ./.github/actions/setup-venv
with:
python-version: '3.11'
# Step 6: Install package and documentation dependencies
- name: Install Package and Dependencies (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
uv pip install .[dev,docs] --no-cache-dir
shell: bash
- name: Install Package and Dependencies (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
uv pip install .[dev,docs] --no-cache-dir
shell: pwsh
# Step 7: Build Sphinx documentation
- name: Build Sphinx Documentation (Linux/macOS)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
cd docs
make clean
make html --debug --jobs 2 SPHINXOPTS=" -W -v"
shell: bash
- name: Build Sphinx Documentation (Windows)
if: runner.os == 'Windows'
run: |
.\.venv\Scripts\Activate.ps1
cd docs
make clean
make html --debug --jobs 2 SPHINXOPTS=" -W -v"
shell: pwsh
# Step 8: Upload built documentation as an artifact
- name: Upload Built Docs
uses: actions/upload-artifact@v4
with:
name: docs-results-${{ runner.os }}
path: docs/build/html/
# Ensure this step runs even if previous steps fail
if: success()