Skip to content

Commit

Permalink
build: Lock GitHub runners' OS (#1765)
Browse files Browse the repository at this point in the history
* build: Lock GitHub runners' OS

This was motivated by our macOS jobs failing [2] because
colima is missing. It looks like this is because the
latest versions of the macOS runner no longer have
colima installed by default [1].

colima is now explicitly installed.

[1] actions/runner-images#6216
[2] `/Users/runner/work/_temp/f19ffbff-27a9-4fc7-80b6-97791d2de141.sh: line 9: colima: command not found`

* build: Lock Colima

* build: Move macOS Docker installation to script

* build: Move macOS libomp activation to script

* build: Use latest Colima

The > 0.6.0 releases actually fix the issue we have linked [1][2][3].

[1] abiosoft/colima#577
[2] https://github.com/jesse-c/MLServer/blob/c3acd60995a72141027eff506e4fd330fe824179/hack/install-docker-macos.sh#L18-L20
[3] > Switch to new user-v2 network. Fixes abiosoft/colima#648, abiosoft/colima#603, abiosoft/colima#577, abiosoft/colima#779, abiosoft/colima#137, abiosoft/colima#740.
  • Loading branch information
Jesse Claven committed May 30, 2024
1 parent fcce136 commit ab1f3f7
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 52 deletions.
121 changes: 69 additions & 52 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -139,18 +153,30 @@ 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:
if: github.event_name == 'push'
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
Expand All @@ -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:
Expand All @@ -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
6 changes: 6 additions & 0 deletions hack/activate-libomp-macos.sh
Original file line number Diff line number Diff line change
@@ -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"
24 changes: 24 additions & 0 deletions hack/install-docker-macos.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ab1f3f7

Please sign in to comment.