diff --git a/tools/dockerfile/test/binder_transport_apk/Dockerfile b/tools/dockerfile/test/binder_transport_apk/Dockerfile new file mode 100644 index 00000000000..d10ec1a0db2 --- /dev/null +++ b/tools/dockerfile/test/binder_transport_apk/Dockerfile @@ -0,0 +1,75 @@ +# Copyright 2021 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Pinned version of the base image is used to avoid regressions caused +# by rebuilding of this docker image. To see available versions, you can run +# "gcloud container images list-tags gcr.io/oss-fuzz-base/base-builder" +# TODO(jtattermusch): with the latest version we'd get clang12+ +# which makes our build fail due to new warnings being treated +# as errors. +FROM gcr.io/oss-fuzz-base/base-builder@sha256:de220fd2433cd53bd06b215770dcd14a5e74632e0215acea7401fee8cafb18da + +# This Dockerfile creates the environment for compiling and e2e testing of Android binder transport implementation + +# Install basic packages and Bazel dependencies. +RUN apt-get update && apt-get install -y software-properties-common python-software-properties +RUN add-apt-repository ppa:webupd8team/java +RUN apt-get update && apt-get -y install \ + autoconf \ + build-essential \ + curl \ + wget \ + libtool \ + make \ + openjdk-8-jdk \ + vim + +#======================== +# Android SDK/NDK installation +ENV SDK_ROOT=/opt/android-sdk +RUN mkdir -p ${SDK_ROOT} +RUN wget -O cmd.zip dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip && \ + unzip cmd.zip && \ + yes | ./cmdline-tools/bin/sdkmanager --sdk_root=${SDK_ROOT} 'tools' && \ + yes | ./cmdline-tools/bin/sdkmanager --sdk_root=${SDK_ROOT} 'platform-tools' && \ + yes | ./cmdline-tools/bin/sdkmanager --sdk_root=${SDK_ROOT} 'build-tools;30.0.3' && \ + yes | ./cmdline-tools/bin/sdkmanager --sdk_root=${SDK_ROOT} 'platforms;android-29' && \ + yes | ./cmdline-tools/bin/sdkmanager --sdk_root=${SDK_ROOT} 'ndk-bundle' && \ + yes | ./cmdline-tools/bin/sdkmanager --sdk_root=${SDK_ROOT} 'ndk;21.4.7075529' + +RUN rm cmd.zip + +# Set environment variables for Bazel rules +ENV ANDROID_HOME=/opt/android-sdk +ENV ANDROID_NDK_HOME=/opt/android-sdk/ndk/21.4.7075529 + +#======================== +# Bazel installation + +# Must be in sync with tools/bazel +ENV BAZEL_VERSION 3.7.1 + +# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. +ENV DISABLE_BAZEL_WRAPPER 1 + +RUN apt-get update && apt-get install -y wget && apt-get clean +RUN wget "https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh" && \ + bash ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ + rm bazel-$BAZEL_VERSION-installer-linux-x86_64.sh + + +RUN mkdir -p /var/local/jenkins + +# Define the default command. +CMD ["bash"] diff --git a/tools/internal_ci/linux/grpc_binder_transport_apk.cfg b/tools/internal_ci/linux/grpc_binder_transport_apk.cfg new file mode 100644 index 00000000000..1c2b38c61b8 --- /dev/null +++ b/tools/internal_ci/linux/grpc_binder_transport_apk.cfg @@ -0,0 +1,23 @@ +# Copyright 2021 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/linux/grpc_binder_transport_apk.sh" +timeout_mins: 60 +env_vars { + key: "BAZEL_SCRIPT" + value: "tools/internal_ci/linux/grpc_binder_transport_apk_build_in_docker.sh" +} diff --git a/tools/internal_ci/linux/grpc_binder_transport_apk.sh b/tools/internal_ci/linux/grpc_binder_transport_apk.sh new file mode 100755 index 00000000000..d85474a5fa7 --- /dev/null +++ b/tools/internal_ci/linux/grpc_binder_transport_apk.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Copyright 2021 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +# change to grpc repo root +cd $(dirname $0)/../../.. + +source tools/internal_ci/helper_scripts/prepare_build_linux_rc + +export DOCKERFILE_DIR=tools/dockerfile/test/binder_transport_apk +export DOCKER_RUN_SCRIPT=$BAZEL_SCRIPT +exec tools/run_tests/dockerize/build_and_run_docker.sh diff --git a/tools/internal_ci/linux/grpc_binder_transport_apk_build_in_docker.sh b/tools/internal_ci/linux/grpc_binder_transport_apk_build_in_docker.sh new file mode 100644 index 00000000000..45e05f42676 --- /dev/null +++ b/tools/internal_ci/linux/grpc_binder_transport_apk_build_in_docker.sh @@ -0,0 +1,33 @@ +# Copyright 2021 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#!/usr/bin/env bash +# +# NOTE: No empty lines should appear in this file before igncr is set! +set -ex -o igncr || set -ex + +mkdir -p /var/local/git +git clone /var/local/jenkins/grpc /var/local/git/grpc +(cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc \ +&& git submodule update --init --reference /var/local/jenkins/grpc/${name} \ +${name}') +cd /var/local/git/grpc + +echo $ANDROID_HOME +echo $ANDROID_NDK_HOME + +# Build all basic targets using the strict warning option which leverages the +# clang compiler to check if sources can pass a set of warning options. +bazel build --define=use_strict_warning=true \ + //examples/android/binder/java/io/grpc/binder/cpp/example:app