-
Notifications
You must be signed in to change notification settings - Fork 0
412 lines (397 loc) · 16.9 KB
/
build-ants.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
name: Build ANTs
on:
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
git_ref:
description: 'Upstream ANTsX/ANTs commit ref to check out when building'
required: true
default: 'b37e8b56e4e518b0f2947f80d0e3701a5ddfe120'
jobs:
build:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, macos-10.15]
runs-on: ${{ matrix.os }}
steps:
# first, rewrite OS names to be safe for github artifacts.
- name: names
run: |
OS="${{ matrix.os }}"
OS=$(echo "$OS" | sed s/://)
echo "ARTIFACT=$OS" >> $GITHUB_ENV
- name: Downgrade OS X Version
if: matrix.os == 'macos-10.15'
run: |
echo "CMAKE_CXX_FLAGS=-mmacosx-version-min=10.12" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
repository: ANTsX/ANTs
# NB: This commit mirrors the state of the kousu/ANTs repository
# at the time of https://github.com/kousu/ANTs/pull/5.
ref: ${{ github.event.inputs.git_ref || 'b37e8b56e4e518b0f2947f80d0e3701a5ddfe120' }}
# The step below sets an option inside the cmake file to use the `https` protocol, which addresses:
# https://github.blog/2021-09-01-improving-git-protocol-security-github/#no-more-unauthenticated-git
- name: Patch in fix for insecure git:// protocol
run: |
perl -pi -e 's/http instead." ON\)/http instead." OFF\)/g' SuperBuild.cmake
- name: cmake generate
run: |
mkdir antsbin
cd antsbin
# TODO: check if cmake picks up CMAKE_CXX_FLAGS without being told about it
# NB: `BUILD_TESTING=OFF` fixes https://github.com/ANTsX/ANTs/issues/1236
cmake \
-DBUILD_TESTING=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \
../
- name: make
working-directory: antsbin
run: |
make VERBOSE=1 -j 4
timeout-minutes: 300
# for debugging, don't let a crash/timeout here fail the whole build
# (github CI seems glitchy about giving reliable output about what happened on timeouts)
continue-on-error: true
- name: pre-package
run: |
mkdir fakeroot/
cd antsbin/ANTS-build
make VERBOSE=1 -j 4 DESTDIR="../../fakeroot" install
continue-on-error: true
- name: package
run: |
# snip out the apps we need for https://github.com/neuropoly/spinalcordtoolbox, since including all of ANTS is too much
mkdir sct-apps/
cp antsbin/ANTS-build/Examples/{antsRegistration,antsSliceRegularizedRegistration,antsApplyTransforms,ComposeMultiTransform} sct-apps
(cd sct-apps; for i in *; do mv $i isct_$i; done)
cp COPYING.txt sct-apps
tar -zcvf sct-apps_${{ env.ARTIFACT }}.tar.gz sct-apps/
continue-on-error: true
- name: results (DEBUG)
run: find .
- name: Upload result
uses: actions/upload-artifact@v2-preview
with:
name: sct-apps_${{ env.ARTIFACT }}
#path: fakeroot/ # this is 2.3G large in this build
path: sct-apps_${{ env.ARTIFACT }}.tar.gz
build-manylinuxes: # Github only supports Ubuntu natively; for other Linuxes, we need to use Docker
strategy:
matrix:
os: ['centos:7'] # 'quay.io/centos/centos:stream8', 'archlinux']
# 'centos:stream8' and 'archlinux' are currently broken. However, we don't currently use either build in our
# `spinalcordtoolbox-binaries` repo. So, we just temporarily disable for now.
runs-on: ubuntu-latest
container: ${{ matrix.os }}
steps:
- name: install centos toolchain
if: contains(matrix.os, 'centos')
run: |
yum install -y make gcc gcc-c++ git zlib-devel
- name: install centos toolchain
if: contains(matrix.os, 'centos:stream8')
run: |
yum install -y cmake
- name: install centos toolchain
if: contains(matrix.os, 'centos:7')
run: |
# centos7 has a new enough cmake available, but it's not in the default repo
yum install -y epel-release
yum install -y cmake3
ln -s /usr/bin/cmake3 /usr/bin/cmake # make it the default
- name: install archlinux toolchain
if: contains(matrix.os, 'archlinux')
run: |
pacman -Syy --noconfirm make cmake gcc git libffi
# first, rewrite OS names to be safe for github artifacts.
- name: names
run: |
OS="${{ matrix.os }}"
OS=$(echo "$OS" | sed s/://)
echo "ARTIFACT=$OS" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
repository: ANTsX/ANTs
# NB: This commit mirrors the state of the kousu/ANTs repository
# at the time of https://github.com/kousu/ANTs/pull/5.
ref: ${{ github.event.inputs.git_ref || 'b37e8b56e4e518b0f2947f80d0e3701a5ddfe120' }}
# The step below sets an option inside the cmake file to use the `https` protocol, which addresses:
# https://github.blog/2021-09-01-improving-git-protocol-security-github/#no-more-unauthenticated-git
- name: Patch in fix for insecure git:// protocol
run: |
perl -pi -e 's/http instead." ON\)/http instead." OFF\)/g' SuperBuild.cmake
- name: context
run: |
set -x
set
pwd
whoami
hostname || true
df -h || true
uname -a
gcc -v
cmake --version
ifconfig
curl ifconfig.me
continue-on-error: true
- name: cmake generate
run: |
mkdir antsbin
cd antsbin
# NB: `BUILD_TESTING=OFF` fixes https://github.com/ANTsX/ANTs/issues/1236
cmake \
-DBUILD_TESTING=OFF \
-DBUILD_SHARED_LIBS=OFF \
../
- name: make
working-directory: antsbin
run: |
make VERBOSE=1 -j 4
timeout-minutes: 300
# for debugging, don't let a crash/timeout here fail the whole build
# (github CI seems glitchy about giving reliable output about what happened on timeouts)
continue-on-error: true
- name: pre-package
run: |
mkdir fakeroot/
cd antsbin/ANTS-build
make VERBOSE=1 -j 4 DESTDIR="../../fakeroot" install
continue-on-error: true
- name: package
run: |
# snip out the apps we need for https://github.com/neuropoly/spinalcordtoolbox, since including all of ANTS is too much
mkdir sct-apps/
cp antsbin/ANTS-build/Examples/{antsRegistration,antsSliceRegularizedRegistration,antsApplyTransforms,ComposeMultiTransform} sct-apps
(cd sct-apps; for i in `ls`; do mv $i isct_$i; done)
cp COPYING.txt sct-apps
tar -zcvf sct-apps_${{ env.ARTIFACT }}.tar.gz sct-apps/
continue-on-error: true
- name: results (DEBUG)
run: find .
- name: Upload result
uses: actions/upload-artifact@v2-preview
with:
name: sct-apps_${{ env.ARTIFACT }}
#path: fakeroot/ # this is 2.3G large in this build
path: sct-apps_${{ env.ARTIFACT }}.tar.gz
build-windows:
strategy:
matrix:
os: [ windows-2019 ]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
# first, rewrite OS names to be safe for github artifacts.
- name: names
run: |
OS="${{ matrix.os }}"
OS=$(echo "$OS" | sed s/://)
echo "ARTIFACT=$OS" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
repository: ANTsX/ANTs
# NB: This commit mirrors the state of the kousu/ANTs repository
# at the time of https://github.com/kousu/ANTs/pull/5.
ref: ${{ github.event.inputs.git_ref || 'b37e8b56e4e518b0f2947f80d0e3701a5ddfe120' }}
# The step below sets an option inside the cmake file to use the `https` protocol, which addresses:
# https://github.blog/2021-09-01-improving-git-protocol-security-github/#no-more-unauthenticated-git
- name: Patch in fix for insecure git:// protocol
run: |
perl -pi -e 's/http instead." ON\)/http instead." OFF\)/g' SuperBuild.cmake
########################################## START OF ITK WORKAROUND ###############################################
# ITK v5.1 has an upstream bug (https://github.com/InsightSoftwareConsortium/ITK/issues/1967) that prevents
# building ITK with MS Visual Studio 2019 (which is what the `windows-2019` GitHub Actions runner uses). This bug
# was fixed in ITK v5.2.
#
# Normally, to pull in an upstream fix, we would update ANTs, which in turn would update ITK (because the `make`
# step for ANTs clones ITK to a specific commit, hardcoded by ANTs in its External_ITKv5.cmake file). However,
# updating ANTs to pull in the ITK v5.2 fix has the side effect of changing the registration results on SCT's end.
#
# So, we need a way to apply a fix for the ITK issue that *doesn't* involve updating ANTs. Luckily, there is a
# quick and dirty workaround, described here: https://github.com/SuperElastix/SimpleElastix/pull/425#issuecomment-878516818
#
# In order to apply the workaround, we have to manually clone ITK ourselves (prior to the ANTs `make` step),
# then apply the fix, then continue on with building ANTs normally.
#
# TODO: Remove this fix after we update ANTs to a version that uses ITK v5.2 or higher.
##################################################################################################################
- name: 'WORKAROUND: Manually clone ITK'
run: |
mkdir antsbin
cd antsbin
git clone https://github.com/InsightSoftwareConsortium/ITK.git ITKv5
cd ITKv5
git checkout 1e708db2f586997e408cfdc2cea5114ae5575892 # This commit corresponds to:
# https://github.com/ANTsX/ANTs/blob/b37e8b56e4e518b0f2947f80d0e3701a5ddfe120/SuperBuild/External_ITKv5.cmake#L154
# i.e. the ITK commit specified by the version of ANTs we're currently using.
- name: 'WORKAROUND: Apply fix for `lrintf` issue in ITK dependency'
run: sed -i '93,120d' antsbin/ITKv5/Modules/ThirdParty/OpenJPEG/src/openjpeg/opj_includes.h
- name: 'WORKAROUND: Skip ITK clone in Superbuild'
run: |
# These `sed` commands remove the git project settings from the `ExternalProject_Add` cmake function call
sed -i '/ GIT_REPOSITORY ${${proj}_REPOSITORY}/d' SuperBuild/External_ITKv5.cmake
sed -i '/ GIT_TAG ${${proj}_GIT_TAG}/d' SuperBuild/External_ITKv5.cmake
########################################### END OF ITK WORKAROUND ################################################
- name: cmake generate
run: |
cd antsbin
# NB: `BUILD_TESTING=OFF` fixes https://github.com/ANTsX/ANTs/issues/1236
cmake \
-DBUILD_TESTING=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DZLIB_INCLUDE_DIR=D:\lib\zlib \
-DZLIB_LIBRARY=D:\lib\zlib\libz.dll.a \
../
- name: Add msbuild to PATH
uses: microsoft/[email protected]
with:
msbuild-architecture: x64
- name: make
working-directory: antsbin
shell: cmd
run: |
msbuild ALL_BUILD.vcxproj -property:Configuration=Release
timeout-minutes: 300
# for debugging, don't let a crash/timeout here fail the whole build
# (github CI seems glitchy about giving reliable output about what happened on timeouts)
continue-on-error: true
- name: package
run: |
# snip out the apps we need for https://github.com/neuropoly/spinalcordtoolbox, since including all of ANTS is too much
mkdir sct-apps/
cp antsbin/ANTS-build/Examples/Release/{antsRegistration,antsSliceRegularizedRegistration,antsApplyTransforms,ComposeMultiTransform}.exe sct-apps
(cd sct-apps; for i in `ls`; do mv $i isct_$i; done)
cp COPYING.txt sct-apps
tar -zcvf sct-apps_${{ env.ARTIFACT }}.tar.gz sct-apps/
continue-on-error: true
- name: results (DEBUG)
run: find .
- name: Upload result
uses: actions/upload-artifact@v2-preview
with:
name: sct-apps_${{ env.ARTIFACT }}
path: sct-apps_${{ env.ARTIFACT }}.tar.gz
release:
needs: [build, build-manylinuxes, build-windows]
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# name the release with the run_id to allow multiple builds on the same branch/tag
# https://github.com/actions/create-release/issues/2#issuecomment-613591846
tag_name: ${{ github.ref }}-${{github.run_id }}
release_name: Release ${{ github.sha }}
draft: true
prerelease: true
- uses: actions/download-artifact@v1
with:
name: sct-apps_centos7
continue-on-error: true
- name: checkin # DEBUG
run: find .
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./sct-apps_centos7/sct-apps_centos7.tar.gz
asset_name: sct-apps_centos7.tar.gz
asset_content_type: application/gzip
continue-on-error: true
# - uses: actions/download-artifact@v1
# with:
# name: sct-apps_centos8
# continue-on-error: true
# - name: checkin # DEBUG
# run: find .
# - name: Upload Release Asset
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
# asset_path: ./sct-apps_centos8/sct-apps_centos8.tar.gz
# asset_name: sct-apps_centos8.tar.gz
# asset_content_type: application/gzip
# continue-on-error: true
#
# - uses: actions/download-artifact@v1
# with:
# name: sct-apps_archlinux
# continue-on-error: true
# - name: Upload Release Asset
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./sct-apps_archlinux/sct-apps_archlinux.tar.gz
# asset_name: sct-apps_archlinux.tar.gz
# asset_content_type: application/gzip
# continue-on-error: true
- uses: actions/download-artifact@v1
with:
name: sct-apps_ubuntu-20.04
continue-on-error: true
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./sct-apps_ubuntu-20.04/sct-apps_ubuntu-20.04.tar.gz
asset_name: sct-apps_ubuntu-20.04.tar.gz
asset_content_type: application/gzip
continue-on-error: true
- uses: actions/download-artifact@v1
with:
name: sct-apps_ubuntu-18.04
continue-on-error: true
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./sct-apps_ubuntu-18.04/sct-apps_ubuntu-18.04.tar.gz
asset_name: sct-apps_ubuntu-18.04.tar.gz
asset_content_type: application/gzip
continue-on-error: true
- uses: actions/download-artifact@v1
with:
name: sct-apps_macos-10.15
continue-on-error: true
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./sct-apps_macos-10.15/sct-apps_macos-10.15.tar.gz
asset_name: sct-apps_macos-10.15.tar.gz
asset_content_type: application/gzip
continue-on-error: true
- uses: actions/download-artifact@v1
with:
name: sct-apps_windows-2019
continue-on-error: true
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./sct-apps_windows-2019/sct-apps_windows-2019.tar.gz
asset_name: sct-apps_windows-2019.tar.gz
asset_content_type: application/gzip
continue-on-error: true