Skip to content

Commit 6b079b7

Browse files
shivaspeaksejona86
andauthored
kokoro: Avoid brew on Mac OS (v1.81.x backport) (#12869)
Backport of #12846 to v1.81.x. --- brew is failing with "Error: undefined method 'first' for nil" when trying to upgrade itself. We already use Java 11 on other platforms, and it is already available on the Kokoro machines. We swap to download Maven just like we do for Linux, so then we can avoid brew entirely. However, the pre-installed Java is an arm build whereas the brew install was x86. So now the examples try to use protoc-gen-grpc-java-1.82.0-SNAPSHOT-osx-aarch_64.exe which don't exist because we used the default ARCH of x86_64. So now we also need to swap the primary platform on OS X to aarch_64 and copy the x86_64 binaries from that. CC @shivaspeaks, feel free to review, since you worked on the universal binaries Co-authored-by: Eric Anderson <ejona@google.com>
1 parent d07b476 commit 6b079b7

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

buildscripts/kokoro/macos.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ DOWNLOAD_DIR=/tmp/source
1212
mkdir -p ${DOWNLOAD_DIR}
1313
curl -Ls https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-macos-universal.tar.gz | tar xz -C ${DOWNLOAD_DIR}
1414

15+
curl -Ls https://archive.apache.org/dist/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz |
16+
tar xz -C "${DOWNLOAD_DIR}"
17+
1518
# We had problems with random tests timing out because it took seconds to do
1619
# trivial (ns) operations. The Kokoro Mac machines have 2 cores with 4 logical
1720
# threads, so Gradle should be using 4 workers by default.
@@ -20,9 +23,7 @@ export GRADLE_FLAGS="${GRADLE_FLAGS:-} --max-workers=2"
2023
. "$GRPC_JAVA_DIR"/buildscripts/kokoro/kokoro.sh
2124
trap spongify_logs EXIT
2225

23-
brew install --cask temurin@8
24-
export PATH="$(/usr/libexec/java_home -v"1.8.0")/bin:${DOWNLOAD_DIR}/cmake-${CMAKE_VERSION}-macos-universal/CMake.app/Contents/bin:${PATH}"
25-
export JAVA_HOME="$(/usr/libexec/java_home -v"1.8.0")"
26-
brew install maven
26+
export PATH="/Library/Java/JavaVirtualMachines/jdk-11-latest/Contents/Home/bin:${DOWNLOAD_DIR}/cmake-${CMAKE_VERSION}-macos-universal/CMake.app/Contents/bin:${DOWNLOAD_DIR}/apache-maven-3.8.8/bin:${PATH}"
27+
unset JAVA_HOME
2728

28-
"$GRPC_JAVA_DIR"/buildscripts/kokoro/unix.sh
29+
ARCH=aarch_64 "$GRPC_JAVA_DIR"/buildscripts/kokoro/unix.sh

buildscripts/kokoro/upload_artifacts.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ LOCAL_OTHER_ARTIFACTS="$KOKORO_GFILE_DIR"/github/grpc-java/artifacts/
4141
[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-linux-s390_64.exe' | wc -l)" != '0' ]]
4242

4343
# from macos job:
44-
[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-osx-x86_64.exe' | wc -l)" != '0' ]]
45-
# copy all x86 artifacts to aarch until native artifacts are built
46-
find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-osx-x86_64.exe*' -exec bash -c 'cp "${0}" "${0/x86/aarch}"' {} \;
44+
[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-osx-aarch_64.exe' | wc -l)" != '0' ]]
45+
# copy the universal binaries to x86, as they work on both architectures
46+
find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-osx-aarch_64.exe*' -exec bash -c 'cp "${0}" "${0/aarch/x86/}"' {} \;
4747

4848
# from windows job:
4949
[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-windows-x86_64.exe' | wc -l)" != '0' ]]

0 commit comments

Comments
 (0)