Skip to content

Commit

Permalink
Retry download and install NDK when testing Android (pytorch#97067)
Browse files Browse the repository at this point in the history
As this step uses network to download and install NDK, it could fail flakily, i.e. https://github.com/pytorch/pytorch/actions/runs/4452757793/jobs/7820701670.  So I'm adding retrying to the workflow.

I could try figure out a way to Dockerize this, but not sure yet how to handle the GitHub action `reactivecircus/android-emulator-runner@v2` in Docker.  So let's opt for the easy fix of retrying.
Pull Request resolved: pytorch#97067
Approved by: https://github.com/malfet
  • Loading branch information
huydhn authored and pytorchmergebot committed Mar 23, 2023
1 parent 37faa48 commit 1fb1c6e
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions .github/workflows/_run_android_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,39 @@ jobs:
python-version: 3.8
environment-file: .github/requirements/conda-env-${{ runner.os }}-${{ runner.arch }}

- name: Build PyTorch Android
run: |
# Install NDK 21 after GitHub update
# https://github.com/actions/virtual-environments/issues/5595
ANDROID_ROOT="/usr/local/lib/android"
ANDROID_SDK_ROOT="${ANDROID_ROOT}/sdk"
SDKMANAGER="${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager"
echo "y" | ${SDKMANAGER} "ndk;21.4.7075529"
- name: Install NDK
uses: nick-fields/[email protected]
with:
timeout_minutes: 5
max_attempts: 3
retry_wait_seconds: 90
command: |
# Install NDK 21 after GitHub update
# https://github.com/actions/virtual-environments/issues/5595
ANDROID_ROOT="/usr/local/lib/android"
ANDROID_SDK_ROOT="${ANDROID_ROOT}/sdk"
ANDROID_NDK="${ANDROID_SDK_ROOT}/ndk-bundle"
ANDROID_NDK_VERSION="21.4.7075529"
SDKMANAGER="${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager"
# NB: This step downloads and installs NDK, thus it could be flaky.
# However, SDKMANAGER doesn't return a non-zero status code when it
# happens despite the fact that the corrupted file that it has isn't
# a ZIP archive and couldn't be extracted
echo "y" | ${SDKMANAGER} "ndk;${ANDROID_NDK_VERSION}"
export ANDROID_NDK="${ANDROID_SDK_ROOT}/ndk-bundle"
ln -sfn ${ANDROID_SDK_ROOT}/ndk/21.4.7075529 ${ANDROID_NDK}
ln -sfn "${ANDROID_SDK_ROOT}/ndk/${ANDROID_NDK_VERSION}" "${ANDROID_NDK}"
# So, we need to manually verify the existence of NDK afterward
# and return a failure if the file isn't there
if [ ! -f "${ANDROID_NDK}/build/cmake/android.toolchain.cmake" ]; then
exit 1
fi
echo "ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT}" >> "${GITHUB_ENV}"
echo "ANDROID_NDK=${ANDROID_NDK}" >> "${GITHUB_ENV}"
- name: Build PyTorch Android
run: |
echo "CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname "$(which conda)")/../"}" >> "${GITHUB_ENV}"
${CONDA_RUN} ./scripts/build_pytorch_android.sh x86
Expand Down

0 comments on commit 1fb1c6e

Please sign in to comment.