From da4a77810915f5e191f45c3e25173ee05e1781e3 Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 31 Mar 2023 15:58:05 +0800 Subject: [PATCH 1/3] Execute tests in parallel https://docs.gradle.org/7.6/userguide/performance.html#execute_tests_in_parallel --- .../kotlin/org/jetbrains/conventions/base-java.gradle.kts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts index cff7eb3ebe..7423a34ed2 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts +++ b/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts @@ -22,6 +22,12 @@ java { tasks.withType().configureEach { useJUnitPlatform() + maxParallelForks = if (System.getenv("CI") != null) { + Runtime.getRuntime().availableProcessors() + } else { + (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1 + } + javaLauncher.set(javaToolchains.launcherFor { languageVersion.set(dokkaBuild.testJavaLauncherVersion) }) From 5facf7eee5f29f672345b1cae95d1fc98b9ad388 Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 31 Mar 2023 16:27:19 +0800 Subject: [PATCH 2/3] Use all cores on GHA runners but the half on others --- .../kotlin/org/jetbrains/conventions/base-java.gradle.kts | 2 +- .../jetbrains/conventions/dokka-integration-test.gradle.kts | 6 ++++-- gradle.properties | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts index 7423a34ed2..c5b90e812f 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts +++ b/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts @@ -22,7 +22,7 @@ java { tasks.withType().configureEach { useJUnitPlatform() - maxParallelForks = if (System.getenv("CI") != null) { + maxParallelForks = if (System.getenv("GITHUB_ACTIONS") != null) { Runtime.getRuntime().availableProcessors() } else { (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1 diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts index f9edb68e8e..f29dd3c79e 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts +++ b/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts @@ -51,8 +51,10 @@ val integrationTest by tasks.registering(NonCacheableIntegrationTest::class) { classpath = integrationTestSourceSet.runtimeClasspath setForkEvery(1) - project.properties["dokka_integration_test_parallelism"]?.toString()?.toIntOrNull()?.let { parallelism -> - maxParallelForks = parallelism + maxParallelForks = if (System.getenv("GITHUB_ACTIONS") != null) { + Runtime.getRuntime().availableProcessors() + } else { + (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1 } environment( "isExhaustive", diff --git a/gradle.properties b/gradle.properties index 2fe431fd7e..044817d8fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,6 @@ dokka_version=1.8.20-SNAPSHOT org.jetbrains.dokka.javaToolchain.mainCompiler=8 org.jetbrains.dokka.javaToolchain.testLauncher=8 org.jetbrains.dokka.kotlinLanguageLevel=1.4 -dokka_integration_test_parallelism=2 # Code style kotlin.code.style=official From c9f4aed18df0465a4e9e89669c31d52ed97f6ff8 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 26 Apr 2023 18:33:37 +0800 Subject: [PATCH 3/3] Revert changes for integration tests --- .../jetbrains/conventions/dokka-integration-test.gradle.kts | 6 ++---- gradle.properties | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts index f29dd3c79e..f9edb68e8e 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts +++ b/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts @@ -51,10 +51,8 @@ val integrationTest by tasks.registering(NonCacheableIntegrationTest::class) { classpath = integrationTestSourceSet.runtimeClasspath setForkEvery(1) - maxParallelForks = if (System.getenv("GITHUB_ACTIONS") != null) { - Runtime.getRuntime().availableProcessors() - } else { - (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1 + project.properties["dokka_integration_test_parallelism"]?.toString()?.toIntOrNull()?.let { parallelism -> + maxParallelForks = parallelism } environment( "isExhaustive", diff --git a/gradle.properties b/gradle.properties index 044817d8fb..2fe431fd7e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,7 @@ dokka_version=1.8.20-SNAPSHOT org.jetbrains.dokka.javaToolchain.mainCompiler=8 org.jetbrains.dokka.javaToolchain.testLauncher=8 org.jetbrains.dokka.kotlinLanguageLevel=1.4 +dokka_integration_test_parallelism=2 # Code style kotlin.code.style=official