Imported Upstream version 1.41.0
[platform/upstream/grpc.git] / tools / internal_ci / linux / grpc_android.sh
1 #!/usr/bin/env bash
2 # Copyright 2018 gRPC authors.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 set -ex
17
18 # Accept the Android SDK licences.
19 yes | /opt/android-sdk/current/tools/bin/sdkmanager --licenses
20
21 # change to grpc repo root
22 cd $(dirname $0)/../../..
23
24 REPO_ROOT="$(pwd)"
25
26 git submodule update --init
27
28 # Build protoc and grpc_cpp_plugin. Codegen is not cross-compiled to Android
29 mkdir -p cmake/build
30 pushd cmake/build
31 cmake -DgRPC_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ../..
32 make protoc grpc_cpp_plugin -j2
33 popd
34
35 PROTOC=${REPO_ROOT}/cmake/build/third_party/protobuf/protoc
36 PLUGIN=${REPO_ROOT}/cmake/build/grpc_cpp_plugin
37
38 # Build and run interop instrumentation tests on Firebase Test Lab
39
40 cd "${REPO_ROOT}/src/android/test/interop/"
41 ./gradlew assembleDebug \
42     "-Pprotoc=${PROTOC}" \
43     "-Pgrpc_cpp_plugin=${PLUGIN}"
44 ./gradlew assembleDebugAndroidTest \
45     "-Pprotoc=${PROTOC}" \
46     "-Pgrpc_cpp_plugin=${PLUGIN}"
47 gcloud firebase test android run \
48     --type instrumentation \
49     --app app/build/outputs/apk/debug/app-debug.apk \
50     --test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
51     --device model=Nexus6P,version=27,locale=en,orientation=portrait \
52     --device model=Nexus6P,version=26,locale=en,orientation=portrait \
53     --device model=Nexus6P,version=25,locale=en,orientation=portrait \
54     --device model=Nexus6P,version=24,locale=en,orientation=portrait \
55     --device model=Nexus6P,version=23,locale=en,orientation=portrait \
56     --device model=Nexus6,version=22,locale=en,orientation=portrait \
57     --device model=Nexus6,version=21,locale=en,orientation=portrait \
58     --device model=walleye,version=28,locale=en,orientation=portrait
59
60
61 # Build hello world example
62
63 cd "${REPO_ROOT}/examples/android/helloworld"
64 ./gradlew build \
65     "-Pprotoc=${PROTOC}" \
66     "-Pgrpc_cpp_plugin=${PLUGIN}"