forked from pymedphys/pymedphys
-
Notifications
You must be signed in to change notification settings - Fork 0
493 lines (385 loc) · 14 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
name: Library
on:
push:
branches:
- main
pull_request:
release:
types:
- created
jobs:
# =============================================================================
PreCommit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v1
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 "pre-commit-bot@pymedphys.com"
git config --local user.name "PyMedPhys Pre-Commit Bot"
git commit -m "Fix pre-commit failures" -a
exit 1
- name: Push changes
if: failure()
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: false
matrix:
os: ['ubuntu', 'macos', 'windows']
task: ['tests', 'docs', 'stackoverflow', 'updates', 'cypress', 'slow', 'binary', 'pyright', 'propagate']
exclude:
- os: 'ubuntu'
task: 'binary'
- os: 'windows'
task: 'stackoverflow'
- os: 'windows'
task: 'updates'
- os: 'windows'
task: 'cypress'
- os: 'windows'
task: 'slow'
- os: 'windows'
task: 'pyright'
- os: 'windows'
task: 'propagate'
- os: 'macos'
task: 'stackoverflow'
- os: 'macos'
task: 'updates'
- os: 'macos'
task: 'cypress'
- os: 'macos'
task: 'slow'
- os: 'macos'
task: 'binary'
- os: 'macos'
task: 'pyright'
- os: 'macos'
task: 'propagate'
include:
# Version numbers chosen so that highest and lowest Python version is
# utilised, 3.7 is chosen on Windows to align with Jupyter Book until
# https://github.com/executablebooks/jupyter-book/issues/906 is fixed.
# See https://jupyterbook.org/advanced/advanced.html#working-on-windows
- os: 'ubuntu'
python-version: 3.8
- os: 'windows'
python-version: 3.7
- os: 'macos'
python-version: 3.6
runs-on: ${{ matrix.os }}-latest
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.1.1
with:
version: 1.1.4
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@v1
if: matrix.task == 'cypress' || matrix.task == 'pyright'
with:
node-version: '14'
# -----------------------------------------------------------------------------
# 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 user -E docs
## Install with Tests Environment
- name: Install a tests environment
if: matrix.task == 'tests' || matrix.task == 'cypress' || matrix.task == 'slow' || matrix.task == 'pyright'
run: |
poetry install -E user -E tests
## Install with Doctests Environment
- name: Install a doctests environment
if: matrix.os == 'ubuntu' && matrix.task == 'tests' || matrix.task == 'pyright'
run: |
poetry install -E user -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
## 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 != 'binary' && 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 != 'binary' && 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 == 'binary'
run: |
pip install tomlkit wheel pyinstaller
cd binary
python build-binary.py
- uses: actions/upload-artifact@v2
if: matrix.task == 'binary'
with:
name: PyMedPhysGUI
path: binary/build/dist/PyMedPhysGUI*.exe
- name: Test Binary
if: matrix.task == 'binary'
run: |
pip install psutil
cd binary
python test.py
# -----------------------------------------------------------------------------
# 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 "propagate-bot@pymedphys.com"
git config --local user.name "PyMedPhys Propagate Bot"
git fetch origin $BRANCH
git checkout $BRANCH
git add poetry.lock setup.py
git commit -m "commit changes to poetry.lock and setup.py" || true
echo "::set-output name=status::committed"
git status
git diff-index --quiet HEAD -- || echo "::set-output name=status::failed"
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
- name: Fix any issues
if: steps.propagate-test.outputs.status == 'failed'
run: |
git config --local user.email "propagate-bot@pymedphys.com"
git config --local user.name "PyMedPhys Propagate Bot"
git commit -m "Fix propagate failures" -a
- name: Push changes
if: steps.propagate-test.outputs.status == 'failed'
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.PYMEDPHYS_BOT_TOKEN }}
branch: ${{ github.event.pull_request.head.ref }}
## 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: 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/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: docs # The branch the action should deploy to.
FOLDER: lib/pymedphys/docs/_build/html # The folder the action should deploy.
CLEAN: true # Automatically remove deleted files from the deploy branch
## 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 --reruns 5 -v -s --cypress
- uses: actions/upload-artifact@v2
if: failure() && matrix.task == 'cypress'
with:
name: cypress-videos
path: pymedphys/tests/e2e/cypress/videos
PyPI:
# needs:
# - PreCommit
# - Tests
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
steps:
- name: Hello World
run: |
echo Hello World
WheelBundles:
needs:
- PyPI
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
steps:
- name: Hello World
run: |
echo Hello World
UpdateRelease:
needs:
# - Tests
- WheelBundles
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
steps:
- name: Hello World
run: |
echo Hello World