forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (84 loc) · 3.36 KB
/
_run_android_tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: android-tests
on:
workflow_call:
inputs:
test-matrix:
required: true
type: string
description: |
A JSON description of what configs to run later on.
defaults:
run:
shell: bash -e -l {0}
jobs:
filter:
runs-on: [self-hosted, linux.large]
outputs:
test-matrix: ${{ steps.filter.outputs.test-matrix }}
is-test-matrix-empty: ${{ steps.filter.outputs.is-test-matrix-empty }}
keep-going: ${{ steps.filter.outputs.keep-going }}
steps:
- name: Checkout PyTorch
uses: pytorch/pytorch/.github/actions/checkout-pytorch@main
with:
fetch-depth: 1
submodules: false
- name: Select all requested test configurations
id: filter
uses: ./.github/actions/filter-test-configs
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
test-matrix: ${{ inputs.test-matrix }}
build-and-test:
needs: filter
# Don't run on forked repos.
if: github.repository_owner == 'pytorch' && needs.filter.outputs.is-test-matrix-empty == 'False'
strategy:
matrix: ${{ fromJSON(needs.filter.outputs.test-matrix) }}
fail-fast: false
runs-on: ${{ matrix.runner }}
steps:
# [see note: pytorch repo ref]
- name: Checkout PyTorch
uses: pytorch/pytorch/.github/actions/checkout-pytorch@main
- name: Setup miniconda
uses: pytorch/test-infra/.github/actions/setup-miniconda@main
with:
python-version: 3.8
environment-file: .github/requirements/conda-env-${{ runner.os }}-${{ runner.arch }}
- 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}"
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
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 25
script: ./android/run_tests.sh