Skip to content

Commit

Permalink
ci: run android apps in the emulator (#205)
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Nino [email protected]

Description: previously the CI runs would only build the demos. However we did not run them, or check for liveliness. This PR adds running all the Android demos in the emulator for Mac CI.
Risk Level: low - improved CI
Testing: tested locally and on CI

Fixes #117

Signed-off-by: JP Simard <[email protected]>
  • Loading branch information
junr03 authored and jpsim committed Nov 28, 2022
1 parent 68f27dc commit b216561
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
14 changes: 10 additions & 4 deletions mobile/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ stages:
inputs:
artifactName: 'envoy-mac.aar'
targetPath: dist
- script: bazel build --fat_apk_cpu=x86 //examples/java/hello_world:hello_envoy
displayName: 'Build java app'
- template: ci/templates/start_android_emulator.yaml
- script: bazel mobile-install --fat_apk_cpu=x86 --start_app //examples/java/hello_world:hello_envoy
displayName: 'Start java app'
- script: adb logcat -e "successful response!" -m 1
displayName: 'Check liveliness'
- job: mac_kotlin_helloworld
dependsOn: mac_dist
timeoutInMinutes: 60
Expand All @@ -168,8 +171,11 @@ stages:
inputs:
artifactName: 'envoy-mac.aar'
targetPath: dist
- script: bazel build --fat_apk_cpu=x86 //examples/kotlin/hello_world:hello_envoy_kt
displayName: 'Build kotlin app'
- template: ci/templates/start_android_emulator.yaml
- script: bazel mobile-install --fat_apk_cpu=x86 --start_app //examples/kotlin/hello_world:hello_envoy_kt
displayName: 'Start kotlin app'
- script: adb logcat -e "successful response!" -m 1
displayName: 'Check liveliness'
- stage: ios
dependsOn: [] # this removes the implicit dependency on previous stage and causes this to run in parallel.
jobs:
Expand Down
7 changes: 7 additions & 0 deletions mobile/ci/templates/start_android_emulator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
steps:
- script: echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-28;google_apis;x86'
displayName: 'Install Android '
- script: echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n test_android_emulator -k 'system-images;android-28;google_apis;x86' --force
displayName: 'Create AVD'
- script: nohup $ANDROID_HOME/emulator/emulator -avd test_android_emulator -no-snapshot > /dev/null 2>&1 & $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
displayName: 'Start Android emulator'
1 change: 1 addition & 0 deletions mobile/examples/java/hello_world/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private Response makeRequest() {
InputStream inputStream = connection.getInputStream();
String body = deserialize(inputStream);
inputStream.close();
Log.d("Response", "successful response!");
return new Success(body,
serverHeaderField != null ? String.join(", ", serverHeaderField) : "");
} else {
Expand Down
2 changes: 2 additions & 0 deletions mobile/examples/kotlin/shared/ResponseViewHolder.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.envoyproxy.envoymobile.shared

import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.View
import android.widget.TextView

Expand All @@ -15,6 +16,7 @@ class ResponseViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
{ success ->
responseTextView.text = responseTextView.resources.getString(R.string.title_string, success.title)
headerTextView.text = headerTextView.resources.getString(R.string.header_string, success.header)
Log.d("ResponseViewHolder", "successful response!")
},
{ failure ->
responseTextView.text = responseTextView.resources.getString(R.string.title_string, failure.message)
Expand Down

0 comments on commit b216561

Please sign in to comment.