Skip to content

Commit

Permalink
Fix mempool.space ios tests (#622)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sstone authored and pm47 committed May 15, 2024
1 parent 10b2c43 commit a82e665
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 32 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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.
Expand Down Expand Up @@ -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<org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest>().configureEach {
dependsOn(startIosSimulator)
device = deviceName
standalone.set(false)
finalizedBy(stopIosSimulator)
}
}

tasks.withType<org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest> {
environment("TEST_RESOURCES_PATH", projectDir.resolve("src/commonTest/resources"))
}
Expand Down Expand Up @@ -303,7 +333,7 @@ tasks.withType<AbstractTestTask> {
// Those tests use TLS sockets which are not supported on Linux and MacOS
tasks
.filterIsInstance<KotlinNativeTest>()
.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")
Expand Down

0 comments on commit a82e665

Please sign in to comment.