Skip to content

Commit cb2589f

Browse files
huydhnfacebook-github-bot
authored andcommitted
Add OSS CI workflow for MacOS M1
Summary: This builds and runs Executorch on MacOS M1, similar to the Linux x86_64 job Differential Revision: D47929778 fbshipit-source-id: 8d46b62933ab42de86c6f0f0df371d123911db22
1 parent f747ff9 commit cb2589f

File tree

3 files changed

+82
-12
lines changed

3 files changed

+82
-12
lines changed

.ci/scripts/setup-macos.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
install_buck() {
6+
if ! command -v zstd &> /dev/null; then
7+
brew install zstd
8+
fi
9+
10+
curl https://github.com/facebook/buck2/releases/download/2023-07-18/buck2-x86_64-apple-darwin.zst -o buck2-x86_64-apple-darwin.zst
11+
zstd -d buck2-x86_64-apple-darwin.zst -o buck2
12+
13+
chmod +x buck2
14+
mv buck2 /opt/homebrew/bin
15+
16+
rm buck2-x86_64-apple-darwin.zst
17+
}
18+
19+
install_conda_dependencies() {
20+
pushd .ci/docker
21+
# Install conda dependencies like flatbuffer
22+
const install --file conda-env-ci.txt
23+
popd
24+
}
25+
26+
install_pip_dependencies() {
27+
pushd .ci/docker
28+
# Install all Python dependencies, including PyTorch
29+
pip install --progress-bar off -r requirements-ci.txt
30+
31+
TORCH_VERSION=2.1.0.dev20230731
32+
pip install --progress-bar off --pre torch=="${TORCH_VERSION}" --index-url https://download.pytorch.org/whl/nightly/cpu
33+
popd
34+
}
35+
36+
install_buck
37+
install_conda
38+
install_pip_dependencies

.ci/scripts/test.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
install_executorch() {
6+
# Install executorch, this assumes that Executorch is checked out in the
7+
# current directory
8+
pip3 install .
9+
# Just print out the list of packages for debugging
10+
pip3 list
11+
}
12+
13+
build_and_test_executorch() {
14+
# Build executorch runtime
15+
buck2 build //examples/executor_runner:executor_runner
16+
# Export a test model
17+
python3 -m examples.export.export_example --model_name="linear"
18+
# Run test model
19+
buck2 run //examples/executor_runner:executor_runner -- --model_path ./linear.ff
20+
}
21+
22+
install_executorch
23+
build_and_test_executorch

.github/workflows/pull.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
buck-build-test:
16-
name: buck-build-test
15+
buck-build-test-linux:
16+
name: buck-build-test-linux
1717
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
1818
with:
1919
runner: linux.2xlarge
@@ -27,14 +27,23 @@ jobs:
2727
# here, as it's there in the container
2828
export PATH="/opt/conda/envs/py_${PYTHON_VERSION}/bin:${PATH}"
2929
30-
# Install executorch
31-
pip3 install .
32-
# Just print out the list of packages for debugging
33-
pip3 list
30+
# Build and test Executorch
31+
bash .ci/scripts/test.sh
3432
35-
# Build executorch runtime
36-
buck2 build //examples/executor_runner:executor_runner
37-
# Export a test model
38-
python3 -m examples.export.export_example --model_name="linear"
39-
# Run test model
40-
buck2 run //examples/executor_runner:executor_runner -- --model_path ./linear.ff
33+
buck-build-test-macos:
34+
name: buck-build-test-macos
35+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
36+
with:
37+
runner: macos-m1-12
38+
submodules: 'true'
39+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
40+
script: |
41+
WORKSPACE=$(pwd)
42+
43+
pushd "${WORKSPACE}/pytorch/executorch"
44+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
45+
bash .ci/scripts/setup-macos.sh
46+
47+
# Build and test Executorch
48+
bash .ci/scripts/test.sh
49+
popd

0 commit comments

Comments
 (0)