Skip to content

Commit 5e9db9a

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Mac OSS CI use cmake built gtest (#3713)
Summary: Instead of using buck. Note that for sccache shims, we need to create the tempdir outside of setup-macos.sh, to prevent from files removed after the script finishes. Pull Request resolved: #3713 Reviewed By: huydhn Differential Revision: D57754547 Pulled By: kirklandsign fbshipit-source-id: b348c6226ca090e38a07c8f58570ab5539a817ce
1 parent 610eb4f commit 5e9db9a

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

.ci/scripts/setup-macos.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,11 @@ install_sccache() {
7777

7878
export PATH="${SCCACHE_PATH}:${PATH}"
7979

80-
# Create temp directory for sccache shims
81-
TMP_DIR=$(mktemp -d)
82-
trap 'rm -rfv ${TMP_DIR}' EXIT
83-
8480
write_sccache_stub "${TMP_DIR}/c++"
8581
write_sccache_stub "${TMP_DIR}/cc"
8682
write_sccache_stub "${TMP_DIR}/clang++"
8783
write_sccache_stub "${TMP_DIR}/clang"
8884

89-
export PATH="${TMP_DIR}:$PATH"
9085
sccache --zero-stats || true
9186
}
9287

.github/workflows/_unittest.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ jobs:
4141
4242
macos:
4343
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
44-
strategy:
45-
matrix:
46-
include:
47-
- build-tool: buck2
4844
with:
4945
runner: macos-m1-stable
5046
python-version: '3.11'
@@ -53,18 +49,21 @@ jobs:
5349
script: |
5450
set -eux
5551
56-
BUILD_TOOL=${{ matrix.build-tool }}
57-
5852
bash .ci/scripts/setup-conda.sh
5953
54+
# Create temp directory for sccache shims
55+
export TMP_DIR=$(mktemp -d)
56+
export PATH="${TMP_DIR}:$PATH"
57+
trap 'rm -rfv ${TMP_DIR}' EXIT
58+
6059
# Setup MacOS dependencies as there is no Docker support on MacOS atm
6160
PYTHON_EXECUTABLE=python \
6261
EXECUTORCH_BUILD_PYBIND=ON \
6362
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
6463
${CONDA_RUN} --no-capture-output \
65-
.ci/scripts/setup-macos.sh "${BUILD_TOOL}"
64+
.ci/scripts/setup-macos.sh cmake
6665
6766
# Run pytest with coverage
6867
${CONDA_RUN} pytest -n auto --cov=./ --cov-report=xml
6968
# Run gtest
70-
${CONDA_RUN} buck2 test runtime/core/... runtime/platform/...
69+
${CONDA_RUN} test/run_oss_cpp_tests.sh

test/run_oss_cpp_tests.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,26 @@ set -ex
1717
build_executorch() {
1818
cmake . \
1919
-DCMAKE_INSTALL_PREFIX=cmake-out \
20-
-DEXECUTORCH_BUILD_GTESTS=ON \
2120
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
2221
-Bcmake-out
2322
cmake --build cmake-out -j9 --target install
2423
}
2524

25+
build_gtest() {
26+
mkdir -p third-party/googletest/build
27+
pushd third-party/googletest/build
28+
cmake .. -DCMAKE_INSTALL_PREFIX=.
29+
make -j4
30+
make install
31+
popd
32+
}
33+
2634
build_and_run_test() {
2735
local test_dir=$1
28-
cmake "${test_dir}" -Bcmake-out/"${test_dir}" -DCMAKE_INSTALL_PREFIX=cmake-out
36+
cmake "${test_dir}" \
37+
-DCMAKE_INSTALL_PREFIX=cmake-out \
38+
-DCMAKE_PREFIX_PATH="$(pwd)/third-party/googletest/build" \
39+
-Bcmake-out/"${test_dir}"
2940
cmake --build cmake-out/"${test_dir}" -j9
3041

3142
for t in cmake-out/"${test_dir}"/*test; do
@@ -56,6 +67,7 @@ probe_tests() {
5667
}
5768

5869
build_executorch
70+
build_gtest
5971

6072
if [ -z "$1" ]; then
6173
echo "Running all directories:"

0 commit comments

Comments
 (0)