Skip to content

Commit

Permalink
Install a more recent version of the Android cmdline-tools in macOS t…
Browse files Browse the repository at this point in the history
…ests

PiperOrigin-RevId: 648683213
Change-Id: I0da1e66969dfd9f4e1c42c683a62b1ae5bbf18af
  • Loading branch information
morambro authored and copybara-github committed Jul 2, 2024
1 parent 36bb87f commit 73cfdad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
9 changes: 3 additions & 6 deletions kokoro/macos_external/bazel/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@

set -euo pipefail

export XCODE_VERSION="14.1"
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
export ANDROID_HOME="/usr/local/share/android-sdk"
export COURSIER_OPTS="-Djava.net.preferIPv6Addresses=true"

if [[ -n "${KOKORO_ROOT:-}" ]] ; then
readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)"
cd "${TINK_BASE_DIR}/tink_java"
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-8-latest/Contents/Home
export XCODE_VERSION="14.1"
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
fi

CACHE_FLAGS=""
Expand All @@ -34,6 +31,6 @@ if [[ -n "${TINK_REMOTE_BAZEL_CACHE_GCS_BUCKET:-}" ]]; then
fi
readonly CACHE_FLAGS

./kokoro/testutils/update_android_sdk.sh
source ./kokoro/testutils/update_android_sdk.sh
./kokoro/testutils/run_bazel_tests.sh ${CACHE_FLAGS} .
./kokoro/testutils/run_bazel_tests.sh ${CACHE_FLAGS} "examples"
20 changes: 13 additions & 7 deletions kokoro/testutils/update_android_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,33 @@
# limitations under the License.
################################################################################

# Installs the Android SDK and tools and sets the ANDROID_HOME environment
# variable if running on Kokoro.
set -x

if [[ -z "${KOKORO_ROOT}" ]] ; then
exit 0
fi

readonly ANDROID_COMMANDLINETOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip"
readonly ANDROID_COMMANDLINETOOLS_SHA256="2ccbda4302db862a28ada25aa7425d99dce9462046003c1714b059b5c47970d8"
readonly PLATFORM="$(uname | tr '[:upper:]' '[:lower:]')"

export ANDROID_HOME="/tmp/android-sdk"

if [[ "${PLATFORM}" == 'darwin' ]]; then
export JAVA_OPTS="-Djava.net.preferIPv6Addresses=true"
fi

# Install build-tools and other SDK dependencies.
#
mkdir -p "${ANDROID_HOME}"
time curl -LsS "${ANDROID_COMMANDLINETOOLS_URL}" -o cmdline-tools.zip
echo "${ANDROID_COMMANDLINETOOLS_SHA256} cmdline-tools.zip" | sha256sum -c
unzip cmdline-tools.zip -d "${ANDROID_HOME}"
# Discard STDOUT due to noisy progress bar which can't be silenced.
(yes || true) | "${ANDROID_HOME}/tools/bin/sdkmanager" \
(yes || true) | "${ANDROID_HOME}/cmdline-tools/bin/sdkmanager" \
"--sdk_root=${ANDROID_HOME}" \
"build-tools;30.0.3" \
"platform-tools" \
"platforms;android-23" \
"platforms;android-26" \
"platforms;android-29" \
"platforms;android-30" \
"platforms;android-31" \
> /dev/null
rm -rf cmdline-tools.zip

0 comments on commit 73cfdad

Please sign in to comment.