|
| 1 | +name: Build, test, package |
| 2 | + |
| 3 | +on: [push,pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build-test-cxx: |
| 7 | + runs-on: ${{ matrix.os }} |
| 8 | + strategy: |
| 9 | + max-parallel: 3 |
| 10 | + matrix: |
| 11 | + os: [ubuntu-18.04, windows-2019, macos-10.15] |
| 12 | + include: |
| 13 | + - os: ubuntu-18.04 |
| 14 | + c-compiler: "gcc" |
| 15 | + cxx-compiler: "g++" |
| 16 | + itk-git-tag: "v5.1.0" |
| 17 | + cmake-build-type: "MinSizeRel" |
| 18 | + - os: windows-2019 |
| 19 | + c-compiler: "cl.exe" |
| 20 | + cxx-compiler: "cl.exe" |
| 21 | + itk-git-tag: "v5.1.0" |
| 22 | + cmake-build-type: "Release" |
| 23 | + - os: macos-10.15 |
| 24 | + c-compiler: "clang" |
| 25 | + cxx-compiler: "clang++" |
| 26 | + itk-git-tag: "v5.1.0" |
| 27 | + cmake-build-type: "MinSizeRel" |
| 28 | + |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v1 |
| 31 | + |
| 32 | + - name: Set up Python 3.7 |
| 33 | + uses: actions/setup-python@v1 |
| 34 | + with: |
| 35 | + python-version: 3.7 |
| 36 | + |
| 37 | + - name: Install build dependencies |
| 38 | + run: | |
| 39 | + python -m pip install --upgrade pip |
| 40 | + python -m pip install ninja |
| 41 | +
|
| 42 | + - name: Download ITK |
| 43 | + run: | |
| 44 | + cd .. |
| 45 | + git clone https://github.com/InsightSoftwareConsortium/ITK.git |
| 46 | + cd ITK |
| 47 | + git checkout ${{ matrix.itk-git-tag }} |
| 48 | +
|
| 49 | + - name: Build ITK |
| 50 | + if: matrix.os != 'windows-2019' |
| 51 | + run: | |
| 52 | + cd .. |
| 53 | + mkdir ITK-build |
| 54 | + cd ITK-build |
| 55 | + 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 |
| 56 | + ninja |
| 57 | +
|
| 58 | + - name: Build ITK |
| 59 | + if: matrix.os == 'windows-2019' |
| 60 | + run: | |
| 61 | + cd .. |
| 62 | + mkdir ITK-build |
| 63 | + cd ITK-build |
| 64 | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" |
| 65 | + 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 |
| 66 | + ninja |
| 67 | + shell: cmd |
| 68 | + |
| 69 | + - name: Fetch CTest driver script |
| 70 | + run: | |
| 71 | + curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/dashboard/itk_common.cmake -O |
| 72 | +
|
| 73 | + - name: Configure CTest script |
| 74 | + shell: bash |
| 75 | + run: | |
| 76 | + operating_system="${{ matrix.os }}" |
| 77 | + cat > dashboard.cmake << EOF |
| 78 | + set(CTEST_SITE "GitHubActions") |
| 79 | + file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/.." CTEST_DASHBOARD_ROOT) |
| 80 | + file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/" CTEST_SOURCE_DIRECTORY) |
| 81 | + file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/../build" CTEST_BINARY_DIRECTORY) |
| 82 | + set(dashboard_source_name "${GITHUB_REPOSITORY}") |
| 83 | + if(ENV{GITHUB_REF} MATCHES "master") |
| 84 | + set(branch "-master") |
| 85 | + set(dashboard_model "Continuous") |
| 86 | + else() |
| 87 | + set(branch "-${GITHUB_REF}") |
| 88 | + set(dashboard_model "Experimental") |
| 89 | + endif() |
| 90 | + set(CTEST_BUILD_NAME "${GITHUB_REPOSITORY}-${operating_system}-\${branch}") |
| 91 | + set(CTEST_UPDATE_VERSION_ONLY 1) |
| 92 | + set(CTEST_TEST_ARGS \${CTEST_TEST_ARGS} PARALLEL_LEVEL \${PARALLEL_LEVEL}) |
| 93 | + set(CTEST_BUILD_CONFIGURATION "Release") |
| 94 | + set(CTEST_CMAKE_GENERATOR "Ninja") |
| 95 | + set(CTEST_CUSTOM_WARNING_EXCEPTION |
| 96 | + \${CTEST_CUSTOM_WARNING_EXCEPTION} |
| 97 | + # macOS Azure VM Warning |
| 98 | + "ld: warning: text-based stub file" |
| 99 | + ) |
| 100 | + set(dashboard_no_clean 1) |
| 101 | + set(ENV{CC} ${{ matrix.c-compiler }}) |
| 102 | + set(ENV{CXX} ${{ matrix.cxx-compiler }}) |
| 103 | + set(dashboard_cache " |
| 104 | + ITK_DIR:PATH=\${CTEST_DASHBOARD_ROOT}/ITK-build |
| 105 | + BUILD_TESTING:BOOL=ON |
| 106 | + ") |
| 107 | + string(TIMESTAMP build_date "%Y-%m-%d") |
| 108 | + message("CDash Build Identifier: \${build_date} \${CTEST_BUILD_NAME}") |
| 109 | + message("CTEST_SITE = \${CTEST_SITE}") |
| 110 | + include(\${CTEST_SCRIPT_DIRECTORY}/itk_common.cmake) |
| 111 | + EOF |
| 112 | + cat dashboard.cmake |
| 113 | +
|
| 114 | + - name: Build and test |
| 115 | + if: matrix.os != 'windows-2019' |
| 116 | + run: | |
| 117 | + ctest --output-on-failure -j 2 -V -S dashboard.cmake |
| 118 | +
|
| 119 | + - name: Build and test |
| 120 | + if: matrix.os == 'windows-2019' |
| 121 | + run: | |
| 122 | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" |
| 123 | + ctest --output-on-failure -j 2 -V -S dashboard.cmake |
| 124 | + shell: cmd |
| 125 | + |
| 126 | + build-linux-python-packages: |
| 127 | + runs-on: ubuntu-18.04 |
| 128 | + strategy: |
| 129 | + max-parallel: 2 |
| 130 | + matrix: |
| 131 | + python-version: [35, 36, 37, 38] |
| 132 | + include: |
| 133 | + - itk-python-git-tag: "v5.1.0" |
| 134 | + |
| 135 | + steps: |
| 136 | + - uses: actions/checkout@v2 |
| 137 | + |
| 138 | + - name: 'Free up disk space' |
| 139 | + run: | |
| 140 | + # Workaround for https://github.com/actions/virtual-environments/issues/709 |
| 141 | + df -h |
| 142 | + sudo apt-get clean |
| 143 | + sudo rm -rf "/usr/local/share/boost" |
| 144 | + sudo rm -rf "$AGENT_TOOLSDIRECTORY" |
| 145 | + df -h |
| 146 | +
|
| 147 | + - name: 'Fetch build script' |
| 148 | + run: | |
| 149 | + curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh -O |
| 150 | + chmod u+x dockcross-manylinux-download-cache-and-build-module-wheels.sh |
| 151 | +
|
| 152 | + - name: 'Build 🐍 Python 📦 package' |
| 153 | + run: | |
| 154 | + export ITK_PACKAGE_VERSION=${{ matrix.itk-python-git-tag }} |
| 155 | + ./dockcross-manylinux-download-cache-and-build-module-wheels.sh cp${{ matrix.python-version }} |
| 156 | +
|
| 157 | + - name: Publish Python package as GitHub Artifact |
| 158 | + uses: actions/upload-artifact@v1 |
| 159 | + with: |
| 160 | + name: LinuxWheel${{ matrix.python-version }} |
| 161 | + path: dist |
| 162 | + |
| 163 | + build-macos-python-packages: |
| 164 | + runs-on: macos-10.15 |
| 165 | + strategy: |
| 166 | + max-parallel: 2 |
| 167 | + matrix: |
| 168 | + include: |
| 169 | + - itk-python-git-tag: "v5.1.0" |
| 170 | + |
| 171 | + steps: |
| 172 | + - uses: actions/checkout@v2 |
| 173 | + |
| 174 | + - name: 'Fetch build script' |
| 175 | + run: | |
| 176 | + curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/macpython-download-cache-and-build-module-wheels.sh -O |
| 177 | + chmod u+x macpython-download-cache-and-build-module-wheels.sh |
| 178 | +
|
| 179 | + - name: 'Build 🐍 Python 📦 package' |
| 180 | + run: | |
| 181 | + export ITK_PACKAGE_VERSION=${{ matrix.itk-python-git-tag }} |
| 182 | + export MACOSX_DEPLOYMENT_TARGET=10.9 |
| 183 | + ./macpython-download-cache-and-build-module-wheels.sh |
| 184 | +
|
| 185 | + - name: Publish Python package as GitHub Artifact |
| 186 | + uses: actions/upload-artifact@v1 |
| 187 | + with: |
| 188 | + name: MacOSWheels |
| 189 | + path: dist |
| 190 | + |
| 191 | + build-windows-python-packages: |
| 192 | + runs-on: windows-2019 |
| 193 | + strategy: |
| 194 | + max-parallel: 2 |
| 195 | + matrix: |
| 196 | + python-version-minor: [5, 6, 7, 8] |
| 197 | + include: |
| 198 | + - itk-python-git-tag: "v5.1.0" |
| 199 | + |
| 200 | + steps: |
| 201 | + - uses: actions/checkout@v2 |
| 202 | + with: |
| 203 | + path: "im" |
| 204 | + |
| 205 | + - name: 'Install Python' |
| 206 | + run: | |
| 207 | + $pythonArch = "64" |
| 208 | + $pythonVersion = "3.${{ matrix.python-version-minor }}" |
| 209 | + iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/scikit-build/scikit-ci-addons/master/windows/install-python.ps1')) |
| 210 | +
|
| 211 | + - name: 'Fetch build dependencies' |
| 212 | + shell: bash |
| 213 | + run: | |
| 214 | + mv im ../../ |
| 215 | + cd ../../ |
| 216 | + curl -L "https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${{ matrix.itk-python-git-tag }}/ITKPythonBuilds-windows.zip" -o "ITKPythonBuilds-windows.zip" |
| 217 | + 7z x ITKPythonBuilds-windows.zip -o/c/P -aoa -r |
| 218 | + curl -L "https://data.kitware.com/api/v1/file/5c0ad59d8d777f2179dd3e9c/download" -o "doxygen-1.8.11.windows.bin.zip" |
| 219 | + 7z x doxygen-1.8.11.windows.bin.zip -o/c/P/doxygen -aoa -r |
| 220 | + curl -L "https://data.kitware.com/api/v1/file/5bbf87ba8d777f06b91f27d6/download/grep-win.zip" -o "grep-win.zip" |
| 221 | + 7z x grep-win.zip -o/c/P/grep -aoa -r |
| 222 | +
|
| 223 | + - name: 'Build 🐍 Python 📦 package' |
| 224 | + shell: cmd |
| 225 | + run: | |
| 226 | + cd ../../im |
| 227 | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" |
| 228 | + set PATH="C:\P\grep;%PATH%" |
| 229 | + set CC=cl.exe |
| 230 | + set CXX=cl.exe |
| 231 | + C:\Python3${{ matrix.python-version-minor }}-x64\python.exe C:\P\IPP\scripts\windows_build_module_wheels.py --py-envs "3${{ matrix.python-version-minor }}-x64" |
| 232 | +
|
| 233 | + - name: Publish Python package as GitHub Artifact |
| 234 | + uses: actions/upload-artifact@v1 |
| 235 | + with: |
| 236 | + name: WindowWheel3.${{ matrix.python-version-minor }} |
| 237 | + path: ../../im/dist |
| 238 | + |
| 239 | + publish-python-packages-to-pypi: |
| 240 | + needs: |
| 241 | + - build-linux-python-packages |
| 242 | + - build-macos-python-packages |
| 243 | + - build-windows-python-packages |
| 244 | + runs-on: ubuntu-18.04 |
| 245 | + |
| 246 | + steps: |
| 247 | + - name: Download Python Packages |
| 248 | + uses: actions/download-artifact@v2 |
| 249 | + |
| 250 | + - name: Prepare packages for upload |
| 251 | + run: | |
| 252 | + ls -R |
| 253 | + for d in */; do |
| 254 | + mv ${d}/*.whl . |
| 255 | + done |
| 256 | + mkdir dist |
| 257 | + mv *.whl dist/ |
| 258 | + ls dist |
| 259 | +
|
| 260 | + - name: Publish 🐍 Python 📦 package to PyPI |
| 261 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 262 | + uses: pypa/gh-action-pypi-publish@master |
| 263 | + with: |
| 264 | + user: __token__ |
| 265 | + password: ${{ secrets.pypi_password }} |
0 commit comments