-
Notifications
You must be signed in to change notification settings - Fork 45
556 lines (544 loc) · 21.3 KB
/
main.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
name: CI
on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
branches: [ master ]
schedule:
- cron: '0 0 * * 0,3'
workflow_dispatch:
jobs:
build_opengate_wheel:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.9]
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Checkout submodules
shell: bash -l {0}
run: |
export GIT_SSL_NO_VERIFY=1
git submodule update --init --recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- name: Create opengate Wheel
run: |
rm -rf $GITHUB_WORKSPACE/opengate/tests/data
cp $GITHUB_WORKSPACE/.git/modules/gam-tests/data/HEAD $GITHUB_WORKSPACE/opengate/tests/
pip install build
python -m build
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: dist-opengate
path: dist/
build_opengate_core_wheel:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
python-version: [3.9, '3.10', '3.11', '3.12']
env:
GEANT4_VERSION: 'v11.2.1'
ITK_VERSION: 'v5.2.1'
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Checkout submodules
shell: bash -l {0}
run: |
if [[ ${{ matrix.os }} == "ubuntu-latest" ]]; then
export GIT_SSL_NO_VERIFY=1
git submodule update --init --recursive
elif [[ ${{ matrix.os }} == "macos-13" ]]; then
export GIT_SSL_NO_VERIFY=1
git submodule update --init --recursive
else
set "GIT_SSL_NO_VERIFY=1"
git submodule update --init --recursive
fi
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- name: Get OS version
id: get-os-version
shell: bash -l {0}
run: |
if [[ ${{ matrix.os }} == "ubuntu-latest" ]]; then
varOS=`cat /etc/os-release | grep "VERSION=" | grep -oP '(?<=\").*?(?=\")'`
varOS=($varOS)
echo "release=${varOS[0]}" >> $GITHUB_OUTPUT
elif [[ ${{ matrix.os }} == "macos-13" ]]; then
varOS=`sw_vers | grep "ProductVersion:"`
varOS="${varOS#*:}"
echo "release=${varOS:1}" >> $GITHUB_OUTPUT
else
varOS=`windows`
echo "release=${varOS}" >> $GITHUB_OUTPUT
fi
- name: Cache modules
id: cache_opengate_core_dependencies
uses: actions/cache@v4
with:
path: ~/software
key: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build2
restore-keys: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build2
- name: Create opengate_core Wheel Linux
if: matrix.os == 'ubuntu-latest'
run: |
if [ ${{ matrix.python-version }} == "3.9" ]; then
export PYTHONFOLDER="cp39-cp39"
elif [ ${{ matrix.python-version }} == "3.10" ]; then
export PYTHONFOLDER="cp310-cp310"
elif [ ${{ matrix.python-version }} == "3.11" ]; then
export PYTHONFOLDER="cp311-cp311"
elif [ ${{ matrix.python-version }} == "3.12" ]; then
export PYTHONFOLDER="cp312-cp312"
fi
mkdir -p $HOME/software
docker run --rm -e "PYTHONFOLDER=${PYTHONFOLDER}" -v $GITHUB_WORKSPACE:/home tbaudier/opengate_core:${{ env.GEANT4_VERSION }} /home/.github/workflows/createWheelLinux.sh
ls wheelhouse
rm -rf dist
mv wheelhouse dist
sudo chown -R runner:docker dist
- uses: conda-incubator/setup-miniconda@v3
if: (matrix.os == 'macos-13') || (matrix.os == 'windows-latest')
with:
miniconda-version: "latest"
auto-update-conda: true
activate-environment: opengate_core
python-version: ${{ matrix.python-version }}
- name: Set up Homebrew
if: matrix.os == 'macos-13'
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Create opengate_core Wheel Mac
if: matrix.os == 'macos-13'
shell: bash -l {0}
run: |
brew install [email protected] || true
brew link --overwrite [email protected]
#brew update
#rm -rf /usr/local/bin/python3.1*-config /usr/local/bin/2to3-3.1* /usr/local/bin/idle3.1* /usr/local/bin/pydoc3.1* /usr/local/bin/python3.1*
#rm -rf /usr/local/bin/python3-config /usr/local/bin/2to3 /usr/local/bin/idle3 /usr/local/bin/pydoc3 /usr/local/bin/python3
brew install --force --verbose --overwrite \
ccache \
fftw \
libomp \
xquartz \
xerces-c \
wget
brew uninstall --ignore-dependencies libxext
brew uninstall --ignore-dependencies libx11
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include -fopenmp"
conda info
conda list
which python
python --version
export PATH="/usr/local/miniconda/envs/opengate_core/bin/:$PATH"
pip install wget colored
pip install wheel delocate
conda install conda-forge::qt6-main conda-forge::qt6-3d
mkdir -p $HOME/software
if [ "${{ steps.cache_opengate_core_dependencies.outputs.cache-hit }}" != 'true' ]; then
cd $HOME/software
mkdir geant4
cd geant4
mkdir src bin data
git clone --branch $GEANT4_VERSION https://github.com/Geant4/geant4.git --depth 1 src
cd bin
cmake -DCMAKE_CXX_FLAGS=-std=c++17 \
-DGEANT4_INSTALL_DATA=OFF \
-DGEANT4_INSTALL_DATADIR=$HOME/software/geant4/data \
-DGEANT4_USE_QT=ON \
-DGEANT4_USE_OPENGL_X11=OFF \
-DGEANT4_USE_QT_QT6=ON \
-DGEANT4_USE_SYSTEM_EXPAT=OFF \
-DGEANT4_BUILD_MULTITHREADED=ON \
-DGEANT4_USE_GDML=ON \
../src
make -j4
cd $HOME/software
mkdir itk
cd itk
mkdir src bin
git clone --branch $ITK_VERSION https://github.com/InsightSoftwareConsortium/ITK.git --depth 1 src
cd bin
cmake -DCMAKE_CXX_FLAGS=-std=c++17 \
-DBUILD_TESTING=OFF \
-DITK_USE_FFTWD=ON \
-DITK_USE_FFTWF=ON \
-DITK_USE_SYSTEM_FFTW:BOOL=ON \
../src
make -j4
fi
cd $GITHUB_WORKSPACE
source $HOME/software/geant4/bin/geant4make.sh
export CMAKE_PREFIX_PATH=$HOME/software/geant4/bin:$HOME/software/itk/bin/:${CMAKE_PREFIX_PATH}
cd core
mkdir opengate_core/plugins
cp -r /Users/runner/miniconda3/envs/opengate_core/lib/qt6/plugins/platforms/* opengate_core/plugins/
cp -r /Users/runner/miniconda3/envs/opengate_core/lib/qt6/plugins/imageformats opengate_core/plugins/
python3 setup.py sdist bdist_wheel
ls dist
export DYLD_LIBRARY_PATH=$HOME/software/geant4/bin/BuildProducts/lib:/Users/runner/miniconda3/envs/opengate_core/lib/qt6/plugins/platforms:/opt/X11/lib/:$DYLD_LIBRARY_PATH:/Users/runner/miniconda3/envs/opengate_core/lib
delocate-listdeps --all dist/*.whl
delocate-wheel -w fixed_wheels -v dist/*.whl
rm -rf dist
ls fixed_wheels
delocate-listdeps --all fixed_wheels/*.whl
mv fixed_wheels dist
cd dist
find . -name '*whl' -exec bash -c ' mv $0 ${0/macosx_13_0/macosx_10_9}' {} \;
cd ../..
mv core/dist .
- name: Create opengate_core Wheel Windows
if: matrix.os == 'windows-latest'
shell: bash -l {0}
run: |
choco install cmake
cmake --version
conda info
conda list
which python
python --version
export PATH="/usr/local/miniconda/envs/opengate_core/bin/:$PATH"
pip install wheel wget colored
pip install cibuildwheel==2.21.1
which pip
mkdir -p $HOME/software
if [ "${{ steps.cache_opengate_core_dependencies.outputs.cache-hit }}" != 'true' ]; then
cd $HOME/software
mkdir geant4
cd geant4
mkdir src bin data
git clone --branch $GEANT4_VERSION https://github.com/Geant4/geant4.git --depth 1 src
cd bin
cmake -DGEANT4_INSTALL_DATA=ON \
-DGEANT4_INSTALL_DATADIR=$HOME/software/geant4/data \
-DGEANT4_BUILD_MULTITHREADED=ON \
../src
cmake --build . --config Release
cd $HOME/software
mkdir itk
cd itk
mkdir src bin
git clone --branch $ITK_VERSION https://github.com/InsightSoftwareConsortium/ITK.git --depth 1 src
cd bin
cmake -DCMAKE_CXX_FLAGS=-std=c++17 \
-DBUILD_TESTING=OFF \
../src
cmake --build . --config Release
fi
cd $GITHUB_WORKSPACE
source $HOME/software/geant4/bin/geant4make.sh
export CMAKE_PREFIX_PATH=$HOME/software/geant4/bin:$HOME/software/itk/bin/:${CMAKE_PREFIX_PATH}
cd core
if [[ ${{ matrix.python-version }} == "3.9" ]]; then
export CIBW_BUILD="cp39-win_amd64"
elif [[ ${{ matrix.python-version }} == "3.10" ]]; then
export CIBW_BUILD="cp310-win_amd64"
elif [[ ${{ matrix.python-version }} == "3.11" ]]; then
export CIBW_BUILD="cp311-win_amd64"
elif [[ ${{ matrix.python-version }} == "3.12" ]]; then
export CIBW_BUILD="cp312-win_amd64"
fi
find $HOME/software/geant4/bin/ -iname "*.dll"
ls $HOME/software/geant4/bin/BuildProducts/Release/bin
ls $HOME/software/geant4/bin/BuildProducts/Release/lib/
export CIBW_BEFORE_BUILD="python -m pip install colored"
python -m cibuildwheel --output-dir dist
cd ..
mkdir core/dist2
pip install pefile machomachomangler
ls core/dist
python $GITHUB_WORKSPACE\\.github\\workflows\\delocateWindows.py core\\dist -w core\\dist2 -d C:\\Users\\runneradmin\\software\\geant4\\bin\\BuildProducts\\Release\\bin
mv core/dist2 dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}-${{ matrix.python-version }}-opengate-core
path: dist/
build_opengate_core_novis_wheel:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.9, '3.10', '3.11', '3.12']
env:
GEANT4_VERSION: 'v11.2.1'
ITK_VERSION: 'v5.2.1'
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Checkout submodules
shell: bash -l {0}
run: |
export GIT_SSL_NO_VERIFY=1
git submodule update --init --recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- name: Get OS version
id: get-os-version
shell: bash -l {0}
run: |
varOS=`cat /etc/os-release | grep "VERSION=" | grep -oP '(?<=\").*?(?=\")'`
varOS=($varOS)
echo "release=${varOS[0]}" >> $GITHUB_OUTPUT
- name: Cache modules
id: cache_opengate_core_dependencies
uses: actions/cache@v4
with:
path: ~/software
key: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build2
restore-keys: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build2
- name: Create opengate_core_novis Wheel Linux
run: |
if [ ${{ matrix.python-version }} == "3.9" ]; then
export PYTHONFOLDER="cp39-cp39"
elif [ ${{ matrix.python-version }} == "3.10" ]; then
export PYTHONFOLDER="cp310-cp310"
elif [ ${{ matrix.python-version }} == "3.11" ]; then
export PYTHONFOLDER="cp311-cp311"
elif [ ${{ matrix.python-version }} == "3.12" ]; then
export PYTHONFOLDER="cp312-cp312"
fi
mkdir -p $HOME/software
docker run --rm -e "PYTHONFOLDER=${PYTHONFOLDER}" -v $GITHUB_WORKSPACE:/home tbaudier/opengate_core:${{ env.GEANT4_VERSION }}_novis /home/.github/workflows/createWheelLinux_novis.sh
ls wheelhouse
rm -rf dist
mv wheelhouse dist
sudo chown -R runner:docker dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}-${{ matrix.python-version }}-opengate-core-novis
path: dist/
publish_wheel:
runs-on: ubuntu-latest
needs: [build_opengate_wheel, build_opengate_core_wheel]
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: dist-*
merge-multiple: true
path: dist/
- name: Separate the wheels
run: |
mkdir dist_opengate_core dist_opengate dist_opengate_core_novis
mv dist/opengate_core_novis-* dist_opengate_core_novis/ || true
mv dist/opengate_core-* dist_opengate_core/
mv dist/opengate-* dist_opengate/
- name: Publish to PyPI opengate_core_novis
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_OPENGATE_CORE }}
packages_dir: dist_opengate_core_novis/
skip_existing: true
- name: Publish to PyPI opengate_core
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_OPENGATE_CORE }}
packages_dir: dist_opengate_core/
skip_existing: true
- name: Publish to PyPI opengate
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_OPENGATE }}
packages_dir: dist_opengate/
skip_existing: true
# ssh_session:
# env:
# GEANT4_VERSION: 'v11.2.1'
# ITK_VERSION: 'v5.2.1'
# runs-on: macos-13
# steps:
# - name: Checkout github repo
# uses: actions/checkout@v4
# - name: Checkout submodules
# shell: bash -l {0}
# run: |
# export GIT_SSL_NO_VERIFY=1
# git submodule update --init --recursive
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: 3.9
# architecture: 'x64'
# - name: Get OS version
# id: get-os-version
# shell: bash -l {0}
# run: |
# varOS=`sw_vers | grep "ProductVersion:"`
# varOS="${varOS#*:}"
# echo "release=${varOS:1}" >> $GITHUB_OUTPUT
# - name: Cache modules
# id: cache_opengate_core_dependencies
# uses: actions/cache@v4
# with:
# path: ~/software
# key: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build2
# restore-keys: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build2
# - uses: conda-incubator/setup-miniconda@v3
# with:
# miniconda-version: "latest"
# auto-update-conda: true
# activate-environment: opengate_core
# python-version: 3.9
# - name: Set up Homebrew
# id: set-up-homebrew
# uses: Homebrew/actions/setup-homebrew@master
# - name: Start SSH session
# uses: luchihoratiu/debug-via-ssh@main
# with:
# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
# SSH_PASS: ${{ secrets.SSH_PASS }}
test_wheel:
runs-on: ${{ matrix.os }}
needs: [build_opengate_wheel, build_opengate_core_wheel]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
python-version: [3.9, '3.10', '3.11', '3.12']
steps:
- uses: actions/download-artifact@v4
with:
pattern: dist-*
merge-multiple: true
path: dist/
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- name: Run tests
shell: bash {0}
run: |
if [[ ${{ matrix.python-version }} == "3.9" ]]; then
export PYTHONFOLDER="cp39-cp39"
elif [[ ${{ matrix.python-version }} == "3.10" ]]; then
export PYTHONFOLDER="cp310-cp310"
elif [[ ${{ matrix.python-version }} == "3.11" ]]; then
export PYTHONFOLDER="cp311-cp311"
elif [[ ${{ matrix.python-version }} == "3.12" ]]; then
export PYTHONFOLDER="cp312-cp312"
fi
if [[ ${{ matrix.os }} == "ubuntu-latest" ]]; then
export OSNAME="manylinux"
export PLATFORM="x86_"
pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
elif [[ ${{ matrix.os }} == "macos-13" ]]; then
export OSNAME="macosx"
export PLATFORM="x86_"
which python
python --version
pip install torch
elif [[ ${{ matrix.os }} == "windows-latest" ]]; then
export OSNAME="win"
export PLATFORM="amd"
pip install torch
fi
pip install SimpleITK
pip install gaga_phsp==0.7.4
pip install spekpy
pip install dist/opengate_core-*-${PYTHONFOLDER}-${OSNAME}*_${PLATFORM}64.whl
pip install dist/opengate-*.whl
export GIT_SSL_NO_VERIFY=1
if [[ ${{ matrix.os }} == "ubuntu-latest" ]]; then
path=`opengate_library_path.py -p site_packages`
export LD_LIBRARY_PATH="${path}/opengate_core.libs":${LD_LIBRARY_PATH}
fi
if [[ ${{ matrix.os }} == "windows-latest" ]]; then
path=`opengate_library_path.py -p site_packages`
export LD_LIBRARY_PATH="${path}/opengate_core.libs":${LD_LIBRARY_PATH}
export PATH="${path}\\opengate_core.libs":${PATH}
fi
dashboard_path=`opengate_library_path.py -p tests`
pip freeze
if [ "${{ github.event_name }}" = "schedule" ]; then
OutputTest=$(opengate_tests)
else
OutputTest=$(opengate_tests -r)
fi
echo "$OutputTest"
ls $dashboard_path/../output_dashboard/
cp -r $dashboard_path/../output_dashboard .
OutputTest=$(echo "$OutputTest" | tail -1)
if [[ "$OutputTest" != "True" ]]; then
exit -1
else
exit 0
fi
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: results_json-${{ matrix.os }}-${{ matrix.python-version }}
path: output_dashboard/dashboard_output*.json
publish_test:
runs-on: ubuntu-latest
if: ${{ (always()) && (github.ref == 'refs/heads/master') }}
needs: [test_wheel]
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: results_json-*
merge-multiple: true
path: ./
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
auto-update-conda: true
activate-environment: vega-altair
python-version: '3.10'
- name: Merge the results
shell: bash -el {0}
run: |
git clone https://github.com/OpenGATE/opengate_tests_results.git
cd opengate_tests_results
echo $pwd
ls ..
cp ../dashboard_output_*.json .
conda install -c conda-forge altair-all
pip install pandas numpy
python compile_opengate_tests_results.py
- name: Pushes to another repository
continue-on-error: true
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.PUSH_OPENGATE_TESTS_RESULTS }}
with:
source-directory: 'opengate_tests_results'
destination-github-username: 'OpenGATE'
destination-repository-name: 'opengate_tests_results'
user-email: [email protected]
target-branch: master