-
Notifications
You must be signed in to change notification settings - Fork 5
430 lines (363 loc) Β· 15 KB
/
build-test-package.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
name: Build, test, package
on: [push,pull_request]
env:
itk-git-tag: "v5.4.0"
itk-wheel-tag: "v5.4.0"
# v5.4.0 + fixes
itk-python-package-tag: "c9bb40bcb9f99938d071435e46f44d3d2b389482"
itk-python-package-org: "InsightSoftwareConsortium"
ctest-options: ""
jobs:
build-test-cxx:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 3
matrix:
os: [ubuntu-22.04, windows-2022, macos-12, macos-14]
include:
- os: ubuntu-22.04
c-compiler: "gcc"
cxx-compiler: "g++"
cmake-build-type: "MinSizeRel"
- os: windows-2022
c-compiler: "cl.exe"
cxx-compiler: "cl.exe"
cmake-build-type: "Release"
- os: macos-12
c-compiler: "clang"
cxx-compiler: "clang++"
cmake-build-type: "MinSizeRel"
- os: macos-14
c-compiler: "clang"
cxx-compiler: "clang++"
cmake-build-type: "MinSizeRel"
steps:
- uses: actions/checkout@v4
- name: Free Disk Space (Ubuntu)
if: matrix.os == 'ubuntu-22.04'
uses: jlumbroso/[email protected]
with:
large-packages: false
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: shogo82148/actions-setup-perl@v1
- uses: ilammy/setup-nasm@v1
- name: Get specific version of CMake, Ninja
uses: lukka/[email protected]
- name: 'Specific XCode version'
if: matrix.os == 'macos-12'
run: |
sudo xcode-select -s "/Applications/Xcode_13.2.1.app"
- name: 'Specific XCode version'
if: matrix.os == 'macos-14'
run: |
sudo xcode-select -s "/Applications/Xcode_15.0.1.app"
- name: Download ITK
run: |
cd ..
git clone https://github.com/InsightSoftwareConsortium/ITK.git
cd ITK
git checkout ${{ env.itk-git-tag }}
- name: Build ITK
if: matrix.os != 'windows-2022'
run: |
cd ..
mkdir ITK-build
cd ITK-build
cmake -DCMAKE_C_COMPILER:FILEPATH="${{ matrix.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.cmake-build-type }} -DBUILD_TESTING:BOOL=OFF -GNinja ../ITK
ninja
- name: Build ITK
if: matrix.os == 'windows-2022'
shell: pwsh
run: |
Set-PSDebug -Trace 1
cd ..
& "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -SkipAutomaticLocation
mkdir ITK-build
cd ITK-build
cmake -DCMAKE_C_COMPILER:FILEPATH="${{ matrix.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.cmake-build-type }} -DBUILD_TESTING:BOOL=OFF -GNinja ../ITK
ninja
- name: Fetch CTest driver script
run: |
curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/dashboard/itk_common.cmake -O
- 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}/" CTEST_SOURCE_DIRECTORY)
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/../build" CTEST_BINARY_DIRECTORY)
set(dashboard_source_name "${GITHUB_REPOSITORY}")
if((ENV{GITHUB_REF_NAME} MATCHES "master" OR ENV{GITHUB_REF_NAME} MATCHES "main"))
set(branch "-master")
set(dashboard_model "Continuous")
else()
set(branch "-${GITHUB_REF}")
set(dashboard_model "Experimental")
endif()
set(CTEST_BUILD_NAME "${GITHUB_REPOSITORY}-${operating_system}-\${branch}")
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(CTEST_CUSTOM_WARNING_EXCEPTION
\${CTEST_CUSTOM_WARNING_EXCEPTION}
# macOS Azure VM Warning
"ld: warning: text-based stub file"
"Wunused-result"
"file: .+ has no symbols"
"Wpointer-bool-conversion"
"note: prefix with the address-of operator to silence this warning"
"warning C4722: 'riegeli::internal::UnreachableStream::~UnreachableStream': destructor never returns, potential memory leak"
"warning C4722: 'riegeli::internal::CheckFailed::~CheckFailed': destructor never returns, potential memory leak"
"_deps[/\\\\].+-src[/\\\\]" # disable all warnings from external projects
"_deps[/\\\\].+-build[/\\\\]" # disable all warnings from external projects
# the following warnings escape the above filter
"warning: Import validate/validate.proto is unused"
"warning:.+__builtin___memcpy_chk"
"warning:.+__builtin_memchr"
"warning:.+__builtin_memcpy"
"ld: warning: ignoring duplicate libraries:.+"
"cc1plus: warning: writing 16 bytes into a region of size 0"
"note: source object allocated here"
)
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
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_SCRIPT_DIRECTORY}/itk_common.cmake)
EOF
cat dashboard.cmake
- name: Build and test
if: matrix.os != 'windows-2022'
run: |
ctest --output-on-failure -j 2 -V -S dashboard.cmake ${{ env.ctest-options }}
- name: Build and test
if: matrix.os == 'windows-2022'
shell: pwsh
run: |
& "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -SkipAutomaticLocation
ctest --output-on-failure -j 2 -V -S dashboard.cmake ${{ env.ctest-options }}
build-linux-py:
runs-on: ubuntu-22.04
strategy:
max-parallel: 2
matrix:
python3-minor-version: ["8", "9", "10", "11"]
manylinux-platform: ["_2_28-x64"]
steps:
- uses: actions/checkout@v4
- name: Get specific version of CMake, Ninja
uses: lukka/[email protected]
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/[email protected]
with:
large-packages: false
- uses: shogo82148/actions-setup-perl@v1
- uses: ilammy/setup-nasm@v1
- name: 'Fetch build script'
run: |
IPP_DOWNLOAD_GIT_TAG=${{ env.itk-python-package-tag }}
IPP_DOWNLOAD_ORG=${{ env.itk-python-package-org }}
curl -L https://raw.githubusercontent.com/${IPP_DOWNLOAD_ORG:=InsightSoftwareConsortium}/ITKPythonPackage/${IPP_DOWNLOAD_GIT_TAG:=master}/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh -O
chmod u+x dockcross-manylinux-download-cache-and-build-module-wheels.sh
- name: 'Build π Python π¦ package'
shell: bash
run: |
rm -rf dist
export ITK_PACKAGE_VERSION=${{ env.itk-wheel-tag }}
export ITKPYTHONPACKAGE_TAG=${{ env.itk-python-package-tag }}
export ITKPYTHONPACKAGE_ORG=${{ env.itk-python-package-org }}
export ITK_MODULE_PREQ=
CMAKE_OPTIONS=""
MANYLINUX_PLATFORM=${{ matrix.manylinux-platform }}
echo "Manylinux platform ${MANYLINUX_PLATFORM}"
rm -rf ITKPythonPackage
export MANYLINUX_VERSION=`(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 1)`
export TARGET_ARCH=`(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 2)`
echo "Building for manylinux specialization ${MANYLINUX_VERSION} and target architecture ${TARGET_ARCH}"
./dockcross-manylinux-download-cache-and-build-module-wheels.sh cp3${{ matrix.python3-minor-version }} $CMAKE_OPTIONS
- name: Set up Python 3.11 for Validation
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Validate build output
shell: bash
run: |
python -m pip install twine
ls dist/
MANYLINUX_PLATFORM=${{ matrix.manylinux-platform }}
MANYLINUX_VERSION=`(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 1)`
TARGET_ARCH_NAME=`(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 2)`
if [[ ${TARGET_ARCH_NAME} == "x64" ]]; then
TARGET_ARCH_NAME="x86_64" # Match auditwheel naming convention
fi
WHEEL_PATTERN="dist/itk_*cp3${{ matrix.python3-minor-version }}*manylinux${MANYLINUX_VERSION}*${TARGET_ARCH_NAME}.whl"
echo "Searching for wheels matching pattern ${WHEEL_PATTERN}"
python -m twine check ${WHEEL_PATTERN}
- name: Publish Python package as GitHub Artifact
uses: actions/upload-artifact@v4
with:
name: LinuxWheel3${{ matrix.python3-minor-version }}${{ matrix.manylinux-platform }}
path: dist/*.whl
- name: Publish Python package as GitHub Artifact
uses: actions/upload-artifact@v4
with:
name: MacOSWheel3${{ matrix.python3-minor-version }}
path: dist/*.whl
build-macos-arm-py:
runs-on: macos-14
strategy:
max-parallel: 2
matrix:
python3-minor-version: ["9", "10", "11"]
steps:
- uses: actions/checkout@v4
- name: 'Specific XCode version'
run: |
sudo xcode-select -s "/Applications/Xcode_15.0.1.app"
- name: Get specific version of CMake, Ninja
uses: lukka/[email protected]
- uses: shogo82148/actions-setup-perl@v1
- uses: ilammy/setup-nasm@v1
- name: 'Fetch build script'
if: matrix.python3-minor-version != '8'
run: |
IPP_DOWNLOAD_GIT_TAG=${{ env.itk-python-package-tag }}
IPP_DOWNLOAD_ORG=${{ env.itk-python-package-org }}
curl -L https://raw.githubusercontent.com/${IPP_DOWNLOAD_ORG:=InsightSoftwareConsortium}/ITKPythonPackage/${IPP_DOWNLOAD_GIT_TAG:=master}/scripts/macpython-download-cache-and-build-module-wheels.sh -O
chmod u+x macpython-download-cache-and-build-module-wheels.sh
- name: 'Build π Python π¦ package'
if: matrix.python3-minor-version != '8'
shell: bash
run: |
rm -rf dist
export ITK_PACKAGE_VERSION=${{ env.itk-wheel-tag }}
export ITKPYTHONPACKAGE_TAG=${{ env.itk-python-package-tag }}
export ITKPYTHONPACKAGE_ORG=${{ env.itk-python-package-org }}
export ITK_MODULE_PREQ=
export MACOSX_DEPLOYMENT_TARGET=11.0
SCMAKE_OPTIONS=""
./macpython-download-cache-and-build-module-wheels.sh $CMAKE_OPTIONS "3.${{ matrix.python3-minor-version }}"
- name: Set up Python 3.11 for Validation
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Validate build output
if: matrix.python3-minor-version != '8'
shell: bash
run: |
python -m pip install twine
ls dist/
WHEEL_PATTERN="dist/itk_*macosx*.whl"
EXPECTED_WHEEL_COUNT=1
WHEEL_COUNT=`(ls ${WHEEL_PATTERN} | wc -l)`
if (( ${WHEEL_COUNT} != ${EXPECTED_WHEEL_COUNT} )); then
echo "Expected ${EXPECTED_WHEEL_COUNT} wheels but found ${WHEEL_COUNT}"
exit 1
fi
python -m twine check ${WHEEL_PATTERN}
- name: Publish Python package as GitHub Artifact
if: matrix.python3-minor-version != '8'
uses: actions/upload-artifact@v4
with:
name: MacOSArmWheel3${{ matrix.python3-minor-version }}
path: dist/*.whl
build-windows-python-packages:
runs-on: windows-2022
strategy:
max-parallel: 2
matrix:
python3-minor-version: ["8", "9", "10", "11"]
steps:
- name: Get specific version of CMake, Ninja
uses: lukka/[email protected]
- uses: actions/checkout@v4
with:
path: "im"
- name: 'Reduce source path length'
shell: bash
run: |
# Move checked-out source to a shorter path to avoid Windows path length issues
mv im ../../
- name: 'Fetch build script'
shell: pwsh
run: |
cd ../../im
$ITKPYTHONPACKAGE_TAG = "${{ env.itk-python-package-tag }}"
$ITKPYTHONPACKAGE_ORG = "${{ env.itk-python-package-org }}"
$SCRIPT_UPSTREAM = "https://raw.githubusercontent.com/$ITKPYTHONPACKAGE_ORG/ITKPythonPackage/$ITKPYTHONPACKAGE_TAG/scripts/windows-download-cache-and-build-module-wheels.ps1"
echo "Fetching $SCRIPT_UPSTREAM"
(new-object net.webclient).DownloadString($SCRIPT_UPSTREAM) > windows-download-cache-and-build-module-wheels.ps1
- uses: shogo82148/actions-setup-perl@v1
- uses: ilammy/setup-nasm@v1
- name: 'Build π Python π¦ package'
shell: pwsh
run: |
if (Test-Path dist) { rm dist -r -fo }
cd ../../im
& "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -SkipAutomaticLocation
$env:CC="cl.exe"
$env:CXX="cl.exe"
$env:ITK_PACKAGE_VERSION = "${{ env.itk-wheel-tag }}"
$env:ITKPYTHONPACKAGE_TAG = "${{ env.itk-python-package-tag }}"
$env:ITKPYTHONPACKAGE_ORG = "${{ env.itk-python-package-org }}"
$env:ITK_MODULE_PREQ = ""
./windows-download-cache-and-build-module-wheels.ps1 "${{ matrix.python3-minor-version }}" -cmake_options ""
mkdir -p '${{ github.workspace }}\dist'
cp 'dist\*.whl' '${{ github.workspace }}\dist'
- name: Set up Python 3.11 for Validation
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Validate build output
shell: pwsh
run: |
python -m pip install twine
ls dist/
$WHEEL_PATTERN = "dist/itk_*cp3${{ matrix.python3-minor-version }}*win*.whl"
echo "Searching for wheels matching pattern ${WHEEL_PATTERN}"
python -m twine check ${WHEEL_PATTERN}
- name: Publish Python package as GitHub Artifact
uses: actions/upload-artifact@v4
with:
name: WindowsWheel3${{ matrix.python3-minor-version }}
path: dist/*.whl
publish-python-packages-to-pypi:
needs:
- build-linux-py
- build-macos-arm-py
- build-windows-python-packages
runs-on: ubuntu-22.04
steps:
- name: Download Python Packages
uses: actions/download-artifact@v4
- name: Prepare packages for upload
run: |
ls -R
for d in */; do
mv ${d}/*.whl .
done
mkdir dist
mv *.whl dist/
ls dist
- name: Publish π Python π¦ package to PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: pypa/[email protected]
with:
skip_existing: true
user: __token__
password: ${{ secrets.pypi_password }}