mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
Reduce parallel JVMs spawned for tests (#7701)
* Set `maxParallelForks = 1` for most tests, except for screenshot ones It turns out the Robolectric setup penalty compounds the more parallel JVMs you spawn. Using 1 JVM vs 8 was up to 2.5x faster in local tests. * Split the roborazzi tests tasks config and CI step
This commit is contained in:
committed by
GitHub
parent
600a989854
commit
7aa43411e0
@@ -78,6 +78,9 @@ jobs:
|
||||
- name: ⚙️ Run screenshot tests
|
||||
run: ./gradlew :tests:uitests:verifyPaparazziDebug $CI_GRADLE_ARG_PROPERTIES
|
||||
|
||||
- name: ⚙️ Run Compound screenshot tests
|
||||
run: ./gradlew :libraries:compound:verifyRoborazziDebug $CI_GRADLE_ARG_PROPERTIES
|
||||
|
||||
- name: ⚙️ Generate kover coverage report
|
||||
run: ./gradlew :koverXmlReportMerged :koverHtmlReportMerged :koverVerifyAll -x testDebugUnitTest $CI_GRADLE_ARG_PROPERTIES
|
||||
|
||||
|
||||
@@ -153,7 +153,10 @@ allprojects {
|
||||
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
|
||||
|
||||
val isScreenshotTest = project.gradle.startParameter.taskNames.any { it.contains("paparazzi", ignoreCase = true) }
|
||||
val isRoborazziTest = project.gradle.startParameter.taskNames.any { it.contains("roborazzi", ignoreCase = true) }
|
||||
if (isScreenshotTest) {
|
||||
// Paparazzi tests benefit from parallelisation, so we can use half the available cores to run them in parallel.
|
||||
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
|
||||
// Increase heap size for screenshot tests
|
||||
maxHeapSize = "2g"
|
||||
// Record all the languages?
|
||||
@@ -165,9 +168,22 @@ allprojects {
|
||||
exclude("translations/*.class")
|
||||
}
|
||||
} else {
|
||||
// Robolectric and Compose pay a 5 to 30 seconds bootstrap cost per test JVM (instrumenting
|
||||
// android-all, then warming up the Compose runtime). That cost is paid once per JVM and then
|
||||
// amortised over every test class the JVM runs, so splitting a module across several forks
|
||||
// re-pays it for each fork instead of saving time. Keep a single fork per module and let
|
||||
// Gradle parallelise by running many modules' test tasks concurrently instead.
|
||||
maxParallelForks = 1
|
||||
|
||||
// Disable screenshot tests by default
|
||||
exclude("ui/*.class")
|
||||
exclude("translations/*.class")
|
||||
if (isRoborazziTest.not()) {
|
||||
// Roborazzi screenshot tests (:libraries:compound) live in a `screenshot` package, which
|
||||
// the two patterns above do not match, so they used to run on every plain unit test run.
|
||||
// They are verified by the dedicated `verifyRoborazziDebug` task instead.
|
||||
exclude("**/screenshot/**")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user