Skip to content
Closed
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
65 changes: 50 additions & 15 deletions .buildkite/commands/connected-tests.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,56 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

echo "--- :closed_lock_with_key: Installing Secrets"
./gradlew applyConfiguration
SYSTEM_IMAGE="system-images;android-34;google_apis;x86_64"
AVD_NAME="aztec-connected-tests"
EMULATOR_LOG="build/emulator.log"

echo -e "\n--- :gcloud: Logging into Google Cloud"
gcloud auth activate-service-account --key-file .configure-files/firebase.secrets.json
BUILD_SDK="$ANDROID_HOME"
# The agent user cannot write to the image's SDK, and Gradle still needs it.
EMULATOR_SDK="$(mktemp -d)"
ln -s "$BUILD_SDK/licenses" "$EMULATOR_SDK/licenses"
ln -s "$BUILD_SDK/platform-tools" "$EMULATOR_SDK/platform-tools"
ln -s "$BUILD_SDK/platforms" "$EMULATOR_SDK/platforms"
export ANDROID_HOME="$EMULATOR_SDK"
export ANDROID_SDK_ROOT="$EMULATOR_SDK"
export PATH="$EMULATOR_SDK/cmdline-tools/latest/bin:$EMULATOR_SDK/emulator:$EMULATOR_SDK/platform-tools:$PATH"

echo -e "\n--- :hammer_and_wrench: Building Tests"
./gradlew --stacktrace app:assembleDebug app:assembleDebugAndroidTest
stop_emulator() {
adb emu kill || true
avdmanager delete avd --name "$AVD_NAME" || true
rm -rf "$EMULATOR_SDK"
}

echo -e "\n--- :firebase: Run Tests"
gcloud firebase test android run \
--project api-project-108380595987 \
--type instrumentation \
--app app/build/outputs/apk/debug/app-debug.apk \
--test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
--device model=Nexus5X,version=26,locale=en,orientation=portrait \
--verbosity info
echo "--- :package: Installing emulator and system image"
# `avdmanager` resolves the SDK from its own location, ignoring `ANDROID_HOME`, so it has to live in this SDK too.
sdkmanager --sdk_root="$EMULATOR_SDK" "cmdline-tools;latest" "emulator" "$SYSTEM_IMAGE" > /dev/null

# The image lacks this library, and the emulator segfaults without it, even with `-no-window`.
EMULATOR_LIBS="$EMULATOR_SDK/extra-libs"
mkdir -p "$EMULATOR_LIBS"
dnf download --destdir "$EMULATOR_LIBS" libX11-xcb > /dev/null
rpm2cpio "$EMULATOR_LIBS"/*.rpm | (cd "$EMULATOR_LIBS" && cpio -idm --quiet)

echo "--- :mag: Checking hardware acceleration"
ls -la /dev/kvm
emulator -accel-check

echo "--- :robot_face: Starting Android emulator"
avdmanager create avd --force --name "$AVD_NAME" --package "$SYSTEM_IMAGE" --device "pixel_5" <<< "no"
trap stop_emulator EXIT

mkdir -p "$(dirname "$EMULATOR_LOG")"
LD_LIBRARY_PATH="$EMULATOR_LIBS/usr/lib64" emulator -avd "$AVD_NAME" -no-window -no-audio -no-boot-anim -no-snapshot -no-metrics -gpu swiftshader_indirect > "$EMULATOR_LOG" 2>&1 &

timeout 300 adb wait-for-device
timeout 300 bash -c 'until [[ "$(adb shell getprop sys.boot_completed 2> /dev/null | tr -d "\r")" == "1" ]]; do sleep 5; done'

adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
adb shell settings put secure long_press_timeout 1800
adb shell input keyevent 82

echo "--- :android: Running connected tests"
ANDROID_HOME="$BUILD_SDK" ANDROID_SDK_ROOT="$BUILD_SDK" ./gradlew --stacktrace :app:connectedDebugAndroidTest
4 changes: 3 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ steps:
command: .buildkite/commands/connected-tests.sh
plugins: [$CI_TOOLKIT]
artifact_paths:
- "aztec/build/test-results/**/*.xml"
- "app/build/reports/androidTests/connected/**/*"
- "app/build/outputs/androidTest-results/connected/**/*"
- "build/emulator.log"

- label: "Publish :aztec"
key: "publish-aztec"
Expand Down
11 changes: 0 additions & 11 deletions .configure

This file was deleted.

Binary file removed .configure-files/firebase.secrets.json.enc
Binary file not shown.
10 changes: 0 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,3 @@ ktlint

# Dependencies
vendor

# Currently, the configure tool stores the encrypted files under
# .configure-files. Everything in that folder without a .enc extension should
# be ignored.
.configure-files/*
!.configure-files/*.enc

# Secrets files that should never be committed, regardless of location
firebase.secrets.json

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package org.wordpress.aztec.demo

import android.os.Build
import android.util.Log
import androidx.test.rule.GrantPermissionRule
import androidx.test.runner.AndroidJUnit4
Expand All @@ -12,8 +13,11 @@ import org.junit.runner.RunWith
abstract class BaseTest {
@Rule
@JvmField
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(android.Manifest.permission.CAMERA,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
val grantPermissionRule: GrantPermissionRule = if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
GrantPermissionRule.grant(android.Manifest.permission.CAMERA)
} else {
GrantPermissionRule.grant(android.Manifest.permission.CAMERA, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
}

companion object {
fun label(label: String) {
Expand Down
11 changes: 0 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
repositories {
maven { url "https://a8c-libs.s3.amazonaws.com/android" }
}
dependencies {
classpath 'com.automattic.android:configure:0.6.5'
}
}

plugins {
id "com.android.application" apply false
id "org.jetbrains.kotlin.android" apply false
Expand All @@ -35,8 +26,6 @@ allprojects {
}
}

apply plugin: 'com.automattic.android.configure'

task clean(type: Delete) {
delete rootProject.buildDir
}
Expand Down
Loading