-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #1 by jylinv0: Add ci.yaml for github workflows
Add instrumentation test to github workflow Closes #1 PiperOrigin-RevId: 605482436 Change-Id: I531ce6880b7b81f284ef1d6cab31eaec77580067
- Loading branch information
1 parent
f2c8f3b
commit 29fdfe8
Showing
28 changed files
with
709 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.swp | ||
*.swo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
workspace(name = "rules_utp") | ||
|
||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") | ||
load("@rules_android//rules:rules.bzl", "android_sdk_repository") | ||
|
||
maybe( | ||
android_sdk_repository, | ||
name = "androidsdk", | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
load("@rules_android//rules:rules.bzl", "android_binary", "android_library") | ||
load( | ||
"@rules_utp//launcher:rules.bzl", | ||
"UTP_RELEASE", | ||
"android_environment", | ||
"environment", | ||
"environment_variable", | ||
"instrumentation", | ||
"instrumentation_args", | ||
"utp_entry_point", | ||
) | ||
load(":rule.bzl", "android_instrumentation_test") | ||
|
||
package( | ||
default_applicable_licenses = ["@rules_utp//:license"], | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
android_instrumentation_test( | ||
name = "sample_instrumentation", | ||
device_serial = "emulator-5554", # Default serial-no | ||
entry_point = ":entry_point", | ||
environment = ":default_environment", | ||
instrumentation = ":device_instrumentation", | ||
instrumentation_args = ":device_instrumentation_args", | ||
support_apps = [":sample_app"], | ||
test_app = ":test_app", | ||
utp_release = "@rules_utp" + UTP_RELEASE, | ||
) | ||
|
||
android_binary( | ||
name = "test_app", | ||
instruments = ":sample_app", | ||
manifest = "//lib:AndroidManifest.xml", | ||
multidex = "native", | ||
deps = [ | ||
":test_src", | ||
"@android_maven//:com_android_support_multidex", | ||
], | ||
) | ||
|
||
android_library( | ||
name = "test_src", | ||
srcs = ["//lib:SampleTest.java"], | ||
deps = [ | ||
":sample_lib", | ||
"@androidx_maven//:androidx_test_core", | ||
"@androidx_maven//:androidx_test_espresso_espresso_core", | ||
"@androidx_maven//:androidx_test_ext_junit", | ||
"@androidx_maven//:androidx_test_runner", | ||
"@bazel_tools//tools/jdk:TestRunner", | ||
], | ||
) | ||
|
||
android_binary( | ||
name = "sample_app", | ||
custom_package = "com.sample", | ||
manifest = "//lib:SampleAndroidManifest.xml", | ||
multidex = "native", | ||
deps = [ | ||
":sample_lib", | ||
"@android_maven//:com_android_support_multidex", | ||
], | ||
) | ||
|
||
android_library( | ||
name = "sample_lib", | ||
srcs = ["//lib:SampleActivity.java"], | ||
custom_package = "com.sample", | ||
manifest = "//lib:SampleAndroidManifest.xml", | ||
resource_files = ["//lib:resource_files"], | ||
) | ||
|
||
## instruments | ||
|
||
instrumentation( | ||
name = "device_instrumentation", | ||
app_package = "com.sample", | ||
test_package = "com.sample.test", | ||
test_runner_class = "androidx.test.runner.AndroidJUnitRunner", | ||
) | ||
|
||
instrumentation_args( | ||
name = "device_instrumentation_args", | ||
# enable_debug = True, # Need to launch debugger otherwise test will hang | ||
) | ||
|
||
## environment | ||
|
||
android_environment( | ||
name = "android_environment", | ||
test_log_dir = "/tmp/ait/testlog", | ||
test_run_log = "test-results.log", | ||
) | ||
|
||
environment( | ||
name = "default_environment", | ||
android_environment = ":android_environment", | ||
output_dir = environment_variable("TEST_UNDECLARED_OUTPUTS_DIR"), | ||
runfiles_dir = "{}/test_local_repo".format(environment_variable("TEST_SRCDIR")), | ||
tmp_dir = environment_variable("TEST_TMPDIR"), | ||
) | ||
|
||
### UTP entry point | ||
utp_entry_point( | ||
name = "entry_point", | ||
testonly = True, | ||
utp_release = "@rules_utp" + UTP_RELEASE, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
module( | ||
name = "example_ait", | ||
version = "TODO", | ||
) | ||
|
||
bazel_dep(name = "rules_android", version = "0.1.1") | ||
bazel_dep(name = "rules_utp", version = "0.0.1") | ||
bazel_dep(name = "rules_jvm_external", version = "5.3") | ||
|
||
|
||
bazel_dep(name = "rules_java", version = "7.3.2") | ||
rules_java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains") | ||
use_repo(rules_java_toolchains, "remote_java_tools") | ||
bazel_dep(name = "bazel_skylib", version = "1.4.1") | ||
|
||
|
||
UTP_VERSION = "0.0.9-alpha01" | ||
SERVICES_VERSION = "1.4.2" | ||
androidxLibVersion = "1.0.0" | ||
coreVersion = "1.6.0-alpha05" | ||
extJUnitVersion = "1.2.0-alpha03" | ||
espressoVersion = "3.6.0-alpha03" | ||
runnerVersion = "1.6.0-alpha06" | ||
rulesVersion = "1.6.0-alpha03" | ||
|
||
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") | ||
maven.install( | ||
name = "android_maven", | ||
artifacts = [ | ||
"com.android.support:multidex:1.0.3", | ||
"com.android.support.test:runner:1.0.2", | ||
], | ||
repositories = [ | ||
"https://maven.google.com", | ||
"https://repo1.maven.org/maven2", | ||
], | ||
) | ||
maven.install( | ||
name = "androidx_maven", | ||
artifacts = [ | ||
"androidx.test:core:" + coreVersion, | ||
"androidx.test.espresso:espresso-core:" + espressoVersion, | ||
"androidx.test.ext:junit:" + extJUnitVersion, | ||
"androidx.test:runner:" + runnerVersion, | ||
"androidx.test:rules:" + rulesVersion, | ||
], | ||
fetch_sources = True, | ||
# To generate the maven lockfile, run this command: | ||
# bazel run --noenable_bzlmod @rules_androidx_maven//:pin | ||
# lock_file = "//:rules_androidx_maven_install.json", | ||
repositories = [ | ||
"https://maven.google.com", | ||
"https://repo1.maven.org/maven2", | ||
], | ||
) | ||
use_repo( | ||
maven, | ||
"android_maven", "androidx_maven" | ||
) | ||
|
||
|
||
remote_android_extensions = use_extension("@bazel_tools//tools/android:android_extensions.bzl", "remote_android_tools_extensions") | ||
use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools") | ||
|
||
local_path_override( | ||
module_name = "rules_utp", | ||
path = "../../", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
workspace(name = "example_ait") | ||
|
||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") | ||
|
||
local_repository( | ||
name = "rules_utp", | ||
path = "../../", | ||
) | ||
load("@rules_utp//:prereqs.bzl", "rules_utp_prereqs") | ||
rules_utp_prereqs() | ||
|
||
load("@rules_utp//:depprereqs.bzl", "rules_utp_dep_prereqs") | ||
rules_utp_dep_prereqs() | ||
|
||
load("@rules_utp//:defs.bzl", "rules_utp_workspace") | ||
rules_utp_workspace() | ||
|
||
load("defs.bzl", "example_workspace") | ||
example_workspace() | ||
|
||
maybe( | ||
android_sdk_repository, | ||
name = "androidsdk", | ||
) | ||
|
||
|
||
register_toolchains("@rules_android//toolchains/android:all") | ||
register_toolchains("@rules_android//toolchains/android_sdk:all") | ||
register_toolchains("@rules_android//toolchains/emulator:all") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
workspace(name = "example_ait") | ||
|
||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") | ||
load("@rules_android//rules:rules.bzl", "android_sdk_repository") | ||
|
||
maybe( | ||
android_sdk_repository, | ||
name = "androidsdk", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright 2024 The Bazel Authors. All rights reserved. | ||
# | ||
# 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. | ||
|
||
"""Workspace setup macro for rules_android.""" | ||
|
||
load("@rules_jvm_external//:defs.bzl", "maven_install") | ||
|
||
def example_workspace(): | ||
""" Sets up workspace dependencies for rules_android.""" | ||
|
||
CORE_VERSION = "1.6.0-alpha05" | ||
EXT_JUNIT_VERSION = "1.2.0-alpha03" | ||
ESPRESSO_VERSION = "3.6.0-alpha03" | ||
RUNNER_VERSION = "1.6.0-alpha06" | ||
RULES_VERSION = "1.6.0-alpha03" | ||
|
||
maven_install( | ||
name = "android_maven", | ||
artifacts = [ | ||
"com.android.support:multidex:1.0.3", | ||
"com.android.support.test:runner:1.0.2", | ||
], | ||
fetch_sources = True, | ||
repositories = [ | ||
"https://maven.google.com", | ||
"https://repo1.maven.org/maven2", | ||
], | ||
) | ||
|
||
maven_install( | ||
name = "androidx_maven", | ||
artifacts = [ | ||
"androidx.test:core:" + CORE_VERSION, | ||
"androidx.test.espresso:espresso-core:" + ESPRESSO_VERSION, | ||
"androidx.test.ext:junit:" + EXT_JUNIT_VERSION, | ||
"androidx.test:runner:" + RUNNER_VERSION, | ||
"androidx.test:rules:" + RULES_VERSION, | ||
], | ||
fetch_sources = True, | ||
repositories = [ | ||
"https://maven.google.com", | ||
"https://repo1.maven.org/maven2", | ||
], | ||
) |
Oops, something went wrong.