diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 55bf2ebf5..aec13497e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: matrix: python-version: ["3.9", "3.10"] target: ["dataplane", "model-repository"] - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -36,8 +36,10 @@ jobs: lint: strategy: matrix: - python-version: ["3.9", "3.10"] - runs-on: ubuntu-latest + python-version: + - "3.9" + - "3.10" + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -57,33 +59,30 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: + - ubuntu-22.04 + - macos-13 # NOTE: There's no pre-built `grpcio` wheel for Python 3.11 yet # https://github.com/grpc/grpc/issues/32454 - python-version: ["3.9", "3.10"] + python-version: + - "3.9" + - "3.10" is-pr: - ${{ github.event_name == 'pull_request' }} exclude: # MacOS tests take a lot of time, so we will run them only on merge # From https://github.com/orgs/community/discussions/26253 - is-pr: true - os: macos-latest + os: macos-13 runs-on: ${{ matrix.os }} steps: - - name: Setup docker (missing on MacOS) - if: runner.os == 'macos' - run: | - # From https://github.com/actions/runner-images/issues/17#issuecomment-1537238473 - # From https://github.com/abiosoft/colima/discussions/273#discussioncomment-4959736 - # NOTE: Use the `slirp` driver rather than the default to avoid - # random connection errors. - # From https://github.com/abiosoft/colima/issues/577 - brew install docker docker-buildx - mkdir -p $HOME/.docker/cli-plugins - ln -sfn $(which docker-buildx) $HOME/.docker/cli-plugins/docker-buildx - colima start --memory 5 --network-driver slirp - sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock - uses: actions/checkout@v4 + - name: Setup Docker (missing on MacOS) + if: runner.os == 'macos' + run: ./hack/install-docker-macos.sh + - name: Install OpenMP (in MacOS) + if: runner.os == 'macOS' + run: brew install libomp - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -97,16 +96,28 @@ jobs: with: virtualenvs-create: false - name: Install Dependencies - run: poetry install --sync --only dev + run: | + if [[ ${{ runner.os == 'macOS' }} ]]; then + source ./hack/activate-libomp-macos.sh + fi + poetry install --sync --only dev - name: Test - run: tox -e mlserver + run: | + if [[ ${{ runner.os == 'macOS' }} ]]; then + source ./hack/activate-libomp-macos.sh + fi + tox -e mlserver runtimes: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] - python-version: ["3.9", "3.10"] + os: + - ubuntu-22.04 + - macos-13 + python-version: + - "3.9" + - "3.10" tox-environment: - sklearn - xgboost @@ -122,10 +133,13 @@ jobs: # MacOS tests take a lot of time, so we will run them only on merge # From https://github.com/orgs/community/discussions/26253 - is-pr: true - os: macos-latest + os: macos-13 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 + - name: Install OpenMP (in MacOS) + if: runner.os == 'macOS' + run: brew install libomp - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -139,9 +153,17 @@ jobs: with: virtualenvs-create: false - name: Install Dependencies - run: poetry install --sync --only dev + run: | + if [[ ${{ runner.os == 'macOS' }} ]]; then + source ./hack/activate-libomp-macos.sh + fi + poetry install --sync --only dev - name: Test - run: tox -c ./runtimes/${{ matrix.tox-environment }} + run: | + if [[ ${{ runner.os == 'macOS' }} ]]; then + source ./hack/activate-libomp-macos.sh + fi + tox -c ./runtimes/${{ matrix.tox-environment }} # Ensure that having all the runtimes installed together works all-runtimes: @@ -149,8 +171,12 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] - python-version: ["3.9", "3.10"] + os: + - ubuntu-22.04 + - macos-13 + python-version: + - "3.9" + - "3.10" runs-on: ${{ matrix.os }} steps: - name: Maximize build space @@ -164,30 +190,13 @@ jobs: remove-docker-images: 'true' overprovision-lvm: 'true' swap-size-mb: 1024 - - name: Setup docker (missing on MacOS) + - uses: actions/checkout@v4 + - name: Setup Docker (missing on MacOS) if: runner.os == 'macOS' - run: | - # From https://github.com/actions/runner-images/issues/17#issuecomment-1537238473 - # From https://github.com/abiosoft/colima/discussions/273#discussioncomment-4959736 - # NOTE: Use the `slirp` driver rather than the default to avoid - # random connection errors. - # From https://github.com/abiosoft/colima/issues/577 - brew install docker docker-buildx - mkdir -p $HOME/.docker/cli-plugins - ln -sfn $(which docker-buildx) $HOME/.docker/cli-plugins/docker-buildx - colima start --memory 5 --network-driver slirp - sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock - - name: Downgrade OpenMP (in MacOS) + run: ./hack/install-docker-macos.sh + - name: Install OpenMP (in MacOS) if: runner.os == 'macOS' - run: | - # Recent versions of OpenMP cause segfaults in MacOS when training - # LightGBM / XGBoost models (but only when Torch is present) - # https://github.com/microsoft/LightGBM/issues/4229 - # https://github.com/autogluon/autogluon/issues/1442 - wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb - brew unlink libomp - brew install libomp.rb - - uses: actions/checkout@v4 + run: brew install libomp - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -201,6 +210,14 @@ jobs: with: virtualenvs-create: false - name: Install Dependencies - run: poetry install --sync --only dev + run: | + if [[ ${{ runner.os == 'macOS' }} ]]; then + source ./hack/activate-libomp-macos.sh + fi + poetry install --sync --only dev - name: Test - run: tox -e all-runtimes + run: | + if [[ ${{ runner.os == 'macOS' }} ]]; then + source ./hack/activate-libomp-macos.sh + fi + tox -e all-runtimes diff --git a/hack/activate-libomp-macos.sh b/hack/activate-libomp-macos.sh new file mode 100755 index 000000000..6b3813c19 --- /dev/null +++ b/hack/activate-libomp-macos.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -Eeuo pipefail + +export LDFLAGS="-L/usr/local/opt/libomp/lib" +export CPPFLAGS="-I/usr/local/opt/libomp/include" diff --git a/hack/install-docker-macos.sh b/hack/install-docker-macos.sh new file mode 100755 index 000000000..87e5b6fbe --- /dev/null +++ b/hack/install-docker-macos.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -Eeuo pipefail + +# Install Docker +# From https://github.com/actions/runner-images/issues/17#issuecomment-1537238473 +# From https://github.com/abiosoft/colima/discussions/273#discussioncomment-4959736 +brew install docker docker-buildx +mkdir -p $HOME/.docker/cli-plugins +ln -sfn $(which docker-buildx) $HOME/.docker/cli-plugins/docker-buildx + +# Install Lima +brew install lima +# Don't explicitly start Lima here (e.g. with `limactl start`). +# Let Colina do that, otherwise, # Colima seems to hang +# waiting for the SSH requirement to be met. + +# Install Colima +sudo mkdir -p /usr/local/bin +sudo curl -L -o /usr/local/bin/colima https://github.com/abiosoft/colima/releases/download/v0.6.9/colima-Darwin-x86_64 && sudo chmod +x /usr/local/bin/colima +colima start --memory 5 --runtime docker + +# Link Colima and Docker +sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock