Skip to content

Commit d8b814b

Browse files
authored
Add support for building android_device and testing android_instrumentation_test emulator tests on RBE (#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
1 parent 422ad27 commit d8b814b

File tree

4 files changed

+103
-7
lines changed

4 files changed

+103
-7
lines changed

.bazelrc

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,55 @@ test --flaky_test_attempts=3
2020

2121
# The unified launcher runs in Python 2 host configuration
2222
# https://github.com/bazelbuild/bazel/issues/7899
23-
build --host_force_python=PY2
23+
build --host_force_python=PY2
24+
25+
# ------------------------
26+
# General RBE configuration
27+
# ------------------------
28+
build:remote --jobs=100
29+
30+
# Java toolchain setup
31+
build:remote --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
32+
build:remote --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
33+
build:remote --host_javabase=@rbe_default//java:jdk
34+
build:remote --javabase=@rbe_default//java:jdk
35+
36+
# C++ toolchain setup
37+
build:remote --extra_toolchains=@rbe_default//config:cc-toolchain
38+
build:remote --crosstool_top=@rbe_default//cc:toolchain
39+
40+
# Remote instance setup
41+
build:remote --remote_instance_name=projects/bazel-untrusted/instances/default_instance
42+
build:remote --project_id=bazel-untrusted
43+
44+
# Set various strategies so that all actions execute remotely. Mixing remote
45+
# and local execution will lead to errors unless the toolchain and remote
46+
# machine exactly match the host machine.
47+
build:remote --spawn_strategy=remote
48+
build:remote --define=EXECUTOR=remote
49+
50+
# Enable the remote cache so action results can be shared across machines,
51+
# developers, and workspaces.
52+
build:remote --remote_cache=remotebuildexecution.googleapis.com
53+
54+
# Enable remote execution so actions are performed on the remote systems.
55+
build:remote --remote_executor=remotebuildexecution.googleapis.com
56+
57+
# Enable authentication. This will pick up application default credentials by
58+
# default.
59+
build:remote --google_default_credentials
60+
61+
# -------------------------------------------
62+
# Custom RBE configuration for Android builds
63+
# -------------------------------------------
64+
65+
build:remote_android --config=remote # Reuse general configuration
66+
67+
# Platform configuration
68+
build:remote_android --extra_execution_platforms=:android_platform
69+
build:remote_android --host_platform=:android_platform
70+
build:remote_android --platforms=:android_platform
71+
72+
build:remote_android --strategy=DexBuilder=remote
73+
build:remote_android --noexperimental_check_desugar_deps # Workaround for singlejar incompatibility with RBE
74+
build:remote_android --incompatible_strict_action_env

BUILD.bazel

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,30 @@ android_library(
2121
artifact("org.hamcrest:java-hamcrest"),
2222
],
2323
)
24+
25+
# Platform configuration for emulators on RBE for Bazel CI
26+
platform(
27+
name = "android_platform",
28+
constraint_values = [
29+
"@bazel_tools//platforms:x86_64",
30+
"@bazel_tools//platforms:linux",
31+
"@bazel_toolchains//constraints:xenial",
32+
"@bazel_tools//tools/cpp:clang",
33+
],
34+
# TODO(@jin): s/di-cloud-exp/rbe-containers/ when the official android-test container with libxcursor1 and libxcomposite1 is ready.
35+
# URI for official container: docker://gcr.io/rbe-containers/ubuntu16_04-android_test@sha256:<sha256>
36+
remote_execution_properties = """
37+
properties: {
38+
name: "container-image"
39+
value: "docker://gcr.io/di-cloud-exp/rbe-ubuntu16-04-android@sha256:eb3828f71faf595f44b20b97d205e73e8a21982f1d7a170c3ec8f9d33ce3179a"
40+
}
41+
properties: {
42+
name: "dockerNetwork"
43+
value: "standard"
44+
}
45+
properties: {
46+
name: "dockerPrivileged"
47+
value: "true"
48+
}
49+
""",
50+
)

WORKSPACE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ android_sdk_repository(
99
# path = "/path/to/sdk",
1010
)
1111

12+
# Required for running emulator tests on RBE on Bazel CI
13+
android_ndk_repository(name = "androidndk")
14+
1215
# Android Test Support
1316
#
1417
# This repository contains the supporting tools to run Android instrumentation tests,
@@ -95,3 +98,20 @@ maven_install(
9598
jetify = True,
9699
version_conflict_policy = "pinned",
97100
)
101+
102+
http_archive(
103+
name = "bazel_toolchains",
104+
sha256 = "4d348abfaddbcee0c077fc51bb1177065c3663191588ab3d958f027cbfe1818b",
105+
strip_prefix = "bazel-toolchains-2.1.0",
106+
urls = [
107+
"https://github.com/bazelbuild/bazel-toolchains/releases/download/2.1.0/bazel-toolchains-2.1.0.tar.gz",
108+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/2.1.0.tar.gz",
109+
],
110+
)
111+
112+
load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
113+
114+
rbe_autoconfig(name = "rbe_default")
115+
116+
# RBE support for android_device and android_instrumentation_test on RBE.
117+
register_execution_platforms(":android_platform")

bazelci/buildkite-pipeline.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ platforms:
55
build_targets:
66
- "//..."
77
test_flags:
8-
- "--local_test_jobs=8" # Run at most 8 tests (= emulators) in parallel
9-
- "--flaky_test_attempts=3" # Flakes.
10-
- "--spawn_strategy=standalone" # Reduce flakes.
8+
- "--config=remote_android"
9+
- "--flaky_test_attempts=3"
1110
test_targets:
1211
- "//..."
1312
- "-//ui/espresso/AccessibilitySample/..."
1413
ubuntu1804:
1514
build_targets:
1615
- "//..."
1716
test_flags:
18-
- "--local_test_jobs=8" # Run at most 8 tests (= emulators) in parallel
19-
- "--flaky_test_attempts=3" # Flakes.
20-
- "--spawn_strategy=standalone" # Reduce flakes.
17+
- "--config=remote_android"
18+
- "--flaky_test_attempts=3"
2119
test_targets:
2220
- "//..."
2321
- "-//ui/espresso/AccessibilitySample/..."

0 commit comments

Comments
 (0)