1#!/usr/bin/env bash 2# Copyright 2022 The 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 16set -ex 17 18# change to grpc repo root 19cd $(dirname $0)/../../.. 20 21REPO_ROOT="$(pwd)" 22 23# Build protoc and grpc_cpp_plugin. Codegen is not cross-compiled to Android 24mkdir -p cmake/build 25pushd cmake/build 26cmake -DgRPC_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ../.. 27make protoc grpc_cpp_plugin -j8 28popd 29 30PROTOC=${REPO_ROOT}/cmake/build/third_party/protobuf/protoc 31PLUGIN=${REPO_ROOT}/cmake/build/grpc_cpp_plugin 32 33# Build and run interop instrumentation tests on Firebase Test Lab 34cd "${REPO_ROOT}/src/android/test/interop/" 35./gradlew assembleDebug --parallel \ 36 "-Pprotoc=${PROTOC}" \ 37 "-Pgrpc_cpp_plugin=${PLUGIN}" 38./gradlew assembleDebugAndroidTest \ 39 "-Pprotoc=${PROTOC}" \ 40 "-Pgrpc_cpp_plugin=${PLUGIN}" 41 42# TODO(jtattermusch): make it easier to run this test locally 43# under docker. The issue is that "gcloud firebase" requires being authenticated 44# with gcloud first (while on CI we can rely on GCE default credentials). 45gcloud firebase test android run \ 46 --type instrumentation \ 47 --app app/build/outputs/apk/debug/app-debug.apk \ 48 --test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \ 49 --device model=Nexus6P,version=27,locale=en,orientation=portrait \ 50 --device model=Nexus6P,version=26,locale=en,orientation=portrait \ 51 --device model=Nexus6P,version=25,locale=en,orientation=portrait \ 52 --device model=Nexus6P,version=24,locale=en,orientation=portrait \ 53 --device model=Nexus6P,version=23,locale=en,orientation=portrait \ 54 --device model=Nexus6,version=22,locale=en,orientation=portrait \ 55 --device model=Nexus6,version=21,locale=en,orientation=portrait \ 56 --device model=walleye,version=28,locale=en,orientation=portrait 57 58# Build hello world example 59cd "${REPO_ROOT}/examples/android/helloworld" 60./gradlew build \ 61 "-Pprotoc=${PROTOC}" \ 62 "-Pgrpc_cpp_plugin=${PLUGIN}" 63