forked from hyperspy/hyperspy-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
543 lines (477 loc) · 17.2 KB
/
release.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
name: Release
on:
workflow_dispatch:
push:
branches: ['*']
tags: ['*']
paths-ignore:
- 'docs/**'
pull_request:
branches: [main]
paths-ignore:
- 'docs/**'
permissions:
# needs write permission at workflow level to create release and upload artifacts
contents: write
env:
MPLBACKEND: 'agg'
TEST_DEPS: pytest pytest-qt pytest-xdist pytest-rerunfailures pytest-mpl filelock
jobs:
create_release_job:
name: Create Release (on tag only)
runs-on: ubuntu-latest
outputs:
ID: ${{ steps.create_release.outputs.id }}
VERSION: ${{ env.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Get version (on tag)
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Get version (short hash)
if: ${{ startsWith(github.ref, 'refs/tags/') == false }}
run: |
# Use git short hash instead of tag
echo "VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Display version
run: |
echo ${{ env.VERSION }}
- name: Find and Replace
uses: jacobtomlinson/gha-find-replace@a51bbcd94d000df9ca0fcb54ec8be69aad8374b0
if: startsWith(github.ref, 'refs/tags/')
with:
find: "__TAG__"
replace: ${{ env.VERSION }}
include: "RELEASE_TEXT.md" # Will match all RELEASE_TEXT.md files in any nested directory
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
id: create_release
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions
with:
body_path: "RELEASE_TEXT.md"
draft: true
build:
name: ${{ matrix.TARGET_PLATFORM }}-${{ matrix.BLAS_IMPL }}
needs: create_release_job
runs-on: ${{ matrix.os }}-${{ matrix.os_version }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu
os_version: latest
INSTALLER_EXTENSION: sh
BLAS_IMPL: mkl
ARCH: x86_64
TARGET_PLATFORM: linux-64
- os: ubuntu
os_version: latest
INSTALLER_EXTENSION: sh
BLAS_IMPL: openblas
ARCH: x86_64
TARGET_PLATFORM: linux-64
- os: windows
os_version: latest
INSTALLER_EXTENSION: exe
BLAS_IMPL: mkl
ARCH: x86_64
TARGET_PLATFORM: win-64
- os: windows
os_version: latest
INSTALLER_EXTENSION: exe
BLAS_IMPL: openblas
ARCH: x86_64
TARGET_PLATFORM: win-64
- os: macos
os_version: '13'
INSTALLER_EXTENSION: pkg
BLAS_IMPL: mkl
ARCH: x86_64
TARGET_PLATFORM: osx-64
- os: macos
os_version: latest
INSTALLER_EXTENSION: pkg
BLAS_IMPL: accelerate
ARCH: arm64
TARGET_PLATFORM: osx-arm64
env:
DISPLAY: ':0'
MICROMAMBA_VERSION: '1.5.8'
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
- shell: bash -l {0}
name: Conda info
run: |
conda info
conda list
- shell: bash -l {0}
name: Install constructor
run: |
mamba install constructor jinja2 conda-libmamba-solver
- shell: bash -l {0}
if: matrix.ARCH == 'arm64'
name: Install micromamba
run: |
TEMP_DIR=$(mktemp -d)
mkdir "${TEMP_DIR}/micromamba"
pushd "${TEMP_DIR}/micromamba"
curl -L -O "https://anaconda.org/conda-forge/micromamba/${{ env.MICROMAMBA_VERSION }}/download/${{ matrix.TARGET_PLATFORM }}/micromamba-${{ env.MICROMAMBA_VERSION }}-0.tar.bz2"
bsdtar -xf "micromamba-${{ env.MICROMAMBA_VERSION }}-0.tar.bz2"
echo "MICROMAMBA_FILE=${PWD}/bin/micromamba" >> $GITHUB_ENV
ls ${PWD}
ls ${PWD}/bin
popd
- shell: bash -l {0}
name: Build distribution
env:
VERSION: ${{ needs.create_release_job.outputs.VERSION }}
BLAS_IMPL: ${{ matrix.BLAS_IMPL }}
CONDA_SOLVER: 'libmamba'
run: |
if [ ${{ matrix.TARGET_PLATFORM }} == osx-arm64 ]; then
constructor -v conda_distribution --platform ${{ matrix.TARGET_PLATFORM }} --conda-exe ${{ env.MICROMAMBA_FILE }}
else
constructor -v conda_distribution
fi
- shell: bash -l {0}
name: Set asset name
env:
ext: ${{ matrix.INSTALLER_EXTENSION }}
run: |
installer_name=(HyperSpy-*.${{ env.ext }})
echo "Original installer name: " $installer_name
# Rename installer name according to BLAS_IMPL
if [ ${{ matrix.TARGET_PLATFORM }} = osx-arm64 ]; then
CPU=Silicon
elif [ ${{ matrix.BLAS_IMPL }} = mkl ]; then
CPU=Intel
else
CPU=AMD
fi
new_installer_name=$(basename $installer_name .${{ env.ext }})-$CPU.${{ env.ext }}
mv $installer_name $new_installer_name
echo "asset_name=$new_installer_name" >> $GITHUB_ENV
echo "Installer name: "$new_installer_name
ls
- name: Get hash
run: |
shasum -a 256 ${{ env.asset_name }}
- name: Install new distribution (Linux)
if: runner.os == 'linux'
env:
install_dir: '${{ github.workspace }}/new_distribution'
run: |
echo "install_dir=${{ env.install_dir }}" >> $GITHUB_ENV
bash ${{ env.asset_name }} -b -p ${{ env.install_dir }}
- name: Install new distribution (MacOS)
if: runner.os == 'macos'
run: |
echo "install_dir=/Users/runner" >> $GITHUB_ENV
installer -pkg ${{ env.asset_name }} -target CurrentUserHomeDirectory
- name: Install new distribution (Windows)
if: runner.os == 'windows'
env:
install_dir: '${{ github.workspace }}\nd'
shell: bash
run: |
echo "install_dir=${{ env.install_dir }}" >> $GITHUB_ENV
- name: Install new distribution (Windows)
if: runner.os == 'windows'
shell: powershell
run: |
Start-Process -Wait -FilePath ${{ env.asset_name }} -ArgumentList "/S /AddToPath=0 /RegisterPython=0 /NoScripts=1 /D=${{ env.install_dir }}"
- name: Upload artifact
if: startsWith(github.ref, 'refs/tags/') != true
uses: actions/upload-artifact@v4
with:
path: ${{ env.asset_name }}
name: ${{ env.asset_name }}
- shell: bash -l {0}
name: Info new distribution
run: |
conda activate "${{ env.install_dir }}"
conda info
conda config --show channels
conda config --show channel_priority
conda list
- shell: bash -l {0}
name: Check latest available hyperspy version
run: |
conda activate "${{ env.install_dir }}"
python check_hyperspy_latest.py
- name: Install xvfb
if: runner.os == 'linux' && always()
run: |
sudo apt-get install -y xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0
- name: Start xvfb
if: runner.os == 'linux' && always()
run: |
sudo /usr/bin/Xvfb ${{ env.DISPLAY }} -screen 0 1280x1024x24 &
- shell: bash -l {0}
name: Install test dependencies
if: always()
run: |
conda activate "${{ env.install_dir }}"
mamba install ${{ env.TEST_DEPS }}
- shell: bash -l {0}
# TODO: revisit at some point, to get it to work on linux (hyperspyui CI works fine...)
if: runner.os != 'linux' && always()
name: Test new distribution (HyperSpyUI)
run: |
conda activate "${{ env.install_dir }}"
pytest --pyargs hyperspyui
- shell: bash -l {0}
name: Test RosettaSciIO
if: always()
run: |
conda activate "${{ env.install_dir }}"
pytest --pyargs rsciio --reruns 3 -n 2
- shell: bash -l {0}
name: Test hyperspy
if: always()
run: |
conda activate "${{ env.install_dir }}"
pytest --pyargs hyperspy --reruns 3 -n 2
- shell: bash -l {0}
name: Test hyperspy_gui_ipywidgets
if: always()
run: |
conda activate "${{ env.install_dir }}"
pytest --pyargs hyperspy_gui_ipywidgets
- shell: bash -l {0}
name: Test hyperspy_gui_traitsui
if: runner.os != 'linux' && always()
run: |
conda activate "${{ env.install_dir }}"
# test_image_contrast_tool not supported with agg backend
pytest --pyargs hyperspy_gui_traitsui -k "not test_image_contrast_tool"
- shell: bash -l {0}
name: Run test exspy
if: always()
run: |
conda activate "${{ env.install_dir }}"
pytest --pyargs exspy
- shell: bash -l {0}
name: Run test holospy
if: always()
run: |
conda activate "${{ env.install_dir }}"
pytest --pyargs holospy
- shell: bash -l {0}
name: Run test lumispy
if: always()
run: |
conda activate "${{ env.install_dir }}"
pytest --pyargs lumispy
- shell: bash -l {0}
name: Run test pyxem
if: always()
run: |
conda activate "${{ env.install_dir }}"
# cause of the TestAddEllipseArrayAsMarkers failure is unknown (seems to be on blas mkl only)
pytest --pyargs pyxem -k "not TestAddEllipseArrayAsMarkers"
- shell: bash -l {0}
name: Run test atomap
if: always()
run: |
conda activate "${{ env.install_dir }}"
# Skip interactive test
pytest --pyargs atomap -k "not TestSelectAtomsWithGui"
# - shell: bash -l {0}
# name: Run test kikuchipy
# if: always()
# env:
# MPLBACKEND: 'agg'
# run: |
# conda activate "${{ env.install_dir }}"
# pytest --pyargs kikuchipy
- name: Upload Release Asset
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ env.asset_name }}
draft: true
build_portable:
name: windows (Portable)
needs: create_release_job
runs-on: windows-latest
env:
WP_URL: https://github.com/winpython/winpython/releases/download/7.1.20240203final/Winpython64-3.11.8.0.exe
WP_SHA256: 0fa1bad92e7287632ce6c32c263c694b109b714b5d12e56063b2cd4281a71f7c
WP_EXE: winpython.exe
WP_DIR_NAME: WPy64-31180
#LIB_TO_INSTALL: abtem ase atomap exspy graphviz holospy hdf5plugin hyperspy[all] hyperspyui kikuchipy lumispy matplotlib-scalebar nglview particlespy py4dstem pymatgen pystackreg python-rapidjson pyxem scanning_drift_corr start_jupyter_cm
LIB_TO_INSTALL: abtem ase atomap dask-image exspy graphviz holospy hdf5plugin hyperspy[all] hyperspyui lumispy matplotlib-scalebar nglview particlespy py4dstem pymatgen pystackreg python-rapidjson pyxem scanning_drift_corr start_jupyter_cm
steps:
- uses: actions/checkout@v4
- name: Download Winpython
run: |
Invoke-WebRequest -OutFile ${{ env.WP_EXE }} ${{ env.WP_URL }}
ls
$file_hash = (Get-FileHash ${{ env.WP_EXE }} ).Hash
$file_hash
if ($file_hash -ne "${{ env.WP_SHA256 }}") { exit(1) }
- name: Install Winpython
run: |
.\${{ env.WP_EXE }} -y | Out-Null
ls
ls ${{ env.WP_DIR_NAME }}
- name: Install libraries
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
where python
where pip
pip install ${{ env.LIB_TO_INSTALL }}
# workaround for imageio / pillow incompatiblity?
pip install --upgrade imageio
- name: Pip list
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
pip list
- shell: bash -l {0}
name: Set installer name
env:
VERSION: ${{ needs.create_release_job.outputs.VERSION }}
run: |
installer_name=HyperSpy-bundle-${{ env.VERSION }}-Windows-x86_64-Portable.exe
echo "asset_name=$installer_name" >> $GITHUB_ENV
echo $installer_name
- name: Run pyclean in distribution folder
shell: cmd
run: |
where pip
pip install pyclean
where pyclean
pyclean ${{ env.WP_DIR_NAME }}
- name: Create installer
run: |
7z -mx5 -sfx a ${{ env.asset_name }} ${{ env.WP_DIR_NAME }}
ls
- name: Upload artifact
if: startsWith(github.ref, 'refs/tags/') != true
uses: actions/upload-artifact@v4
with:
path: ${{ env.asset_name }}
name: ${{ env.asset_name }}
- name: Install new distribution
run: |
Remove-Item -recurse ${{ env.WP_DIR_NAME }}
ls
.\${{ env.asset_name }} -y | Out-Null
echo "After installation"
ls
echo ${{ env.asset_name }}
- name: Check latest available hyperspy version
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
python check_hyperspy_latest.py
- name: Install testing libraries
if: always()
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
pip install ${{ env.TEST_DEPS }}
- name: Run test suite (HyperSpyUI)
if: always()
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
pytest --pyargs hyperspyui
- name: Run test hyperspy
if: always()
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
pytest --pyargs hyperspy --reruns 3 -n 2
- name: Run test RosettaSciIO
if: always()
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
pytest --pyargs rsciio --reruns 3 -n 2
- name: Run test hyperspy_gui_ipywidgets
if: always()
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
pytest --pyargs hyperspy_gui_ipywidgets
- name: Run test hyperspy_gui_traitsui --reruns 3
if: always()
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
# test_image_contrast_tool not supported with agg backend
pytest --pyargs hyperspy_gui_traitsui -k "not test_image_contrast_tool"
- name: Run test exspy
if: always()
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
pytest --pyargs exspy
- name: Run test holospy
if: always()
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
pytest --pyargs holospy
- name: Run test lumispy
if: always()
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
pytest --pyargs lumispy
- name: Run test pyxem
if: always()
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
# cause of the TestAddEllipseArrayAsMarkers failure is unknown (seems to be on blas mkl only)
pytest --pyargs pyxem -k "not TestAddEllipseArrayAsMarkers"
- name: Run test atomap
if: always()
shell: cmd
run: |
call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
# Skip interactive test
pytest --pyargs atomap -k "not TestSelectAtomsWithGui"
# - name: Run test kikuchipy
# if: always()
# shell: cmd
# run: |
# call "${{ env.WP_DIR_NAME }}\scripts\env.bat"
# # Skip these tests until there are fixed
# pytest --pyargs kikuchipy -k "not test_load_with_padding"
- name: Upload Release Asset
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ env.asset_name }}
draft: true
publish_release_job:
# Set build, build_portable are needed, so that it runs when they are finished
needs: [create_release_job, build, build_portable]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Finalise release
# Publish draft release
uses: eregon/publish-release@01df127f5e9a3c26935118e22e738d95b59d10ce
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.create_release_job.outputs.ID }}