# One-shot build for sanity checking the MacOS runtime.
name: MacOS Runtime OneShot Sanity

on:
  workflow_dispatch:

jobs:
  build_core:
    name: "MacOS Runtime OneShot"
    runs-on: macos-latest

    env:
      CIBW_BUILD_VERBOSITY: 1
      CIBW_ENVIRONMENT_MACOS: "REPO_DIR=${{ github.workspace }}/main_checkout"
      CIBW_BUILD: "cp36-* cp37-* cp38-* cp39-*"
      CIBW_SKIP: "*-win32 *-manylinux_i686"

    steps:
      - uses: actions/checkout@v2
        with:
          path: 'main_checkout'
          submodules: true

      - uses: actions/setup-python@v2
        name: Install Python
        with:
          python-version: '3.8'

      - name: Install cibuildwheel
        shell: bash
        run: |
          python -m pip install cibuildwheel==1.7.2

      # Runtime wheels are version specific, so we build one for each python
      # version. We do this serially by deleting the CMakeCache and install
      # directory between runs. Most of the build will be incremental.
      # We save a little bit of time by disabling the compiler build.
      - name: Build runtime wheels
        shell: bash
        run: |
          # TODO: Find a cross-platform way to invoke install/strip (it does
          # not exist on Windows).
          package_dir="./iree-install/python_packages/iree_rt"
          export CIBW_BEFORE_BUILD="rm -f ./iree-build/CMakeCache.txt && \
            rm -Rf ./iree-install && \
            python ./main_checkout/build_tools/cmake/cmake_ci.py \
              -B./iree-build -DCMAKE_INSTALL_PREFIX=./iree-install \
              -DCMAKE_BUILD_TYPE=Release \
              -DIREE_BUILD_COMPILER=OFF \
              -DIREE_BUILD_PYTHON_BINDINGS=ON \
              -DIREE_BUILD_SAMPLES=OFF && \
            python ./main_checkout/build_tools/cmake/cmake_ci.py \
              --build ./iree-build --target install"
          # TODO: cibuildwheel sanity checks this, but our setup.py is the
          # *output* of the build :( File a bug.
          mkdir -p $package_dir && touch $package_dir/setup.py
          python -m cibuildwheel --output-dir wheelhouse $package_dir

      - uses: actions/upload-artifact@v2
        with:
          path: ./wheelhouse/*.whl
          retention-days: 1

Add one-shot runtime MacOS sanity check workflow.
Add one-shot runtime MacOS sanity check workflow.
