Skip to content

Commit ab1f3f7

Browse files
author
Jesse Claven
authored
build: Lock GitHub runners' OS (#1765)
* 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.
1 parent fcce136 commit ab1f3f7

File tree

3 files changed

+99
-52
lines changed

3 files changed

+99
-52
lines changed

.github/workflows/tests.yml

Lines changed: 69 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
matrix:
1616
python-version: ["3.9", "3.10"]
1717
target: ["dataplane", "model-repository"]
18-
runs-on: ubuntu-latest
18+
runs-on: ubuntu-22.04
1919
steps:
2020
- uses: actions/checkout@v4
2121
- name: Set up Python ${{ matrix.python-version }}
@@ -36,8 +36,10 @@ jobs:
3636
lint:
3737
strategy:
3838
matrix:
39-
python-version: ["3.9", "3.10"]
40-
runs-on: ubuntu-latest
39+
python-version:
40+
- "3.9"
41+
- "3.10"
42+
runs-on: ubuntu-22.04
4143
steps:
4244
- uses: actions/checkout@v4
4345
- name: Set up Python ${{ matrix.python-version }}
@@ -57,33 +59,30 @@ jobs:
5759
strategy:
5860
fail-fast: false
5961
matrix:
60-
os: [ubuntu-latest, macos-latest]
62+
os:
63+
- ubuntu-22.04
64+
- macos-13
6165
# NOTE: There's no pre-built `grpcio` wheel for Python 3.11 yet
6266
# https://github.com/grpc/grpc/issues/32454
63-
python-version: ["3.9", "3.10"]
67+
python-version:
68+
- "3.9"
69+
- "3.10"
6470
is-pr:
6571
- ${{ github.event_name == 'pull_request' }}
6672
exclude:
6773
# MacOS tests take a lot of time, so we will run them only on merge
6874
# From https://github.com/orgs/community/discussions/26253
6975
- is-pr: true
70-
os: macos-latest
76+
os: macos-13
7177
runs-on: ${{ matrix.os }}
7278
steps:
73-
- name: Setup docker (missing on MacOS)
74-
if: runner.os == 'macos'
75-
run: |
76-
# From https://github.com/actions/runner-images/issues/17#issuecomment-1537238473
77-
# From https://github.com/abiosoft/colima/discussions/273#discussioncomment-4959736
78-
# NOTE: Use the `slirp` driver rather than the default to avoid
79-
# random connection errors.
80-
# From https://github.com/abiosoft/colima/issues/577
81-
brew install docker docker-buildx
82-
mkdir -p $HOME/.docker/cli-plugins
83-
ln -sfn $(which docker-buildx) $HOME/.docker/cli-plugins/docker-buildx
84-
colima start --memory 5 --network-driver slirp
85-
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
8679
- uses: actions/checkout@v4
80+
- name: Setup Docker (missing on MacOS)
81+
if: runner.os == 'macos'
82+
run: ./hack/install-docker-macos.sh
83+
- name: Install OpenMP (in MacOS)
84+
if: runner.os == 'macOS'
85+
run: brew install libomp
8786
- name: Set up Python ${{ matrix.python-version }}
8887
uses: actions/setup-python@v5
8988
with:
@@ -97,16 +96,28 @@ jobs:
9796
with:
9897
virtualenvs-create: false
9998
- name: Install Dependencies
100-
run: poetry install --sync --only dev
99+
run: |
100+
if [[ ${{ runner.os == 'macOS' }} ]]; then
101+
source ./hack/activate-libomp-macos.sh
102+
fi
103+
poetry install --sync --only dev
101104
- name: Test
102-
run: tox -e mlserver
105+
run: |
106+
if [[ ${{ runner.os == 'macOS' }} ]]; then
107+
source ./hack/activate-libomp-macos.sh
108+
fi
109+
tox -e mlserver
103110
104111
runtimes:
105112
strategy:
106113
fail-fast: false
107114
matrix:
108-
os: [ubuntu-latest, macos-latest]
109-
python-version: ["3.9", "3.10"]
115+
os:
116+
- ubuntu-22.04
117+
- macos-13
118+
python-version:
119+
- "3.9"
120+
- "3.10"
110121
tox-environment:
111122
- sklearn
112123
- xgboost
@@ -122,10 +133,13 @@ jobs:
122133
# MacOS tests take a lot of time, so we will run them only on merge
123134
# From https://github.com/orgs/community/discussions/26253
124135
- is-pr: true
125-
os: macos-latest
136+
os: macos-13
126137
runs-on: ${{ matrix.os }}
127138
steps:
128139
- uses: actions/checkout@v4
140+
- name: Install OpenMP (in MacOS)
141+
if: runner.os == 'macOS'
142+
run: brew install libomp
129143
- name: Set up Python ${{ matrix.python-version }}
130144
uses: actions/setup-python@v5
131145
with:
@@ -139,18 +153,30 @@ jobs:
139153
with:
140154
virtualenvs-create: false
141155
- name: Install Dependencies
142-
run: poetry install --sync --only dev
156+
run: |
157+
if [[ ${{ runner.os == 'macOS' }} ]]; then
158+
source ./hack/activate-libomp-macos.sh
159+
fi
160+
poetry install --sync --only dev
143161
- name: Test
144-
run: tox -c ./runtimes/${{ matrix.tox-environment }}
162+
run: |
163+
if [[ ${{ runner.os == 'macOS' }} ]]; then
164+
source ./hack/activate-libomp-macos.sh
165+
fi
166+
tox -c ./runtimes/${{ matrix.tox-environment }}
145167
146168
# Ensure that having all the runtimes installed together works
147169
all-runtimes:
148170
if: github.event_name == 'push'
149171
strategy:
150172
fail-fast: false
151173
matrix:
152-
os: [ubuntu-latest, macos-latest]
153-
python-version: ["3.9", "3.10"]
174+
os:
175+
- ubuntu-22.04
176+
- macos-13
177+
python-version:
178+
- "3.9"
179+
- "3.10"
154180
runs-on: ${{ matrix.os }}
155181
steps:
156182
- name: Maximize build space
@@ -164,30 +190,13 @@ jobs:
164190
remove-docker-images: 'true'
165191
overprovision-lvm: 'true'
166192
swap-size-mb: 1024
167-
- name: Setup docker (missing on MacOS)
193+
- uses: actions/checkout@v4
194+
- name: Setup Docker (missing on MacOS)
168195
if: runner.os == 'macOS'
169-
run: |
170-
# From https://github.com/actions/runner-images/issues/17#issuecomment-1537238473
171-
# From https://github.com/abiosoft/colima/discussions/273#discussioncomment-4959736
172-
# NOTE: Use the `slirp` driver rather than the default to avoid
173-
# random connection errors.
174-
# From https://github.com/abiosoft/colima/issues/577
175-
brew install docker docker-buildx
176-
mkdir -p $HOME/.docker/cli-plugins
177-
ln -sfn $(which docker-buildx) $HOME/.docker/cli-plugins/docker-buildx
178-
colima start --memory 5 --network-driver slirp
179-
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
180-
- name: Downgrade OpenMP (in MacOS)
196+
run: ./hack/install-docker-macos.sh
197+
- name: Install OpenMP (in MacOS)
181198
if: runner.os == 'macOS'
182-
run: |
183-
# Recent versions of OpenMP cause segfaults in MacOS when training
184-
# LightGBM / XGBoost models (but only when Torch is present)
185-
# https://github.com/microsoft/LightGBM/issues/4229
186-
# https://github.com/autogluon/autogluon/issues/1442
187-
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb
188-
brew unlink libomp
189-
brew install libomp.rb
190-
- uses: actions/checkout@v4
199+
run: brew install libomp
191200
- name: Set up Python ${{ matrix.python-version }}
192201
uses: actions/setup-python@v5
193202
with:
@@ -201,6 +210,14 @@ jobs:
201210
with:
202211
virtualenvs-create: false
203212
- name: Install Dependencies
204-
run: poetry install --sync --only dev
213+
run: |
214+
if [[ ${{ runner.os == 'macOS' }} ]]; then
215+
source ./hack/activate-libomp-macos.sh
216+
fi
217+
poetry install --sync --only dev
205218
- name: Test
206-
run: tox -e all-runtimes
219+
run: |
220+
if [[ ${{ runner.os == 'macOS' }} ]]; then
221+
source ./hack/activate-libomp-macos.sh
222+
fi
223+
tox -e all-runtimes

hack/activate-libomp-macos.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuo pipefail
4+
5+
export LDFLAGS="-L/usr/local/opt/libomp/lib"
6+
export CPPFLAGS="-I/usr/local/opt/libomp/include"

hack/install-docker-macos.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuo pipefail
4+
5+
# Install Docker
6+
# From https://github.com/actions/runner-images/issues/17#issuecomment-1537238473
7+
# From https://github.com/abiosoft/colima/discussions/273#discussioncomment-4959736
8+
brew install docker docker-buildx
9+
mkdir -p $HOME/.docker/cli-plugins
10+
ln -sfn $(which docker-buildx) $HOME/.docker/cli-plugins/docker-buildx
11+
12+
# Install Lima
13+
brew install lima
14+
# Don't explicitly start Lima here (e.g. with `limactl start`).
15+
# Let Colina do that, otherwise, # Colima seems to hang
16+
# waiting for the SSH requirement to be met.
17+
18+
# Install Colima
19+
sudo mkdir -p /usr/local/bin
20+
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
21+
colima start --memory 5 --runtime docker
22+
23+
# Link Colima and Docker
24+
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock

0 commit comments

Comments
 (0)