-
Notifications
You must be signed in to change notification settings - Fork 0
400 lines (375 loc) · 14.1 KB
/
build-test.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
name: Build and ctest and recon_test_pack CI
on:
push:
branches:
- master
- tof_sino_UCL
paths-ignore:
- '.appveyor.yml'
- 'CITATION.cff'
- '**/*.md'
- '**/*.html'
- '**/*.htm'
- '**/*.tex'
pull_request:
branches:
- master
- tof_sino_UCL
paths-ignore:
- '.appveyor.yml'
- 'CITATION.cff'
- '**/*.md'
- '**/*.html'
- '**/*.htm'
- '**/*.tex'
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
compiler: gcc
compiler_version: 9
BUILD_FLAGS: "-DSTIR_OPENMP=ON"
BUILD_TYPE: "Release"
parallelproj: "ON"
ROOT: "ON"
ITK: "OFF"
- os: ubuntu-latest
compiler: clang
#compiler_version:
BUILD_FLAGS: "-DSTIR_OPENMP=ON"
BUILD_TYPE: "Release"
parallelproj: "ON"
ROOT: "OFF"
# currently using ITK 5.2 which doesn't like clang 14
ITK: "OFF"
- os: ubuntu-latest
compiler: gcc
compiler_version: 10
BUILD_FLAGS: "-DSTIR_OPENMP=ON -DCMAKE_CXX_STANDARD=17"
BUILD_TYPE: "Debug"
parallelproj: "OFF"
ROOT: "OFF"
ITK: "ON"
- os: ubuntu-latest
compiler: gcc
compiler_version: 12
BUILD_FLAGS: "-DSTIR_OPENMP=ON -DCMAKE_CXX_STANDARD=14"
BUILD_TYPE: "RelWithDebInfo"
parallelproj: "ON"
ROOT: "OFF"
ITK: "ON"
- os: macOS-latest
compiler: gcc
compiler_version: 11
BUILD_FLAGS: "-DSTIR_OPENMP=OFF"
parallelproj: "OFF"
BUILD_TYPE: "Debug"
ROOT: "OFF"
ITK: "OFF"
# Currently disabled due to problems with listmode recon, see https://github.com/UCL/STIR/issues/1200
#- os: macOS-latest
# compiler: clang
# compiler_version: 16
# BUILD_FLAGS: "-DSTIR_OPENMP=OFF"
# parallelproj: "OFF"
# BUILD_TYPE: "Release"
# ROOT: "OFF"
# ITK: "OFF"
# let's run all of them, as opposed to aborting when one fails
fail-fast: false
name: ${{ matrix.os }}-${{ matrix.compiler }}${{ matrix.compiler_version }}-${{ matrix.BUILD_TYPE }}-pp=${{ matrix.parallelproj }}-ROOT=${{ matrix.ROOT }}
steps:
- name: disk space
shell: bash
run: |
case ${{matrix.os}} in
(ubuntu* | macOS*)
df -h
# saves about 2GB
echo removing dotnet
sudo rm -rf /usr/share/dotnet
# saves about 10 GB
echo removing agent_tools
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# saves about 10 GB
echo removing android files
sudo rm -rf /usr/local/lib/android
df -h
;;
(windows*)
# no idea how to do this
;;
esac
- uses: actions/checkout@v3
with:
submodules: recursive
- name: disk space
shell: bash
run: |
case ${{matrix.os}} in
(ubuntu* | macOS*)
sudo .github/workflows/GHA_increase_disk_space.sh
;;
(windows*)
# no idea what to do here
;;
esac
- name: set_compiler_variables
shell: bash
run: |
set -ex
if test 'XX${{ matrix.compiler }}' = 'XXclang'; then
CC="clang"
CXX="clang++"
elif test 'XX${{ matrix.compiler }}' = 'XXgcc'; then
CC="gcc"
CXX="g++"
fi
if test 'XX${{ matrix.compiler_version }}' != 'XX'; then
CC=${CC}-${{ matrix.compiler_version }}
CXX=${CXX}-${{ matrix.compiler_version }}
fi
if test 'XX${{ matrix.os }}' = 'XXmacOS-latest'; then
# need to force XCode version for the moment due to a linker bug
# see https://github.com/UCL/STIR/issues/1103
echo DEVELOPER_DIR="/Applications/Xcode_14.1.app/Contents/Developer" >> $GITHUB_ENV
if test 'XX${{ matrix.compiler }}' = 'XXclang'; then
brew install llvm@${{ matrix.compiler_version }}
if test XX${HOMEBREW_PREFIX} = XX; then
HOMEBREW_PREFIX=/usr/local
fi
LDFLAGS="-L$HOMEBREW_PREFIX/opt/llvm/lib/c++ -Wl,-rpath,$HOMEBREW_PREFIX/opt/llvm/lib/c++"
# make available to jobs below
echo LDFLAGS="$LDFLAGS" >> $GITHUB_ENV
CC="$HOMEBREW_PREFIX/opt/llvm/bin/clang"
CXX="$HOMEBREW_PREFIX/opt/llvm/bin/clang++"
fi
fi
export CC CXX
# make available to jobs below
echo CC="$CC" >> $GITHUB_ENV
echo CXX="$CXX" >> $GITHUB_ENV
- name: install_dependencies
shell: bash
run: |
set -ex
# We will install some external dependencies here
CMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install
case ${{matrix.os}} in
(ubuntu*)
sudo apt update
# install compiler
if test 'XX${{ matrix.compiler }}' = 'XXclang'; then
# package is called clang, need libomp-dev for OpenMP support
sudo apt install $CC libomp-dev
else
sudo apt install $CXX
fi
# other dependencies
sudo apt install libboost-dev libhdf5-serial-dev swig python3-dev nlohmann-json3-dev
if test "${{matrix.ITK}}XX" == "ONXX"; then
sudo apt install libinsighttoolkit5-dev
fi
# free up some disk space
sudo apt clean
PYTHON_EXECUTABLE=$(which python3)
;;
(macOS*)
brew install boost swig python nlohmann-json
PYTHON_EXECUTABLE=$(which python3)
;;
(windows*)
# this compiles the whole thing so takes ages
vcpkg install boost-core hdf5 nlohmann-json
# swig is preinstalled and is currently not in vcpcg
vcpkg list
PYTHON_EXECUTABLE=$(which python3)
;;
esac
echo PYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" >> $GITHUB_ENV
${PYTHON_EXECUTABLE} -m venv ${GITHUB_WORKSPACE}/my-env
source ${GITHUB_WORKSPACE}/my-env/bin/activate
#python -m pip install -U pip
case ${{matrix.os}} in
(macOS*)
# attempt to get round buggy Accelerate builds, see https://github.com/numpy/numpy/issues/15947
# but it didn't work, so commented out
# brew install openblas
# export OPENBLAS=$(brew --prefix openblas)
#python -m pip install --no-cache-dir --no-binary numpy numpy # avoid the cached .whl!
python -m pip install numpy
;;
(*)
python -m pip install numpy
;;
esac
python -m pip install pytest
if test "${{matrix.parallelproj}}XX" == "ONXX"; then
git clone --depth 1 --branch v1.3.7 https://github.com/gschramm/parallelproj
mkdir parallelproj/build
cd parallelproj/build
cmake .. -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DSKIP_CUDA_LIB:BOOL=ON
cmake --build . --target install --config Release
cd ../..
fi
# Install ROOT (warning: currently only valid on Ubuntu)
if test "${{matrix.ROOT}}XX" == "ONXX"; then
wget https://root.cern/download/root_v6.24.02.Linux-ubuntu20-x86_64-gcc9.3.tar.gz
tar -xzvf root_v6.24.02.Linux-ubuntu20-x86_64-gcc9.3.tar.gz
source root/bin/thisroot.sh
fi
# we'll install some dependencies with shared libraries, so need to let the OS know
# thisroot.sh also modified the path, so save that for the recon_test_pack
case ${{matrix.os}} in
(ubuntu*)
echo LD_LIBRARY_PATH="${CMAKE_INSTALL_PREFIX}/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo PATH="$PATH" >> $GITHUB_ENV
;;
(macOS*)
echo DYLD_FALLBACK_LIBRARY_PATH="${CMAKE_INSTALL_PREFIX}/lib:$DYLD_FALLBACK_LIBRARY_PATH" >> $GITHUB_ENV
echo PATH="$PATH" >> $GITHUB_ENV
;;
(windows*)
echo PATH="${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/bin:$PATH" >> $GITHUB_ENV
;;
esac
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.compiler_version }}-${{ matrix.BUILD_TYPE }}
max-size: "2G"
- name: configure
shell: bash
env:
BUILD_TYPE: ${{ matrix.BUILD_TYPE }}
BUILD_FLAGS: ${{ matrix.BUILD_FLAGS }}
run: |
set -ex
source ${GITHUB_WORKSPACE}/my-env/bin/activate
#export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --version
if test "XX$CC" != "XX"; then
$CC --version
$CXX --version
fi
CMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install
# make available to jobs below
echo CMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" >> $GITHUB_ENV
EXTRA_BUILD_FLAGS="-DBUILD_SWIG_PYTHON=ON -DPYTHON_EXECUTABLE=`which python`"
EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} -DDOWNLOAD_ZENODO_TEST_DATA=ON"
EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} -DDISABLE_STIR_LOCAL=OFF -DSTIR_LOCAL=${GITHUB_WORKSPACE}/examples/C++/src"
echo "cmake flags $BUILD_FLAGS $EXTRA_BUILD_FLAGS"
mkdir build
cd build
cmake -S .. ${BUILD_FLAGS} ${EXTRA_BUILD_FLAGS}
# report disk space
case ${{matrix.os}} in
(ubuntu* | macOS*)
df -h
;;
(windows*)
# no idea how to do this
;;
esac
- name: build
shell: bash
env:
BUILD_TYPE: ${{ matrix.BUILD_TYPE }}
run: |
cd ${GITHUB_WORKSPACE}/build;
source ${GITHUB_WORKSPACE}/my-env/bin/activate
cmake --build . -j 2 --config ${BUILD_TYPE}} --target install
- name: ctest
shell: bash
env:
BUILD_TYPE: ${{ matrix.BUILD_TYPE }}
run: |
cd ${GITHUB_WORKSPACE}/build
# don't run all of them in Debug mode as it takes too long
if test ${BUILD_TYPE} = Debug; then
EXCLUDE="-E test_data_processor_projectors|test_export_array|test_ArcCorrection"
fi
ctest --output-on-failure -C ${BUILD_TYPE} ${EXCLUDE}
- name: recon_test_pack
shell: bash
env:
BUILD_FLAGS: ${{ matrix.BUILD_FLAGS }}
BUILD_TYPE: ${{ matrix.BUILD_TYPE }}
run: |
set -ex;
PATH=${CMAKE_INSTALL_PREFIX}/bin:$PATH
cd ${GITHUB_WORKSPACE}/recon_test_pack
./run_tests.sh --nointbp
# don't run all of them in Debug mode as it takes too long
if test ${BUILD_TYPE} != Debug; then
./run_test_simulate_and_recon.sh
./run_test_listmode_recon.sh
./run_test_simulate_and_recon_with_motion.sh
./run_scatter_tests.sh
./run_test_zoom_image.sh
./run_ML_norm_tests.sh
if test "${{matrix.ROOT}}XX" == "ONXX"; then ./run_root_GATE.sh; fi
./run_tests_modelling.sh
cd ${GITHUB_WORKSPACE}/recon_test_pack/SPECT
./run_SPECT_tests.sh
fi
- name: Upload log files for debugging
uses: actions/upload-artifact@v3
if: failure()
with:
name: recon_test_pack_log_files-${{ matrix.os }}-${{ matrix.compiler }}${{ matrix.compiler_version }}-${{ matrix.BUILD_TYPE }}-pp=${{ matrix.parallelproj }}-ROOT=${{ matrix.ROOT }}
path: |
${{ github.workspace }}/recon_test_pack/**/*.log
${{ github.workspace }}/recon_test_pack/**/my_*v
${{ github.workspace }}/recon_test_pack/**/my_*s
retention-days: 7
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session if triggered
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled == 'true' }}
- name: examples
shell: bash
run: |
set -ex;
PATH=${CMAKE_INSTALL_PREFIX}/bin:$PATH
# Run examples to see if they work
cd ${GITHUB_WORKSPACE}/examples/PET_simulation
./run_simulation.sh 1> /dev/null
# Run the Demo executables
EXE_LOC=${GITHUB_WORKSPACE}/build/src/examples/C++
cd ${GITHUB_WORKSPACE}/examples/C++/src
generate_image generate_image.par
forward_project sino.hs image.hv small.hs
# Cannot test demo1 or demo2 as they require interactivity. Piping does not work.
${EXE_LOC}/demo3 demo.par --display_off
${EXE_LOC}/demo3 demoPM.par --display_off
${EXE_LOC}/demo4_obj_fun demo4_obj_fun.par
${EXE_LOC}/demo5_line_search demo5_line_search.par
- name: Python
shell: bash
run: |
set -ex
source ${GITHUB_WORKSPACE}/my-env/bin/activate
# Run Python tests, making sure we're using the correct Python interpreter
which python
export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/python
cd ${GITHUB_WORKSPACE}/src
case ${{matrix.os}} in
(macOS*)
echo skipping pytest due to numpy problem for now.
;;
(*)
python -m pytest .
;;
esac