|
| 1 | +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 2 | +# See https://llvm.org/LICENSE.txt for license information. |
| 3 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 | +# Copyright (c) 2024. |
| 5 | + |
| 6 | +name: "Build, test, release eudsl-tile" |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + force_debug_with_tmate: |
| 12 | + type: boolean |
| 13 | + description: 'Run the build with tmate session' |
| 14 | + required: false |
| 15 | + default: false |
| 16 | + debug_with_tmate: |
| 17 | + type: boolean |
| 18 | + description: 'Run the build with a tmate session ONLY in case of failure' |
| 19 | + required: false |
| 20 | + default: false |
| 21 | + workflow_call: |
| 22 | + inputs: |
| 23 | + wheel_version: |
| 24 | + description: 'wheel version' |
| 25 | + type: string |
| 26 | + required: false |
| 27 | + default: '' |
| 28 | + workflow_call: |
| 29 | + description: 'To distinguish workflow_call from regular push' |
| 30 | + type: boolean |
| 31 | + required: false |
| 32 | + default: true |
| 33 | + workflow_caller_run_id: |
| 34 | + description: '' |
| 35 | + type: string |
| 36 | + required: false |
| 37 | + default: '' |
| 38 | + pull_request: |
| 39 | + branches: |
| 40 | + - main |
| 41 | + paths: |
| 42 | + - ".github/workflows/build_test_release_eudsl_tile.yml" |
| 43 | + - "projects/eudsl-tile/**" |
| 44 | + push: |
| 45 | + branches: |
| 46 | + - main |
| 47 | + paths: |
| 48 | + - ".github/workflows/build_test_release_eudsl_tile.yml" |
| 49 | + - "projects/eudsl-tile/**" |
| 50 | + |
| 51 | +concurrency: |
| 52 | + group: ${{ github.workflow }}-${{ github.event.number || github.sha }}-build_test_release_eudsl_tile |
| 53 | + cancel-in-progress: true |
| 54 | + |
| 55 | +jobs: |
| 56 | + build-eudsl-tile: |
| 57 | + |
| 58 | + strategy: |
| 59 | + fail-fast: false |
| 60 | + matrix: |
| 61 | + include: |
| 62 | + - name: "ubuntu_x86_64" |
| 63 | + runs-on: "ubuntu-22.04" |
| 64 | + os: "ubuntu" |
| 65 | + host-arch: "x86_64" |
| 66 | + target-arch: "x86_64" |
| 67 | + |
| 68 | + - name: "ubuntu_aarch64" |
| 69 | + runs-on: "ubuntu-22.04-arm" |
| 70 | + os: "ubuntu" |
| 71 | + host-arch: "aarch64" |
| 72 | + target-arch: "aarch64" |
| 73 | + |
| 74 | + - name: "windows_amd64" |
| 75 | + runs-on: "windows-2022" |
| 76 | + os: "windows" |
| 77 | + host-arch: "amd64" |
| 78 | + target-arch: "amd64" |
| 79 | + |
| 80 | + - name: "macos_arm64" |
| 81 | + runs-on: "macos-14" |
| 82 | + os: "macos" |
| 83 | + host-arch: "arm64" |
| 84 | + target-arch: "arm64" |
| 85 | + |
| 86 | + runs-on: ${{ matrix.runs-on }} |
| 87 | + |
| 88 | + name: "Build eudsl-tile ${{ matrix.name }}" |
| 89 | + |
| 90 | + defaults: |
| 91 | + run: |
| 92 | + shell: bash |
| 93 | + |
| 94 | + permissions: |
| 95 | + id-token: write |
| 96 | + contents: write |
| 97 | + |
| 98 | + env: |
| 99 | + # either the PR number or `branch-N` where N always increments |
| 100 | + cache-key: eudsl_tile_${{ matrix.name }}_clang_${{ format('{0}-{1}', github.ref_name, github.run_number) }} |
| 101 | + |
| 102 | + steps: |
| 103 | + - name: "Check out repository" |
| 104 | + uses: actions/checkout@v4.2.2 |
| 105 | + with: |
| 106 | + submodules: false |
| 107 | + |
| 108 | + - name: "Get submodules" |
| 109 | + run: git submodule update --init --depth=1 |
| 110 | + |
| 111 | + - name: "Setup base" |
| 112 | + uses: ./.github/actions/setup_base |
| 113 | + id: setup_base |
| 114 | + with: |
| 115 | + cache-key: ${{ env.cache-key }} |
| 116 | + restore-key: "eudsl_tile_${{ matrix.name }}_clang" |
| 117 | + os: ${{ matrix.os }} |
| 118 | + host-arch: ${{ matrix.host-arch }} |
| 119 | + target-arch: ${{ matrix.target-arch }} |
| 120 | + runs-on: ${{ matrix.runs-on }} |
| 121 | + |
| 122 | + - name: "Pip download MLIR from releases" |
| 123 | + if: ${{ !inputs.workflow_call }} |
| 124 | + run: | |
| 125 | + |
| 126 | + pip download mlir-wheel -f https://llvm.github.io/eudsl |
| 127 | + WHEEL_NAME=$(ls mlir_wheel*) |
| 128 | + $python3_command -m pip install pkginfo |
| 129 | + WHEEL_VERSION=$($python3_command -c "from pkginfo import Wheel; print(Wheel('$WHEEL_NAME').version)") |
| 130 | + echo "WHEEL_VERSION=$WHEEL_VERSION" >> $GITHUB_ENV |
| 131 | +
|
| 132 | + - name: Download LLVM distro artifacts |
| 133 | + if: ${{ inputs.workflow_call }} |
| 134 | + uses: dawidd6/action-download-artifact@v11 |
| 135 | + with: |
| 136 | + name: mlir_wheel_${{ (matrix.name == 'ubuntu_x86_64' || matrix.name == 'ubuntu_aarch64') && 'manylinux' || matrix.os }}_${{ matrix.target-arch }}_artifact |
| 137 | + path: "./" |
| 138 | + run_id: ${{ inputs.workflow_caller_run_id }} |
| 139 | + |
| 140 | + - name: "Set WHEEL_VERSION env var" |
| 141 | + if: ${{ inputs.workflow_call }} |
| 142 | + run: | |
| 143 | + |
| 144 | + echo "WHEEL_VERSION=${{ inputs.wheel_version }}" >> $GITHUB_ENV |
| 145 | +
|
| 146 | + - name: "Configure build" |
| 147 | + run: | |
| 148 | + |
| 149 | + unzip -q mlir_wheel*.whl |
| 150 | + mv mlir_wheel llvm-install |
| 151 | + |
| 152 | + if [[ "${{ matrix.os }}" == "ubuntu" ]]; then |
| 153 | + echo "LLVM_DIR=/host/$PWD/llvm-install/lib/cmake/llvm" >> $GITHUB_ENV |
| 154 | + echo "MLIR_DIR=/host/$PWD/llvm-install/lib/cmake/mlir" >> $GITHUB_ENV |
| 155 | + echo "Clang_DIR=/host/$PWD/llvm-install/lib/cmake/clang" >> $GITHUB_ENV |
| 156 | + echo "CMAKE_PREFIX_PATH=/host/$PWD/llvm-install" >> $GITHUB_ENV |
| 157 | + else |
| 158 | + echo "LLVM_DIR=$PWD/llvm-install/lib/cmake/llvm" >> $GITHUB_ENV |
| 159 | + echo "MLIR_DIR=$PWD/llvm-install/lib/cmake/mlir" >> $GITHUB_ENV |
| 160 | + echo "Clang_DIR=$PWD/llvm-install/lib/cmake/clang" >> $GITHUB_ENV |
| 161 | + echo "CMAKE_PREFIX_PATH=$PWD/llvm-install" >> $GITHUB_ENV |
| 162 | + fi |
| 163 | + |
| 164 | + $python3_command -m pip install cibuildwheel |
| 165 | + |
| 166 | + if [[ "${{ matrix.os }}" == "ubuntu" ]] && [[ "${{ matrix.host-arch }}" == "aarch64" ]]; then |
| 167 | + sudo apt-get install libarchive-dev antlr libxml2-dev libxslt-dev libcurl4-openssl-dev |
| 168 | + fi |
| 169 | + if [[ "${{ matrix.os }}" == "macos" ]]; then |
| 170 | + brew install antlr boost libarchive |
| 171 | + fi |
| 172 | + |
| 173 | + - name: "Build eudsl-tile" |
| 174 | + run: | |
| 175 | + |
| 176 | + # combine eudsl-python-extras and eudsl-tile |
| 177 | + cp -R "$PWD/projects/eudsl-python-extras/mlir/extras" "$PWD/projects/eudsl-tile/eudsl-tile" |
| 178 | + $python3_command -m cibuildwheel "$PWD/projects/eudsl-tile" --output-dir wheelhouse |
| 179 | +
|
| 180 | + - name: Upload artifacts |
| 181 | + uses: actions/upload-artifact@v4 |
| 182 | + with: |
| 183 | + name: eudsl_tile_${{ matrix.name }}_artifact |
| 184 | + path: wheelhouse/*.whl |
| 185 | + if-no-files-found: error |
| 186 | + |
| 187 | + - name: "Setup tmate session" |
| 188 | + if: (failure() && inputs.debug_with_tmate) || inputs.force_debug_with_tmate |
| 189 | + uses: mxschmitt/action-tmate@v3.18 |
| 190 | + with: |
| 191 | + limit-access-to-actor: true |
| 192 | + install-dependencies: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'windows') || startsWith(matrix.os, 'ubuntu') }} |
| 193 | + |
| 194 | + test-eudsl-tile: |
| 195 | + |
| 196 | + if: github.event_name == 'pull_request' |
| 197 | + |
| 198 | + needs: [build-eudsl-tile] |
| 199 | + |
| 200 | + strategy: |
| 201 | + fail-fast: false |
| 202 | + matrix: |
| 203 | + runs-on: [ |
| 204 | + "ubuntu-22.04", |
| 205 | + "ubuntu-22.04-arm", |
| 206 | + "macos-14", |
| 207 | + "windows-2022" |
| 208 | + ] |
| 209 | + python-version: [ |
| 210 | + "3.10", "3.11", "3.12", |
| 211 | + "3.13", "3.14", "3.14t" |
| 212 | + ] |
| 213 | + include: [ |
| 214 | + {runs-on: "ubuntu-22.04", name: "ubuntu_x86_64", os: "ubuntu"}, |
| 215 | + {runs-on: "ubuntu-22.04-arm", name: "ubuntu_aarch64", os: "ubuntu"}, |
| 216 | + {runs-on: "windows-2022", name: "windows_amd64", os: "windows"}, |
| 217 | + {runs-on: "macos-14", name: "macos_arm64", os: "macos"}, |
| 218 | + ] |
| 219 | + exclude: |
| 220 | + # <frozen importlib._bootstrap>:491: Warning: Numpy built with MINGW-W64 on Windows 64 bits is experimental, and only available for testing. You are advised not to use it for production. |
| 221 | + - runs-on: windows-2022 |
| 222 | + python-version: "3.14" |
| 223 | + |
| 224 | + - runs-on: windows-2022 |
| 225 | + python-version: "3.14t" |
| 226 | + |
| 227 | + - runs-on: macos-14 |
| 228 | + python-version: "3.10" |
| 229 | + |
| 230 | + - runs-on: macos-14 |
| 231 | + python-version: "3.11" |
| 232 | + |
| 233 | + - runs-on: macos-14 |
| 234 | + python-version: "3.12" |
| 235 | + |
| 236 | + - runs-on: macos-14 |
| 237 | + python-version: "3.13" |
| 238 | + |
| 239 | + - runs-on: macos-14 |
| 240 | + python-version: "3.14" |
| 241 | + |
| 242 | + runs-on: ${{ matrix.runs-on }} |
| 243 | + |
| 244 | + name: "Test eudsl-tile ${{ matrix.name }} ${{ matrix.python-version }}" |
| 245 | + |
| 246 | + defaults: |
| 247 | + run: |
| 248 | + shell: bash |
| 249 | + |
| 250 | + steps: |
| 251 | + - name: "Check out repository" |
| 252 | + uses: actions/checkout@v4.2.2 |
| 253 | + with: |
| 254 | + submodules: false |
| 255 | + |
| 256 | + - name: "Get submodules" |
| 257 | + run: git submodule update --init --depth=1 |
| 258 | + |
| 259 | + - name: "Install Python" |
| 260 | + uses: actions/setup-python@v6.0.0 |
| 261 | + with: |
| 262 | + python-version: "${{ matrix.python-version }}" |
| 263 | + |
| 264 | + - uses: actions/download-artifact@v4 |
| 265 | + with: |
| 266 | + name: eudsl_tile_${{ matrix.name }}_artifact |
| 267 | + path: wheelhouse |
| 268 | + |
| 269 | + - name: "Test eudsl-tile" |
| 270 | + run: | |
| 271 | + |
| 272 | + python -m pip install pytest mlir-native-tools -f https://llvm.github.io/eudsl |
| 273 | + python -m pytest $PWD/projects/eudsl-tile/tests |
| 274 | + |
| 275 | + release-eudsl-tile: |
| 276 | + |
| 277 | + if: (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch' |
| 278 | + |
| 279 | + needs: [build-eudsl-tile] |
| 280 | + |
| 281 | + runs-on: "ubuntu-22.04" |
| 282 | + |
| 283 | + permissions: |
| 284 | + id-token: write |
| 285 | + contents: write |
| 286 | + |
| 287 | + strategy: |
| 288 | + fail-fast: false |
| 289 | + matrix: |
| 290 | + name: [ |
| 291 | + "ubuntu_x86_64", |
| 292 | + "ubuntu_aarch64", |
| 293 | + "ubuntu_wasm32", |
| 294 | + "macos_arm64", |
| 295 | + "windows_amd64" |
| 296 | + ] |
| 297 | + |
| 298 | + name: "Release eudsl-tile ${{ matrix.name }}" |
| 299 | + |
| 300 | + steps: |
| 301 | + |
| 302 | + - uses: actions/download-artifact@v4 |
| 303 | + with: |
| 304 | + name: eudsl_tile_${{ matrix.name }}_artifact |
| 305 | + path: wheelhouse |
| 306 | + |
| 307 | + - name: Release current commit |
| 308 | + uses: ncipollo/release-action@v1.12.0 |
| 309 | + with: |
| 310 | + artifacts: "wheelhouse/eudsl_tile*.whl" |
| 311 | + token: "${{ secrets.GITHUB_TOKEN }}" |
| 312 | + tag: eudsl-tile |
| 313 | + name: eudsl-tile |
| 314 | + removeArtifacts: false |
| 315 | + allowUpdates: true |
| 316 | + replacesArtifacts: true |
| 317 | + makeLatest: true |
| 318 | + omitBody: true |
| 319 | + |
| 320 | + call-deploy-pip-page: |
| 321 | + |
| 322 | + if: (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch' |
| 323 | + |
| 324 | + needs: [release-eudsl-tile] |
| 325 | + |
| 326 | + permissions: |
| 327 | + contents: read |
| 328 | + id-token: write |
| 329 | + pages: write |
| 330 | + |
| 331 | + uses: ./.github/workflows/deploy_pip_page.yml |
| 332 | + secrets: inherit # pass all secrets |
0 commit comments