[gradle+deps] Adjust memory limit for test Gradle instances

This commit is contained in:
Him188 2022-11-24 14:03:47 +00:00
parent 5c4a3aeb38
commit 9540bc95c5
7 changed files with 26 additions and 14 deletions

View File

@ -129,4 +129,4 @@ jobs:
run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Porg.gradle.parallel=${{ matrix.parallelCompilation }}"
- name: Check Publication
run: ./gradlew :mirai-deps-test:check ${{ env.gradleArgs }} "-Dmirai.deps.test.must.run=true"
run: ./gradlew :mirai-deps-test:check ${{ env.gradleArgs }} "-Dmirai.deps.test.must.run=true" "-Porg.gradle.parallel=${{ matrix.parallelCompilation }}"

View File

@ -23,7 +23,7 @@ jobs:
env:
enableLocalPublishingTest: 'false'
# All targets MUST be enabled. See #2270.
gradleArgs: --scan "-Dmirai.target=other" "-Pkotlin.compiler.execution.strategy=in-process"
gradleArgs: --scan "-Dmirai.target=other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx4096m" "-Dfile.encoding=UTF-8"
isMac: ${{ startsWith(matrix.os, 'macos') }}
isWindows: ${{ startsWith(matrix.os, 'windows') }}
isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}

View File

@ -23,7 +23,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
object Versions {
val project = System.getenv("mirai.build.project.version")?.takeIf { it.isNotBlank() }
?: System.getProperty("mirai.build.project.version")?.takeIf { it.isNotBlank() }
?: /*PROJECT_VERSION_START*/"2.14.0-dev-shadow-6"/*PROJECT_VERSION_END*/
?: /*PROJECT_VERSION_START*/"2.14.0-dev-shadow-8"/*PROJECT_VERSION_END*/
// DO NOT ADD SPACE BETWEEN!
val core get() = project

View File

@ -38,11 +38,13 @@ abstract class AbstractTest {
.forwardOutput()
.withEnvironment(System.getenv())
.withArguments(buildList {
add("--no-daemon")
add("-Pkotlin.compiler.execution.strategy=in-process")
add("-Dorg.gradle.jvmargs=-Xmx256m")
add("-Dfile.encoding=UTF-8")
addAll(arguments)
add("-P")
add("kotlin.compiler.execution.strategy=in-process")
add("-D")
add("org.gradle.jvmargs=-Xmx512m")
add("-D")
add("file.encoding=UTF-8")
})
.build()
}

View File

@ -113,6 +113,7 @@ val publishMiraiLocalArtifacts = tasks.register("publishMiraiLocalArtifacts", Ex
"--scan",
"-Pkotlin.compiler.execution.strategy=in-process"
)
standardOutput = System.out
errorOutput = System.err
}

View File

@ -11,6 +11,7 @@ package net.mamoe.mirai.deps.test
import org.gradle.api.internal.artifacts.mvnsettings.DefaultMavenFileLocations
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.internal.DefaultGradleRunner
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.extension.AfterEachCallback
import org.junit.jupiter.api.extension.RegisterExtension
@ -89,6 +90,7 @@ abstract class AbstractTest {
lateinit var settingsFile: File
lateinit var propertiesFile: File
private inline fun <reified T> Any?.cast(): T = this as T
@OptIn(ExperimentalStdlibApi::class)
fun runGradle(vararg arguments: String) {
@ -99,13 +101,19 @@ abstract class AbstractTest {
.withGradleVersion("7.2")
.forwardOutput()
.withEnvironment(System.getenv())
.withArguments(buildList {
add("--no-daemon")
add("-Pkotlin.compiler.execution.strategy=in-process")
add("-Dorg.gradle.jvmargs=-Xmx512m")
.cast<DefaultGradleRunner>().withJvmArguments(buildList {
add("-Xmx512m") // Kotlin MPP may need memory to build
add("-Dfile.encoding=UTF-8")
add("--stacktrace")
})
.withArguments(buildList {
addAll(arguments)
add("-P")
add("kotlin.compiler.execution.strategy=in-process")
add("-D")
add("org.gradle.jvmargs=-Xmx512m")
add("-D")
add("file.encoding=UTF-8")
add("--stacktrace")
})
.build()
}

View File

@ -157,12 +157,13 @@ class CoreShadowRelocationTest : AbstractTest() {
// mirai-core-all-2.99.0-deps-test-all.jar
val miraiCoreAllJar =
mavenLocalDir.resolve("net/mamoe/mirai-core-all/$miraiLocalVersion/mirai-core-all-$miraiLocalVersion-all.jar")
assertTrue("'${miraiCoreAllJar.absolutePath}' does not exist") { miraiCoreAllJar.exists() }
val path = miraiCoreAllJar.absolutePath.replace("\\", "/") // overcome string escape in source files.
assertTrue("'$path' does not exist") { miraiCoreAllJar.exists() }
buildFile.appendText(
"""
dependencies {
implementation(fileTree("${miraiCoreAllJar.absolutePath}"))
implementation(fileTree("$path"))
}
""".trimIndent()
)