From a82e665326060cfb95996f35f4f98c9575acd783 Mon Sep 17 00:00:00 2001 From: Fabrice Drouin Date: Wed, 27 Mar 2024 09:01:20 +0100 Subject: [PATCH] Fix mempool.space ios tests (#622) * Fix mempool.space ios tests on github CI These tests include https calls which won't work if the ios simulator is started in standalone mode, which is the default mode. We modified our build and github CI workflow to run tests with `./gradlew -PiosSimulatorMode=standalone` and start the emulator "manually". Builds on dev machine remains the same and mempool.space will still fail on dev machine (unless users set `-PiosSimulatorMode=standalone` ) * Set version to 1.6.2-FEECREDIT-5 --- .github/workflows/release.yml | 2 +- .github/workflows/snapshot.yml | 2 +- .github/workflows/test.yml | 2 +- build.gradle.kts | 34 ++++++++++++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ba25098f..575615886 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,7 +39,7 @@ jobs: with: java-version: 11 - name: Check - run: ./gradlew check + run: ./gradlew -PiosSimulatorMode=standalone check - name: Publish Linux if: matrix.os == 'ubuntu-latest' shell: bash diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 1187abd71..4b50447bc 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -47,7 +47,7 @@ jobs: with: java-version: 11 - name: Check - run: ./gradlew check + run: ./gradlew -PiosSimulatorMode=standalone check - name: Publish Linux to Maven Local if: matrix.os == 'ubuntu-latest' shell: bash diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index df3c6ba08..d9462a75c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -64,7 +64,7 @@ jobs: run: ./gradlew build -PintegrationTests=include - name: Check without integration if: matrix.os == 'macOS-latest' - run: ./gradlew build -x jvmTest + run: ./gradlew build -PiosSimulatorMode=standalone -x jvmTest # Uncomment the lines below to store test results for debugging failed tests (useful for iOS) # - name: Store test results diff --git a/build.gradle.kts b/build.gradle.kts index 619f1b781..6f4b9e8bc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest +import java.io.ByteArrayOutputStream plugins { kotlin("multiplatform") version "1.9.23" @@ -10,7 +11,7 @@ plugins { allprojects { group = "fr.acinq.lightning" - version = "1.6.2-FEECREDIT-4" + version = "1.6.2-FEECREDIT-5" repositories { // using the local maven repository with Kotlin Multi Platform can lead to build errors that are hard to diagnose. @@ -265,6 +266,35 @@ afterEvaluate { })) } } + + val deviceName = project.findProperty("iosDevice") as? String ?: "iPhone 14" + + val startIosSimulator by tasks.creating(Exec::class) { + isIgnoreExitValue = true + errorOutput = ByteArrayOutputStream() + commandLine("xcrun", "simctl", "boot", deviceName) + doLast { + val result = executionResult.get() + if (result.exitValue != 148 && result.exitValue != 149) { + println(errorOutput.toString()) + result.assertNormalExitValue() + } + } + } + + val stopIosSimulator by tasks.creating(Exec::class) { + commandLine("xcrun", "simctl", "shutdown", "all") + } + + if (project.findProperty("iosSimulatorMode") == "standalone") { + tasks.withType().configureEach { + dependsOn(startIosSimulator) + device = deviceName + standalone.set(false) + finalizedBy(stopIosSimulator) + } + } + tasks.withType { environment("TEST_RESOURCES_PATH", projectDir.resolve("src/commonTest/resources")) } @@ -303,7 +333,7 @@ tasks.withType { // Those tests use TLS sockets which are not supported on Linux and MacOS tasks .filterIsInstance() - .filter { it.name == "macosX64Test" || it.name == "linuxX64Test" } + .filter { it.name == "macosX64Test" || it.name == "macosArm64Test" || it.name == "linuxX64Test" } .map { it.filter.excludeTestsMatching("*IntegrationTest") it.filter.excludeTestsMatching("*ElectrumClientTest")