-
Notifications
You must be signed in to change notification settings - Fork 116
235 lines (207 loc) · 9.18 KB
/
ElastixGitHubActions.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
name: Elastix
on: [push, pull_request]
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 3
matrix:
os: [ubuntu-22.04, windows-2022, macos-12]
include:
- os: ubuntu-22.04
c-compiler: "gcc"
cxx-compiler: "g++"
itk-git-tag: "v5.4.0"
cmake-build-type: "Release"
ANNLib: "libANNlib-5.2.so"
ANNLib2: "libANNlib-5.2.so.1"
- os: windows-2022
c-compiler: "cl.exe"
cxx-compiler: "cl.exe"
itk-git-tag: "v5.4.0"
cmake-build-type: "Release"
ANNLib: "ANNlib-5.2.dll"
vcvars64: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
- os: macos-12
c-compiler: "clang"
cxx-compiler: "clang++"
itk-git-tag: "v5.4.0"
cmake-build-type: "Release"
ANNLib: "libANNlib-5.2.1.dylib"
ANNLib2: "libANNlib-5.2.dylib"
steps:
- uses: actions/checkout@v3
- name: Make directory structure
run: |
items=(*)
mkdir Elastix-source
mv ${items[*]} Elastix-source
mv .editorconfig Elastix-source
mv .clang-format Elastix-source
mv Elastix-source/Dockerfile .
shell: bash
- uses: actions/cache@v3
id: cache
with:
path: |
ITK-build
ITK-source
key: ${{ matrix.itk-git-tag }}-${{ matrix.os }}-${{ matrix.cmake-build-type }}
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ninja
- name: Get specific version of CMake, Ninja
uses: lukka/[email protected]
- name: Download ITK
if: steps.cache.outputs.cache-hit != 'true'
run: |
git clone https://github.com/InsightSoftwareConsortium/ITK.git ITK-source
cd ITK-source
git checkout ${{ matrix.itk-git-tag }}
- name: Build ITK
if: ${{ steps.cache.outputs.cache-hit != 'true' && !startsWith(matrix.os, 'windows') }}
run: |
mkdir ITK-build
cd ITK-build
cmake -DCMAKE_C_COMPILER:FILEPATH="${{ matrix.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.cmake-build-type }} -DBUILD_EXAMPLES=OFF -DBUILD_TESTING:BOOL=OFF -DITK_LEGACY_REMOVE=ON -GNinja ../ITK-source
ninja
- name: Build ITK
if: steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.os, 'windows')
run: |
mkdir ITK-build
cd ITK-build
call "${{ matrix.vcvars64 }}"
cmake -DCMAKE_C_COMPILER:FILEPATH="${{ matrix.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.cmake-build-type }} -DBUILD_EXAMPLES=OFF -DBUILD_TESTING:BOOL=OFF -GNinja ../ITK-source
ninja
shell: cmd
- name: Install requirements of PythonTests
run: |
python -m pip install -r ${{ github.workspace }}/Elastix-source/Testing/PythonTests/requirements.txt
- name: Configure CTest script
shell: bash
run: |
operating_system="${{ matrix.os }}"
cat > dashboard.cmake << EOF
set(CTEST_SITE "GitHubActions")
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}" CTEST_DASHBOARD_ROOT)
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/Elastix-source" CTEST_SOURCE_DIRECTORY)
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/Elastix-build" CTEST_BINARY_DIRECTORY)
set(dashboard_source_name "${GITHUB_REPOSITORY}")
set(branch "${GITHUB_REF#refs/heads/}")
set(sha "${GITHUB_SHA}")
set(dashboard_model "Experimental")
set(CTEST_BUILD_NAME "${GITHUB_REPOSITORY}-${operating_system}-\${branch}-\${sha}")
set(CTEST_UPDATE_VERSION_ONLY 1)
set(CTEST_TEST_ARGS \${CTEST_TEST_ARGS} PARALLEL_LEVEL \${PARALLEL_LEVEL})
set(CTEST_BUILD_CONFIGURATION "Release")
set(CTEST_CMAKE_GENERATOR "Ninja")
set(dashboard_no_clean 1)
set(ENV{CC} ${{ matrix.c-compiler }})
set(ENV{CXX} ${{ matrix.cxx-compiler }})
if(WIN32)
set(ENV{PATH} "\${CTEST_DASHBOARD_ROOT}/ITK-build/bin;\$ENV{PATH}")
endif()
set(dashboard_cache "
ITK_DIR:PATH=\${CTEST_DASHBOARD_ROOT}/ITK-build
ELASTIX_USE_GTEST:BOOL=ON
USE_ALL_COMPONENTS:BOOL=ON
BUILD_TESTING:BOOL=ON
")
string(TIMESTAMP build_date "%Y-%m-%d")
message("CDash Build Identifier: \${build_date} \${CTEST_BUILD_NAME}")
message("CTEST_SITE= \${CTEST_SITE}")
include(\${CTEST_SOURCE_DIRECTORY}/Testing/Dashboard/elxCommonCDash.cmake)
EOF
cat dashboard.cmake
- name: Test MacOs
if: startsWith(matrix.os, 'macos')
run: |
ctest --output-on-failure -VV -j 2 -E "elastix_run_example_COMPARE_IM|elastix_run_3DCT_lung.MI.bspline.ASGD.001_COMPARE_TP|elastix_run_3DCT_lung.NMI.bspline.ASGD.001_COMPARE_TP" -S dashboard.cmake
- name: Test Windows
if: startsWith(matrix.os, 'windows')
run: |
call "${{ matrix.vcvars64 }}"
ctest --output-on-failure -VV -j 2 -E "elastix_run_example_COMPARE_IM|elastix_run_3DCT_lung.MI.bspline.ASGD.001_COMPARE_TP" -S dashboard.cmake
shell: cmd
- name: Test Ubuntu
if: startsWith(matrix.os, 'ubuntu')
run: |
ctest --output-on-failure -VV -j 2 -E "elastix_run_example_COMPARE_IM|elastix_run_3DCT_lung.MI.bspline.ASGD.001_COMPARE_TP" -S dashboard.cmake
- name: Build externalproject example
if: ${{ !startsWith(matrix.os, 'windows') }}
run: |
mkdir externalproject-build
cd externalproject-build
cmake -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DElastix_DIR=${{ github.workspace }}/Elastix-build -GNinja ../Elastix-source/dox/externalproject
ninja
- name: Build externalproject example
if: startsWith(matrix.os, 'windows')
run: |
mkdir externalproject-build
cd externalproject-build
call "${{ matrix.vcvars64 }}"
cmake -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DElastix_DIR=${{ github.workspace }}/Elastix-build -GNinja ../Elastix-source/dox/externalproject
ninja
shell: cmd
- name: Run externalproject example
if: ${{ !startsWith(matrix.os, 'windows') }}
run: |
externalproject-build/elastix_translation_example
- name: Run externalproject example
if: startsWith(matrix.os, 'windows')
run: |
set path=${{ github.workspace }}\Elastix-build\bin
externalproject-build\elastix_translation_example.exe
shell: cmd
- name: Prepare Artifacts Unix
if: ${{ !startsWith(matrix.os, 'windows') }}
shell: bash
run: |
mkdir bin
mkdir lib
mkdir uploads
mv Elastix-build/bin/elastix bin
mv Elastix-build/bin/transformix bin
mv Elastix-build/bin/${{ matrix.ANNLib }} lib
mv Elastix-build/bin/${{ matrix.ANNLib2 }} lib
mv Elastix-source/NOTICE uploads
mv Elastix-source/LICENSE uploads
mv bin uploads
mv lib uploads
- name: Prepare Artifacts Windows
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
mkdir uploads
mv Elastix-source/NOTICE uploads
mv Elastix-source/LICENSE uploads
mv Elastix-build/bin/elastix.exe uploads
mv Elastix-build/bin/transformix.exe uploads
mv Elastix-build/bin/${{ matrix.ANNLib }} uploads
- name: Publish Artifacts
uses: actions/upload-artifact@v3
with:
name: "${{ matrix.os }}"
path: uploads
- name: Login to Docker Hub
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && startsWith(matrix.os, 'ubuntu')
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && startsWith(matrix.os, 'ubuntu')
run: |
mkdir output
docker build -t superelastix/elastix:${GITHUB_REF#refs/tags/} .
docker run -u $UID:$GROUPS --mount type=bind,source="$(pwd)"/output,target=/out -v "$(pwd)"/Elastix-source/Testing/Data:/elastix/ superelastix/elastix:${GITHUB_REF#refs/tags/} elastix -out /out/ -p /elastix/parameters.3D.NC.euler.ASGD.001.txt -f /elastix/3DCT_lung_baseline.mha -m /elastix/3DCT_lung_followup.mha
docker push superelastix/elastix:${GITHUB_REF#refs/tags/}