From 59ca31fb6310bd27ca7c4a7bada06ac7e52471f3 Mon Sep 17 00:00:00 2001 From: thunderbiscuit Date: Wed, 15 Nov 2023 10:48:57 -0500 Subject: [PATCH] ci: run android tests in emulator on ci --- .github/workflows/test-android.yaml | 18 +++++++++--------- bdk-android/lib/build.gradle.kts | 12 ++++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-android.yaml b/.github/workflows/test-android.yaml index d80abd9c..72ca5c4c 100644 --- a/.github/workflows/test-android.yaml +++ b/.github/workflows/test-android.yaml @@ -10,11 +10,11 @@ on: - "bdk-ffi/**" - "bdk-android/**" -# The default Android NDK on the ubuntu-22.04 image is 25.2.9519653 +# The default Android NDK on the macos-12 image is 25.2.9519653 jobs: build: - runs-on: ubuntu-20.04 + runs-on: macos-12 steps: - name: "Show default version of NDK" run: echo $ANDROID_NDK_ROOT @@ -48,10 +48,10 @@ jobs: cd bdk-android ./gradlew buildAndroidLib --console=plain -# There are currently no unit tests for bdk-android (see the tests in bdk-jvm instead) and the -# integration tests require the macOS image which is not working with the older NDK version we -# are using, so for now we just make sure that the library builds and omit the connectedTest -# - name: "Run Android connected tests" -# run: | -# cd bdk-android -# ./gradlew connectedAndroidTest --console=plain + - name: "Run connected tests" + uses: ReactiveCircus/android-emulator-runner@v2 + with: + api-level: 31 + target: google_apis + arch: x86_64 + script: cd ./bdk-android/ && ./gradlew connectedAndroidTest --console=plain -P excludeConnectedTests diff --git a/bdk-android/lib/build.gradle.kts b/bdk-android/lib/build.gradle.kts index 1cf6b1f8..7c32d168 100644 --- a/bdk-android/lib/build.gradle.kts +++ b/bdk-android/lib/build.gradle.kts @@ -57,6 +57,18 @@ dependencies { androidTestImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.6.10") } +// This block ensures that the tests that require access to a blockchain are not +// run if the -P excludeConnectedTests flag is passed to Gradle. +// This ensures our CI runs are not fickle by not requiring access to testnet. +// This is a workaround until we have a proper regtest setup for the CI. +// Note that the command in the CI is ./gradlew connectedAndroidTest -P excludeConnectedTests +tasks.withType(com.android.build.gradle.tasks.factory.AndroidUnitTest).configureEach { + if (project.hasProperty("excludeConnectedTests")) { + exclude("**/LiveWalletTest.class") + exclude("**/LiveTxBuilderTest.class") + } +} + afterEvaluate { publishing { publications {