forked from pymedphys/pymedphys
-
Notifications
You must be signed in to change notification settings - Fork 0
573 lines (465 loc) · 17.1 KB
/
library.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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
name: Library
on:
push:
branches:
- main
pull_request:
release:
types:
- created
jobs:
# =============================================================================
PreCommit:
# if: false
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: pre-commit-cache
- name: Run Pre-Commit
run: |
pip install pre-commit
pre-commit run --all-files
- name: Fix any issues
if: failure()
run: |
git config --local user.email "[email protected]"
git config --local user.name "PyMedPhys Pre-Commit Bot"
git add -A
git stash
git checkout $GITHUB_HEAD_REF
git pull
pre-commit run --all-files || true
git commit -m "Fix pre-commit failures" -a
echo "##[set-output name=complete;]$(echo 1)"
id: fix_issues
- name: Push changes
if: failure() && steps.fix_issues.outputs.complete
uses: ad-m/github-push-action@057a6ba835d986bfe495dd476a6c4db1d5f9503c
with:
github_token: ${{ secrets.PYMEDPHYS_BOT_TOKEN }}
branch: ${{ github.event.pull_request.head.ref }}
# =============================================================================
Tests:
strategy:
fail-fast: true
matrix:
os: ["ubuntu", "macos", "windows"]
task:
[
"tests",
"docs",
"stackoverflow",
"updates",
"cypress",
"slow",
"build",
"pyright",
"propagate",
]
exclude:
- os: "windows"
task: "stackoverflow"
- os: "windows"
task: "updates"
- os: "windows"
task: "slow"
- os: "windows"
task: "pyright"
- os: "windows"
task: "propagate"
- os: "windows"
task: "cypress"
- os: "macos"
task: "stackoverflow"
- os: "macos"
task: "updates"
- os: "macos"
task: "cypress"
- os: "macos"
task: "slow"
- os: "macos"
task: "pyright"
- os: "macos"
task: "propagate"
include:
# Version numbers under support currently are versions 3.8, 3.9, and
# 3.10. Instead of doing a full OS python version matrix, instead
# just one version is chosen per OS in the hope that that offers a
# reasonable trade off between test coverage and CI minutes utilised.
# Windows is chosen to be the one using 3.10 since that is known to
# work for the docs build. 3.9 and 3.8 are divied up between Ubuntu
# and macOS arbitrarily.
- os: "ubuntu"
python-version: "3.9"
- os: "windows"
python-version: "3.10"
- os: "macos"
python-version: "3.8"
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
if: matrix.task != 'propagate'
- uses: actions/checkout@v2
if: matrix.task == 'propagate'
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get full Python version
id: full-python-version
shell: bash
run: |
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
# -----------------------------------------------------------------------------
# Set up pip
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install -U pip # to ensure version > 20 to have cache dir
echo "::set-output name=dir::$(pip cache dir)"
- name: Pip Cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-${{ matrix.task }}-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}
# -----------------------------------------------------------------------------
# Upgrade pip and setuptools, and install poetry
- name: Upgrade pip and setuptools
run: |
pip install --upgrade pip setuptools
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.2.1
virtualenvs-create: true
- name: Update PATH in Windows
if: matrix.os == 'windows'
run: |
Add-Content -Path $env:GITHUB_PATH -Value "$env:USERPROFILE\.poetry\bin"
Get-Content -Path $env:GITHUB_PATH
- name: Configure Poetry to not use experimental installer
run: |
poetry config experimental.new-installer false
# -----------------------------------------------------------------------------
# No import and run CLI with no dependencies
- name: Build wheel
if: matrix.task == 'tests'
run: |
poetry build --format wheel
- name: Install wheel
if: matrix.task == 'tests' && matrix.os == 'windows'
run: |
python -m pip install (Get-Item .\dist\*.whl)
- name: Install wheel
if: matrix.task == 'tests' && matrix.os != 'windows'
run: |
python -m pip install ./dist/*.whl
- name: Run clean tests
if: matrix.task == 'tests'
run: |
pymedphys --help
python -c "import pymedphys"
python -c "import pymedphys.beta"
python -c "import pymedphys.experimental"
# Remove confusion for tests down the line
- name: Remove base install of pymedphys
if: matrix.task == 'tests'
run: |
pip uninstall -y pymedphys
# -----------------------------------------------------------------------------
# Set up Poetry
- name: Configure poetry
run: |
poetry config virtualenvs.in-project true
- name: Poetry Cache
uses: actions/cache@v2
id: poetry-cache
with:
path: .venv
key: venv-${{ matrix.task }}-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
# This is from <https://github.com/python-poetry/poetry/blob/639d5e057/.github/workflows/main.yml#L57-L60>
- name: Ensure cache is healthy
if: steps.poetry-cache.outputs.cache-hit == 'true'
shell: bash
run: |
timeout 10s poetry run pip --version || rm -rf .venv
# Install Node
- uses: actions/setup-node@v3
if: matrix.task == 'cypress' || matrix.task == 'pyright' || matrix.task == 'build'
with:
node-version: "14"
# cache: "yarn" # TODO: Sort out this cache parameter
# -----------------------------------------------------------------------------
# System installs
- name: Install Pandoc on Ubuntu
if: ( matrix.task == 'docs' || matrix.task == 'updates' ) && matrix.os == 'ubuntu'
run: |
sudo apt-get install -y pandoc
- name: Install Pandoc on MacOS
if: matrix.task == 'docs' && matrix.os == 'macos'
run: |
brew install pandoc
- name: Install Pandoc on Windows
if: matrix.task == 'docs' && matrix.os == 'windows'
run: |
choco install pandoc
## Plain install
- name: Install a plain environment
if: matrix.task == 'stackoverflow'
run: |
poetry install -E user
## Install with Documentation Environment
- name: Install a docs environment
if: matrix.task == 'docs'
run: |
poetry install -E docs
## Install with Tests Environment
# TODO: Redesign CI to be more efficient once this issue lands python-poetry/poetry#4842
- name: Install a tests/doctests environment
if: matrix.task == 'tests' || matrix.task == 'cypress' || matrix.task == 'slow' || matrix.task == 'pyright'
run: |
poetry install -E user -E tests -E doctests
## Install remaining packages for pyright
- name: Install a propagate environment
if: matrix.task == 'pyright' || matrix.task == 'propagate'
run: |
poetry install -E propagate || poetry lock --no-update && poetry install -E propagate
## Install with Binary Build Environment
- name: Install a binary build environment
if: matrix.task == 'build'
run: |
poetry install -E build -E cli
## Update all packages and then install with tests environment
- name: Update all packages then install with tests and user environment
if: matrix.task == 'updates'
run: |
poetry install -E user -E tests -E docs
poetry update
poetry install -E user -E tests -E docs
# -----------------------------------------------------------------------------
# PyMedPhys Data Cache
- name: Get PyMedPhys cache directory
id: pymedphys-cache-location
if: matrix.task != 'build' && matrix.task != 'pyright'
run: |
echo "::set-output name=dir::$(poetry run python -c 'import pymedphys._config as cf; print(str(cf.get_config_dir()))')"
- name: PyMedPhys Cache
id: pymedphys-cache
if: matrix.task != 'build' && matrix.task != 'pyright'
uses: actions/cache@v2
with:
path: ${{ steps.pymedphys-cache-location.outputs.dir }}
key: pymedphys-${{ matrix.task }}-${{ runner.os }}-${{ hashFiles('**/hashes.json') }}
# -----------------------------------------------------------------------------
# Binary building
- name: Build Binary
if: matrix.task == 'build'
run: |
poetry run pymedphys dev build --install
- uses: actions/upload-artifact@v3
if: matrix.task == 'build'
with:
name: PyMedPhysApp-${{ runner.os }}
path: |
js/app/dist/*.dmg
js/app/dist/*.exe
js/app/dist/*.snap
js/app/dist/*.AppImage
!js/app/dist/*unpacked/
# TODO:
# - name: Test Binary
# if: matrix.task == 'build'
# run: |
# -----------------------------------------------------------------------------
# TESTS
## Propagate
- name: See if propagate is needed
if: matrix.task == 'propagate'
id: propagate-test
run: |
echo "::set-output name=status::before"
poetry run pymedphys dev propagate
git config --local user.email "[email protected]"
git config --local user.name "PyMedPhys Propagate Bot"
git add poetry.lock
git commit -m "commit changes to poetry.lock" || true
git status
git diff-index --quiet HEAD --
## Pyright
- name: Install and run pyright
if: matrix.task == 'pyright'
run: |
npm install -g pyright
poetry run pyright
## Pytest
- name: Run basic pytest tests
if: matrix.task == 'tests' || matrix.task == 'updates'
run: |
poetry run pymedphys dev tests -v
## Doctest
- name: Run doctest tests
if: matrix.os == 'ubuntu' && matrix.task == 'tests'
run: |
poetry run pymedphys dev doctests -v
## Pylint
- name: Run pylint tests
if: matrix.os == 'ubuntu' && ( matrix.task == 'tests' || matrix.task == 'updates' )
run: |
poetry run pymedphys dev lint
## Slow
- name: Run slow tests
if: matrix.task == 'slow'
run: |
poetry run pymedphys dev tests -v --slow
## Docs
- name: Download docs files
if: matrix.task == 'docs' && matrix.os == 'ubuntu'
run: |
poetry run python -c "import pymedphys; pymedphys.data_path('original_dose_beam_4.dcm'); pymedphys.data_path('logfile_dose_beam_4.dcm');"
- name: Build docs
if: matrix.task == 'docs' || matrix.task == 'updates'
run: |
poetry run pymedphys dev docs
- name: Add GitHub Pages Config Files
if: matrix.task == 'docs' && matrix.os == 'ubuntu' && github.event_name == 'push'
run: |
echo docs.pymedphys.com > lib/pymedphys/docs/_build/html/CNAME
touch lib/pymedphys/docs/_build/html/.nojekyll
- name: Deploy docs
if: matrix.task == 'docs' && matrix.os == 'ubuntu' && github.event_name == 'push'
uses: JamesIves/[email protected]
with:
branch: docs
folder: lib/pymedphys/docs/_build/html
ssh-key: ${{ secrets.DEPLOY_KEY }}
## Stackoverflow
- name: Run stackoverflow example(s)
if: matrix.task == 'stackoverflow'
run: |
poetry run python ./examples/stackoverflow/gamma.py
## Cypress
- name: Run Cypress tests
if: matrix.task == 'cypress'
run: |
poetry run pymedphys dev tests --cypress
- uses: actions/upload-artifact@v2
if: failure() && matrix.task == 'cypress'
with:
name: cypress-videos
path: pymedphys/tests/e2e/cypress/videos
# --------------------------------------------------------------------------- #
# DEPLOYMENT #
# --------------------------------------------------------------------------- #
ValidateVersionReleaseMatch:
if: false # Skip for now
# if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Get the tag version number
# https://github.community/t/how-to-get-just-the-tag-name/16241/7
id: tag_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install base PyMedPhys
run: |
pip install .
- name: Verify that version matches
run: |
python -c "import pymedphys; assert pymedphys.__version__ == '${{ steps.tag_version.outputs.VERSION }}'"
PyPI:
if: false # Skip for now
needs:
- ValidateVersionReleaseMatch
# - PreCommit
# - Tests
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Poetry
uses: snok/[email protected]
- name: Build and publish
run: |
poetry build
# poetry config repositories.test-pypi https://test.pypi.org/legacy/
# poetry config pypi-token.test-pypi ${{ secrets.TEST_PYPI_API_TOKEN }}
# poetry publish -r test-pypi
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
poetry publish
OfflineInstallBundles:
if: false # Skip for now
# needs:
# - PyPI
# - ValidateVersionReleaseMatch
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: true
matrix:
os: ["ubuntu", "macos", "windows"]
python-version: [3.8, 3.9, 3.10]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# - name: Get pip cache dir
# id: pip-cache
# run: |
# python -m pip install -U pip # to ensure version > 20 to have cache dir
# echo "::set-output name=dir::$(pip cache dir)"
# - name: Pip Cache
# uses: actions/cache@v2
# with:
# path: ${{ steps.pip-cache.outputs.dir }}
# key: pip-offline-install-bundles-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.full-python-version.outputs.version }}
- name: Download Source Files and Build PyMedPhys Wheel
run: |
pip install wheel
pip wheel . -w offline --no-deps
pip download -r requirements-dev.txt -d offline
- name: Get Wheel Types
id: wheel_label
run: |
python -c "import pathlib; path = str(next(pathlib.Path('offline').glob('pyarrow*.whl'))); print(f\"::set-output name=NAMING::{'-'.join(path.split('-')[2::])[:-4]}\")"
shell: bash
- uses: actions/upload-artifact@v2
with:
name: offline-install-bundle-${{ steps.wheel_label.outputs.NAMING }}
path: offline/*
UpdateRelease:
if: false # Skip for now
needs:
# - Tests
- OfflineInstallBundles
# - ValidateVersionReleaseMatch
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Hello World
run: |
echo Hello World