Skip to content

Commit

Permalink
Add support for building android_device and testing android_instrumen…
Browse files Browse the repository at this point in the history
…tation_test emulator tests on RBE (android#310)

* Add support for building android_device and testing android_instrumentation_test emulator tests on RBE

* Address philwo's comments

* Update base docker image version and --jobs
  • Loading branch information
jin authored Feb 19, 2020
1 parent 422ad27 commit d8b814b
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 7 deletions.
53 changes: 52 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,55 @@ test --flaky_test_attempts=3

# The unified launcher runs in Python 2 host configuration
# https://github.com/bazelbuild/bazel/issues/7899
build --host_force_python=PY2
build --host_force_python=PY2

# ------------------------
# General RBE configuration
# ------------------------
build:remote --jobs=100

# Java toolchain setup
build:remote --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
build:remote --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
build:remote --host_javabase=@rbe_default//java:jdk
build:remote --javabase=@rbe_default//java:jdk

# C++ toolchain setup
build:remote --extra_toolchains=@rbe_default//config:cc-toolchain
build:remote --crosstool_top=@rbe_default//cc:toolchain

# Remote instance setup
build:remote --remote_instance_name=projects/bazel-untrusted/instances/default_instance
build:remote --project_id=bazel-untrusted

# Set various strategies so that all actions execute remotely. Mixing remote
# and local execution will lead to errors unless the toolchain and remote
# machine exactly match the host machine.
build:remote --spawn_strategy=remote
build:remote --define=EXECUTOR=remote

# Enable the remote cache so action results can be shared across machines,
# developers, and workspaces.
build:remote --remote_cache=remotebuildexecution.googleapis.com

# Enable remote execution so actions are performed on the remote systems.
build:remote --remote_executor=remotebuildexecution.googleapis.com

# Enable authentication. This will pick up application default credentials by
# default.
build:remote --google_default_credentials

# -------------------------------------------
# Custom RBE configuration for Android builds
# -------------------------------------------

build:remote_android --config=remote # Reuse general configuration

# Platform configuration
build:remote_android --extra_execution_platforms=:android_platform
build:remote_android --host_platform=:android_platform
build:remote_android --platforms=:android_platform

build:remote_android --strategy=DexBuilder=remote
build:remote_android --noexperimental_check_desugar_deps # Workaround for singlejar incompatibility with RBE
build:remote_android --incompatible_strict_action_env
27 changes: 27 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,30 @@ android_library(
artifact("org.hamcrest:java-hamcrest"),
],
)

# Platform configuration for emulators on RBE for Bazel CI
platform(
name = "android_platform",
constraint_values = [
"@bazel_tools//platforms:x86_64",
"@bazel_tools//platforms:linux",
"@bazel_toolchains//constraints:xenial",
"@bazel_tools//tools/cpp:clang",
],
# TODO(@jin): s/di-cloud-exp/rbe-containers/ when the official android-test container with libxcursor1 and libxcomposite1 is ready.
# URI for official container: docker://gcr.io/rbe-containers/ubuntu16_04-android_test@sha256:<sha256>
remote_execution_properties = """
properties: {
name: "container-image"
value: "docker://gcr.io/di-cloud-exp/rbe-ubuntu16-04-android@sha256:eb3828f71faf595f44b20b97d205e73e8a21982f1d7a170c3ec8f9d33ce3179a"
}
properties: {
name: "dockerNetwork"
value: "standard"
}
properties: {
name: "dockerPrivileged"
value: "true"
}
""",
)
20 changes: 20 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ android_sdk_repository(
# path = "/path/to/sdk",
)

# Required for running emulator tests on RBE on Bazel CI
android_ndk_repository(name = "androidndk")

# Android Test Support
#
# This repository contains the supporting tools to run Android instrumentation tests,
Expand Down Expand Up @@ -95,3 +98,20 @@ maven_install(
jetify = True,
version_conflict_policy = "pinned",
)

http_archive(
name = "bazel_toolchains",
sha256 = "4d348abfaddbcee0c077fc51bb1177065c3663191588ab3d958f027cbfe1818b",
strip_prefix = "bazel-toolchains-2.1.0",
urls = [
"https://github.com/bazelbuild/bazel-toolchains/releases/download/2.1.0/bazel-toolchains-2.1.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/2.1.0.tar.gz",
],
)

load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")

rbe_autoconfig(name = "rbe_default")

# RBE support for android_device and android_instrumentation_test on RBE.
register_execution_platforms(":android_platform")
10 changes: 4 additions & 6 deletions bazelci/buildkite-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ platforms:
build_targets:
- "//..."
test_flags:
- "--local_test_jobs=8" # Run at most 8 tests (= emulators) in parallel
- "--flaky_test_attempts=3" # Flakes.
- "--spawn_strategy=standalone" # Reduce flakes.
- "--config=remote_android"
- "--flaky_test_attempts=3"
test_targets:
- "//..."
- "-//ui/espresso/AccessibilitySample/..."
ubuntu1804:
build_targets:
- "//..."
test_flags:
- "--local_test_jobs=8" # Run at most 8 tests (= emulators) in parallel
- "--flaky_test_attempts=3" # Flakes.
- "--spawn_strategy=standalone" # Reduce flakes.
- "--config=remote_android"
- "--flaky_test_attempts=3"
test_targets:
- "//..."
- "-//ui/espresso/AccessibilitySample/..."
Expand Down

0 comments on commit d8b814b

Please sign in to comment.