Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into zumegradle-rewrite
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle.kts
  • Loading branch information
rhysdh540 committed Nov 6, 2024
2 parents 3344803 + 0b44c68 commit 8e49298
Show file tree
Hide file tree
Showing 2 changed files with 310 additions and 73 deletions.
154 changes: 81 additions & 73 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import okhttp3.MultipartBody
import okhttp3.Request
import okhttp3.RequestBody.Companion.asRequestBody
import okhttp3.internal.immutableListOf
import okhttp3.internal.toHexString
import org.ajoberstar.grgit.Tag
import org.objectweb.asm.ClassReader
import org.objectweb.asm.ClassWriter
Expand All @@ -31,10 +30,7 @@ import java.io.FileOutputStream
import java.net.URI
import java.nio.file.Files
import java.time.ZonedDateTime
import kotlin.io.path.*
import kotlin.io.path.Path
import kotlin.io.path.deleteRecursively
import kotlin.io.path.exists
import kotlin.math.max

plugins {
id("java")
Expand Down Expand Up @@ -543,20 +539,86 @@ python {
pip("portablemc:${"portablemc_version"()}")
}

data class SmokeTestConfig(
val modLoader: String,
val mcVersion: String,
val loaderVersion: String? = null,
val jvmVersion: Int? = null,
val extraArgs: List<String>? = null,
val dependencies: List<Pair<String, String>>? = null,
) {
val versionString: String get() =
if (loaderVersion != null)
"${modLoader}:${mcVersion}:${loaderVersion}"
else
"${modLoader}:${mcVersion}"
val smokeTest = tasks.register("smokeTest") {
group = "verification"
dependsOn(tasks.checkPython, tasks.pipInstall, compressJar)

doFirst {
SmokeTest(
logger,
"${project.rootDir}/.gradle/python/bin/portablemc",
compressJar.get().outputJar.asFile.get(),
"${project.rootDir}/.gradle/portablemc",
"${project.layout.buildDirectory.get()}/smoke_test",
max(2, Runtime.getRuntime().availableProcessors() / 5),
TimeUnit.SECONDS.toNanos(60),
listOf(
SmokeTest.Config("fabric", "snapshot", dependencies = listOf(
"fabric-api" to "https://github.com/FabricMC/fabric/releases/download/0.107.0%2B1.21.4/fabric-api-0.107.0+1.21.4.jar",
)),
SmokeTest.Config("fabric", "release", dependencies = listOf(
"fabric-api" to "https://github.com/FabricMC/fabric/releases/download/0.107.0%2B1.21.3/fabric-api-0.107.0+1.21.3.jar",
"modmenu" to "https://github.com/TerraformersMC/ModMenu/releases/download/v11.0.3/modmenu-11.0.3.jar",
)),
SmokeTest.Config("fabric", "1.21.1", dependencies = listOf(
"fabric-api" to "https://github.com/FabricMC/fabric/releases/download/0.107.0%2B1.21.1/fabric-api-0.107.0+1.21.1.jar",
"modmenu" to "https://github.com/TerraformersMC/ModMenu/releases/download/v11.0.3/modmenu-11.0.3.jar",
)),
SmokeTest.Config("fabric", "1.20.6", dependencies = listOf(
"fabric-api" to "https://github.com/FabricMC/fabric/releases/download/0.100.8%2B1.20.6/fabric-api-0.100.8+1.20.6.jar",
"modmenu" to "https://github.com/TerraformersMC/ModMenu/releases/download/v10.0.0/modmenu-10.0.0.jar",
)),
SmokeTest.Config("fabric", "1.20.1", dependencies = listOf(
"fabric-api" to "https://github.com/FabricMC/fabric/releases/download/0.92.2%2B1.20.1/fabric-api-0.92.2+1.20.1.jar",
"modmenu" to "https://github.com/TerraformersMC/ModMenu/releases/download/v7.2.2/modmenu-7.2.2.jar",
)),
SmokeTest.Config("fabric", "1.18.2", dependencies = listOf(
"fabric-api" to "https://github.com/FabricMC/fabric/releases/download/0.77.0%2B1.18.2/fabric-api-0.77.0+1.18.2.jar",
"modmenu" to "https://github.com/TerraformersMC/ModMenu/releases/download/v3.2.5/modmenu-3.2.5.jar",
), extraArgs = listOf("--lwjgl=3.2.3")),
SmokeTest.Config("fabric", "1.16.5", dependencies = listOf(
"fabric-api" to "https://github.com/FabricMC/fabric/releases/download/0.42.0%2B1.16/fabric-api-0.42.0+1.16.jar",
"modmenu" to "https://github.com/TerraformersMC/ModMenu/releases/download/v1.16.23/modmenu-1.16.23.jar",
)),
SmokeTest.Config("fabric", "1.14.4", dependencies = listOf(
"fabric-api" to "https://github.com/FabricMC/fabric/releases/download/0.28.5%2B1.14/fabric-api-0.28.5+1.14.jar",
"modmenu" to "https://github.com/TerraformersMC/ModMenu/releases/download/v1.7.11/modmenu-1.7.11+build.121.jar",
)),
SmokeTest.Config("legacyfabric", "1.12.2", dependencies = listOf(
"legacy-fabric-api" to "https://github.com/Legacy-Fabric/fabric/releases/download/1.10.2/legacy-fabric-api-1.10.2.jar",
)),
SmokeTest.Config("legacyfabric", "1.8.9", dependencies = listOf(
"legacy-fabric-api" to "https://github.com/Legacy-Fabric/fabric/releases/download/1.10.2/legacy-fabric-api-1.10.2.jar",
)),
SmokeTest.Config("legacyfabric", "1.7.10", dependencies = listOf(
"legacy-fabric-api" to "https://github.com/Legacy-Fabric/fabric/releases/download/1.10.2/legacy-fabric-api-1.10.2.jar",
)),
// SmokeTest.Config("legacyfabric", "1.6.4", dependencies = listOf(
// "legacy-fabric-api" to "https://github.com/Legacy-Fabric/fabric/releases/download/1.10.2/legacy-fabric-api-1.10.2.jar",
// )),
SmokeTest.Config("babric", "b1.7.3", jvmVersion = 17, dependencies = listOf(
"station-api" to "https://cdn.modrinth.com/data/472oW63Q/versions/W3QVtn6S/StationAPI-2.0-alpha.2.4.jar",
), extraArgs = listOf("--exclude-lib=asm-all")),
SmokeTest.Config("neoforge", "release"),
SmokeTest.Config("neoforge", "1.21.1"),
SmokeTest.Config("neoforge", "1.20.4"),
SmokeTest.Config("forge", "1.20.4"),
SmokeTest.Config("forge", "1.20.1"),
SmokeTest.Config("forge", "1.19.2"),
SmokeTest.Config("forge", "1.18.2", extraArgs = listOf("--lwjgl=3.2.3")),
SmokeTest.Config("forge", "1.16.5", extraArgs = listOf("--lwjgl=3.2.3")),
SmokeTest.Config("forge", "1.14.4", dependencies = listOf(
"mixinbootstrap" to "https://github.com/LXGaming/MixinBootstrap/releases/download/v1.1.0/_MixinBootstrap-1.1.0.jar"
), extraArgs = listOf("--lwjgl=3.2.3")),
SmokeTest.Config("forge", "1.12.2", dependencies = listOf(
"mixinbooter" to "https://github.com/CleanroomMC/MixinBooter/releases/download/9.3/mixinbooter-9.3.jar"
)),
SmokeTest.Config("forge", "1.8.9", dependencies = listOf(
"mixinbooter" to "https://github.com/CleanroomMC/MixinBooter/releases/download/9.3/mixinbooter-9.3.jar"
)),
SmokeTest.Config("forge", "1.7.10", dependencies = listOf(
"unimixins" to "https://github.com/LegacyModdingMC/UniMixins/releases/download/0.1.19/+unimixins-all-1.7.10-0.1.19.jar"
)),
override fun toString(): String {
val result = StringBuilder()

Expand Down Expand Up @@ -691,61 +753,7 @@ val smokeTest = tasks.register("smokeTest") {
21 to "java-runtime-delta",
8 to "jre-legacy"
)
if (config.jvmVersion != null)
extraArgs.add("--jvm=${mainDir}/jvm/${jvmVersionMap[config.jvmVersion]}/bin/java")

if (config.extraArgs != null)
extraArgs.addAll(config.extraArgs)

val command = arrayOf(
"${project.rootDir}/.gradle/python/bin/portablemc",
"--main-dir", mainDir,
"--work-dir", workDir,
"start", config.versionString,
*extraArgs.toTypedArray(),
"--jvm-args=-DzumeGradle.auditAndExit=true",
)

ProcessBuilder(*command, "--dry")
.inheritIO()
.start()
.waitFor()

val process = ProcessBuilder(*command)
.inheritIO()
.start()

var passed = false

if (process.waitFor(30, TimeUnit.SECONDS)) {
file(latestLog).also { logFile ->
if (logFile.exists()) {
logFile.reader().use { reader ->
reader.forEachLine { line ->
if (line.endsWith("ZumeGradle audit passed"))
passed = true
}
}
}
}
} else {
process.destroy()
}

if (passed) {
logger.info("Smoke test passed for config:\n${config}")
} else {
logger.error("Smoke test failed for config:\n${config}")
failures.add(config)
}
}

if (failures.isNotEmpty()) {
logger.error("[{\n${failures.joinToString("}, {\n")}}]")
error("One or more tests failed. See logs for more details.")
}

logger.info("All tests passed.")
).test()
}
}
//endregion
Expand Down
Loading

0 comments on commit 8e49298

Please sign in to comment.