-
Notifications
You must be signed in to change notification settings - Fork 14
394 lines (355 loc) · 12.8 KB
/
ci.yml
File metadata and controls
394 lines (355 loc) · 12.8 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
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
name: CI
on:
push:
branches:
- master
tags:
- "**"
pull_request: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
changes:
runs-on: ubuntu-latest
outputs:
webknossos: ${{ steps.filter.outputs.webknossos || github.ref ==
'refs/heads/master' }}
cluster_tools: ${{ steps.filter.outputs.cluster_tools || github.ref ==
'refs/heads/master' }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v4.0.1
id: filter
with:
filters: |
webknossos:
- 'webknossos/**'
cluster_tools:
- 'cluster_tools/**'
cluster_tools_slurm:
needs: changes
if: ${{ needs.changes.outputs.cluster_tools == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: [ "3.13", "3.12", "3.11", "3.10" ]
defaults:
run:
working-directory: cluster_tools
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
cache-dependency-glob: "cluster_tools/uv.lock"
- run: uv python install ${{ matrix.python-version }}
- name: Start Docker Cluster
run: cd ./dockered-slurm && docker compose up -d
- name: Log Core Container
run: |
for name in "slurmctld" "c1" "c2"; do
docker logs "$name"
done
- name: Install UV dependencies
run: |
for name in "slurmctld" "c1" "c2"; do
docker exec -w /cluster_tools "$name" bash -c "uv sync --frozen"
done
- name: "Run Tests (test_all, test_slurm) without modified slurm.conf"
run: |
docker exec \
-w /cluster_tools/tests \
-e PYTEST_EXECUTORS=slurm \
slurmctld bash -c "uv run --frozen python -m pytest -sv test_all.py test_slurm.py -m 'not requires_modified_slurm_config'"
- name: "Run Tests (test_deref_main)"
run: |
docker exec \
-w /cluster_tools/tests \
slurmctld bash -c "uv run --frozen python test_deref_main.py"
- name: Update Slurm Config
run: |
echo "MaxArraySize=2" >> ./dockered-slurm/slurm.conf
sed "s/JobAcctGatherFrequency=30/JobAcctGatherFrequency=1/g" ./dockered-slurm/slurm.conf > ./dockered-slurm/slurm.conf.tmp
mv ./dockered-slurm/slurm.conf.tmp ./dockered-slurm/slurm.conf
- name: Restart Slurm Cluster
run: cd ./dockered-slurm && docker compose restart slurmctld c1 c2
- name: "Run Tests (test_all, test_slurm) with modified slurm.conf"
run: |
# Run tests requiring a modified slurm config
docker exec \
-w /cluster_tools/tests \
-e PYTEST_EXECUTORS=slurm \
slurmctld bash -c "uv run --frozen python -m pytest -sv test_slurm.py -m 'requires_modified_slurm_config'"
cluster_tools_other:
needs: changes
if: ${{ needs.changes.outputs.cluster_tools == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: [ "3.13", "3.12", "3.11", "3.10" ]
defaults:
run:
working-directory: cluster_tools
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
cache-dependency-glob: "cluster_tools/uv.lock"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies (without docker)
run: uv sync --frozen
- name: Check typing
if: ${{ matrix.python-version == '3.11' }}
run: ./typecheck.sh
- name: Check formatting
if: ${{ matrix.python-version == '3.11' }}
run: ./format.sh check
- name: Lint code
if: ${{ matrix.python-version == '3.11' }}
run: ./lint.sh
- name: Run multiprocessing tests
run: |
cd tests
PYTEST_EXECUTORS=multiprocessing,sequential,multiprocessing_with_pickling,sequential_with_pickling \
uv run --frozen python -m pytest -sv test_all.py test_multiprocessing.py
- name: Run batching tests
run: |
cd tests
uv run --frozen python -m pytest -sv test_batching.py
webknossos_linux:
needs: changes
if: |
${{ needs.changes.outputs.cluster_tools == 'true' }} ||
${{ needs.changes.outputs.webknossos == 'true' }}
runs-on: ubicloud-standard-8
strategy:
matrix:
python-version: [ "3.13", "3.12", "3.11", "3.10" ]
group: [ 1, 2, 3 ]
fail-fast: false
defaults:
run:
working-directory: webknossos
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
cache-dependency-glob: "webknossos/uv.lock"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Check formatting
if: ${{ matrix.group == 1 && matrix.python-version == '3.11' }}
run: ./format.sh check
- name: Lint code
if: ${{ matrix.group == 1 && matrix.python-version == '3.11' }}
run: ./lint.sh
- name: Check typing
if: ${{ matrix.group == 1 && matrix.python-version == '3.11' }}
run: ./typecheck.sh
- name: Patch Python standard library to assert that fork is not allowed
run: |
sed -i '/def _launch/a\ \ \ \ \ \ \ \ raise Exception("fork is not allowed.")' ${UV_PYTHON_INSTALL_DIR}/cpython-${{ matrix.python-version }}.*-linux-x86_64-gnu/lib/python${{ matrix.python-version }}/multiprocessing/popen_fork.py
cat ${UV_PYTHON_INSTALL_DIR}/cpython-${{ matrix.python-version }}.*-linux-x86_64-gnu/lib/python${{ matrix.python-version }}/multiprocessing/popen_fork.py
- name: Python tests (with coverage)
if: ${{ matrix.python-version == '3.11' }}
timeout-minutes: 30
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: uv run test.py --splits 3 --group ${{ matrix.group }} --splitting-algorithm
least_duration --cov=webknossos --cov-report=
- name: Python tests
if: ${{ matrix.python-version != '3.11' }}
timeout-minutes: 30
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: uv run test.py --splits 3 --group ${{ matrix.group }} --splitting-algorithm
least_duration
- name: Persist coverage reports
if: ${{ matrix.python-version == '3.11' }}
uses: actions/upload-artifact@v7
with:
name: coverage-report-${{ matrix.group }}
path: "webknossos/.coverage"
include-hidden-files: true
if-no-files-found: error
retention-days: 1 # Automatically deletes after 1 day
- name: Check if git is dirty
run: ../_tooling/check_clean.sh
webknossos_windows:
needs: changes
if: |
${{ needs.changes.outputs.cluster_tools == 'true' }} ||
${{ needs.changes.outputs.webknossos == 'true' }}
runs-on: windows-latest
strategy:
matrix:
python-version: [ "3.12" ]
group: [ 1, 2, 3 ]
fail-fast: false
defaults:
run:
working-directory: webknossos
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
cache-dependency-glob: "webknossos/uv.lock"
- name: Install minio
run: Invoke-WebRequest -Uri
"https://dl.min.io/server/minio/release/windows-amd64/minio.exe"
-OutFile "minio.exe"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Python tests
timeout-minutes: 30
env:
PYTHON_VERSION: ${{ matrix.python-version }}
MULTIPROCESSING_DEFAULT_START_METHOD: spawn
run: uv run test.py --splits 3 --group ${{ matrix.group }} --splitting-algorithm
least_duration
coverage_report:
needs: [ webknossos_linux ]
if: success()
runs-on: ubuntu-latest
defaults:
run:
working-directory: webknossos
steps:
- uses: actions/checkout@v6
- name: Install coverage.py
run: pip install coverage
- name: Download all coverage reports
uses: actions/download-artifact@v8
with:
path: ~/coverage-files
- name: Generate coverage report
env:
COVERAGE_FILE: "~/coverage-files/result.coverage"
run: |
coverage combine ~/coverage-files/**/.coverage
coverage xml -i -o ~/coverage-files/result.xml
- name: Report coverage
uses: orgoro/coverage@v3.2
with:
coverageFile: /home/runner/coverage-files/result.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: 0.8
- name: Cleanup temporary files
run: rm -rf ~/coverage-files
docs:
needs:
- cluster_tools_slurm
- cluster_tools_other
- webknossos_linux
- webknossos_windows
runs-on: ubuntu-latest
if: |
always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
!github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v6
with:
repository: scalableminds/webknossos
path: docs/wk-repo
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
- name: Build Docs
run: |
cd docs
./generate.sh --persist
- name: Push docs (for master)
if: github.ref == 'refs/heads/master'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
CI_BRANCH=${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}
NORMALIZED_CI_BRANCH=${CI_BRANCH//[\/-]/_}
uvx --from awscli aws s3 cp --recursive --endpoint-url https://hel1.your-objectstorage.com docs/out s3://webknossos-www/docs/${NORMALIZED_CI_BRANCH}
- name: Push docs (for tag)
if: github.ref_type == 'tag'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
N8N_TOKEN: ${{ secrets.N8N_USERNAME }}
N8N_USERNAME: ${{ secrets.N8N_TOKEN }}
run: |
CI_TAG=$(git describe --tags)
set -e
uvx --from awscli aws s3 cp --recursive --endpoint-url https://hel1.your-objectstorage.com docs/out s3://webknossos-www/docs/${CI_TAG}
curl --basic -u "${N8N_TOKEN}:${N8N_USERNAME}" https://docs.webknossos.org/webhooks/index-docs
- name: Check links (on master)
if: github.ref == 'refs/heads/master'
env:
# Or as an environment variable
SLACK_HOOK: ${{ secrets.LINK_CHECKER_SLACK_HOOK }}
run: |
cd docs
uv run --frozen linkchecker --config linkcheckerrc https://docs.webknossos.org > link_status || \
curl -X POST --data-urlencode "payload={\"text\": \":warning: Broken Links on doc.webknossos.org :warning:\n"'```'"\n$(cat link_status)\n"'```"}' \
"$SLACK_HOOK"
pypi_and_gh_release:
needs:
- cluster_tools_slurm
- cluster_tools_other
- webknossos_linux
- webknossos_windows
if: |
always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
github.ref_type == 'tag' &&
!github.event.pull_request.head.repo.fork
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
- name: Publish python packages
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_PASSWORD }}
run: _tooling/publish.sh
- name: Prepare github release
run: |
VERSION="$(uvx dunamai from git)"
_tooling/changelog_for_version.sh $VERSION > Changelog.md
- name: Publish github release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref }}
name: ${{ github.ref }}
body_path: Changelog.md
draft: false
prerelease: false
complete:
needs:
- cluster_tools_other
- cluster_tools_slurm
- webknossos_linux
- webknossos_windows
- docs
- pypi_and_gh_release
if: always()
runs-on: ubuntu-latest
steps:
- name: Check failure
if: |
contains(needs.*.result, 'failure') ||
contains(needs.*.result, 'cancelled')
run: exit 1
- name: Success
run: echo Success!