ENH: Update CI and Python package for ITK 5.4.0 #141
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "a52d9b596b4f0da5ddb770ee99851e5c65ca3053" | |
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 }} |