Skip to content

[AINFRA-435] Test Setup to Validate Android Agent (mac-metal) #14241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .buildkite/commands/run-instrumented-tests-emulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash -u

echo "--- 📋 Checking Android SDK"
echo "adb --version"
adb --version
echo "emulator -list-avds"
emulator -list-avds
echo ""

echo "--- 🤖 Launching Emulator(s)"
echo "emulator -avd pixel5api34 -no-snapshot -no-boot-anim -no-audio &"
emulator -avd pixel5api34 -no-snapshot -no-boot-anim -no-audio &
echo ""

echo "--- 🤖 Waiting for Emulator(s) to Start"
echo "adb wait-for-device"
adb wait-for-device
echo "while [ "$(adb shell getprop sys.boot_completed | tr -d '\r')" != "1" ]; do"
echo " sleep 1"
echo "done"
while [ "$(adb shell getprop sys.boot_completed | tr -d '\r')" != "1" ]; do
sleep 1
done
echo ""

echo "--- 🤖 Unlock Emulator(s)"
echo "adb shell dumpsys window | grep mDreamingLockscreen"
adb shell dumpsys window | grep mDreamingLockscreen
echo "adb -s emulator-5554 shell input keyevent 82"
adb -s emulator-5554 shell input keyevent 82
echo ""

echo "--- 🤖 Checking Emulator(s)"
echo "adb devices"
adb devices
echo "adb shell dumpsys window | grep mDreamingLockscreen"
adb shell dumpsys window | grep mDreamingLockscreen
echo ""

echo "--- 🧪 Testing"
./gradlew :WooCommerce:connectedVanillaDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.woocommerce.android.e2e.tests.ui.ReviewsUITest
ui_test_exit_code=$?
echo ""

echo "--- 🤖 Checking Emulator(s)"
echo "adb devices"
adb devices
echo ""

echo "--- 🤖 Stopping Emulator(s)"
echo "adb -s emulator-5554 emu kill"
adb -s emulator-5554 emu kill
echo "adb devices"
while adb devices | grep -q emulator-5554; do sleep 1; done
echo ""

exit $ui_test_exit_code
140 changes: 37 additions & 103 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,108 +1,42 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
---

# Nodes with values to reuse in the pipeline.
common_params:
# Common plugin settings to use with the `plugins` key.
- &test_collector_common_params
files: "WooCommerce/build/buildkite-test-analytics/*.xml"
format: "junit"

agents:
queue: "android"

steps:
- label: Gradle Wrapper Validation
command: validate_gradle_wrapper
agents:
queue: linter

# Wait for Gradle Wrapper to be validated before running any other jobs
- wait

########################################
- group: "🕵️ Linters"
steps:

- label: "☢️ Danger - PR Check"
command: danger
key: danger
if: "build.pull_request.id != null"
retry:
manual:
permit_on_passed: true
agents:
queue: "linter"

- label: "detekt"
command: |
if .buildkite/commands/should-skip-job.sh --job-type validation; then
exit 0
fi
./gradlew detektAll
plugins: [$CI_TOOLKIT]
artifact_paths:
- "**/build/reports/detekt/detekt.html"

- label: "lint"
command: .buildkite/commands/lint.sh
plugins: [$CI_TOOLKIT]
artifact_paths:
- "**/build/reports/lint-results*.*"

- label: "Dependency Tree Diff"
command: comment_with_dependency_diff 'woocommerce' 'vanillaReleaseRuntimeClasspath'
if: build.pull_request.id != null
plugins: [$CI_TOOLKIT]
artifact_paths:
- "**/build/reports/diff/*"

- label: "Merged Manifest Diff"
command: ".buildkite/commands/diff-merged-manifest.sh vanillaRelease"
if: build.pull_request.id != null
plugins: [$CI_TOOLKIT]
artifact_paths:
- "**/build/reports/diff_manifest/**/**/*"

########################################
- group: "🛠 Prototype Builds"
steps:

- label: "🛠 Prototype Build: Mobile App"
command: ".buildkite/commands/prototype-build.sh WooCommerce"
if: build.pull_request.id != null
plugins: [$CI_TOOLKIT]

- label: "🛠 Prototype Build: Wear App"
command: ".buildkite/commands/prototype-build.sh WooCommerce-Wear"
if: build.pull_request.id != null
plugins: [$CI_TOOLKIT]

########################################
- group: "🔬 Tests"
steps:

- label: "Unit tests"
command: .buildkite/commands/run-unit-tests.sh
plugins:
- $CI_TOOLKIT
- $TEST_COLLECTOR :
<<: *test_collector_common_params
api-token-env-name: "BUILDKITE_ANALYTICS_TOKEN_UNIT_TESTS"
artifact_paths:
- "**/build/test-results/merged-test-results.xml"

- label: "Instrumented tests"
command: .buildkite/commands/run-instrumented-tests.sh
plugins:
- $CI_TOOLKIT
- $TEST_COLLECTOR :
<<: *test_collector_common_params
api-token-env-name: "BUILDKITE_ANALYTICS_TOKEN_INSTRUMENTED_TESTS"
artifact_paths:
- "**/build/instrumented-tests/**/*"


- label: "🐘 Populate Gradle build cache"
command: .buildkite/commands/gradle-cache-build.sh
- label: "Test mac-metal queue"
command: |
env
echo "Hello, world!"
aws --version
plugins: [$CI_TOOLKIT]
agents:
queue: "mac-metal"

- label: "Assemble"
command: |
echo "--- 🛠 Building"
./gradlew :WooCommerce:assembleJalapenoDebug
plugins: [ $CI_TOOLKIT ]
artifact_paths:
- "**/build/outputs/apk/**/**/*"
agents:
queue: "mac-metal"

- label: "Instrumented tests without GMD (ReviewsUITest)"
command: .buildkite/commands/run-instrumented-tests-emulator.sh
plugins: [ $CI_TOOLKIT ]
artifact_paths:
- "**/build/reports/androidTests/connected/**/**/**/*"
- "**/build/reports/androidTests/connected/**/**/**/**/*"
agents:
queue: "mac-metal"

- label: "Instrumented tests with GMD (ReviewsUITest)"
command: |
echo "--- 🧪 Testing"
./gradlew :WooCommerce:pixel5api34VanillaDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.woocommerce.android.e2e.tests.ui.ReviewsUITest
plugins: [ $CI_TOOLKIT ]
artifact_paths:
- "**/build/reports/androidTests/managedDevice/**/**/**/pixel5api34/*"
- "**/build/reports/androidTests/managedDevice/**/**/**/pixel5api34/**/*"
agents:
queue: "mac-metal"
9 changes: 9 additions & 0 deletions WooCommerce/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ android {
testOptions {
animationsDisabled = true
execution 'ANDROIDX_TEST_ORCHESTRATOR'
managedDevices {
localDevices {
pixel5api34 {
device = "Pixel 5"
apiLevel = 34
systemImageSource = "google"
}
}
}
}

signingConfigs {
Expand Down