From cefc61a7d6092a2a895cc0a35fcab2650814391c Mon Sep 17 00:00:00 2001 From: IThundxr Date: Mon, 21 Oct 2024 15:47:29 -0400 Subject: [PATCH 01/18] Automated testing --- .github/workflows/build.yml | 121 +++++++++++------- .../gradle/subproject/SubprojectPlugin.kt | 26 ++++ fabric/build.gradle.kts | 4 + .../flywheel/FlywheelTestModClient.java | 22 ++++ fabric/src/testmod/resources/fabric.mod.json | 13 ++ forge/build.gradle.kts | 4 + .../flywheel/FlywheelTestModClient.java | 30 +++++ .../src/testmod/resources/META-INF/mods.toml | 8 ++ 8 files changed, 185 insertions(+), 43 deletions(-) create mode 100644 fabric/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java create mode 100644 fabric/src/testmod/resources/fabric.mod.json create mode 100644 forge/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java create mode 100644 forge/src/testmod/resources/META-INF/mods.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd1169eae..05578a5a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,47 +1,82 @@ -name: build +name: Build on: [ pull_request, push ] jobs: - build: - strategy: - matrix: - java: [ - 17 # Current Java LTS & minimum supported by Minecraft - ] - os: [ ubuntu-latest ] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Validate Gradle Wrapper - uses: gradle/actions/wrapper-validation@v3 - - name: Gradle Cache - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - .gradle/loom-cache - build/ - key: ${{ runner.os }}-jdk${{ matrix.java }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle.properties', '**/gradle-wrapper.properties', '.github/workflows/build.yml') }} - - name: Setup JDK ${{ matrix.java }} - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: ${{ matrix.java }} - - name: Make Gradle Wrapper Executable - if: ${{ runner.os != 'Windows' }} - run: chmod +x ./gradlew - - name: Build - # doesn't actually publish, as no secrets are passed in, just makes sure that publishing works - run: ./gradlew publish --no-daemon - - name: Capture Build Artifacts - if: ${{ runner.os == 'Linux' && matrix.java == '17' }} - uses: actions/upload-artifact@v4 - with: - name: Artifacts - path: | - common/build/libs/ - fabric/build/libs/ - forge/build/libs/ + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Java + run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV" + + - name: Loom Cache + uses: actions/cache@v4 + with: + path: "**/.gradle/loom-cache" + key: "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}" + restore-keys: "${{ runner.os }}-gradle-" + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true + cache-read-only: ${{ !endsWith(github.ref_name, '/dev') }} + + - name: Validate Gradle Wrapper Integrity + uses: gradle/wrapper-validation-action@v2 + + - name: Build + # doesn't actually publish, as no secrets are passed in, just makes sure that publishing works + run: ./gradlew :forge:remapTestmodJar :fabric:remapTestmodJar publish --no-daemon + + - name: Capture Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: Artifacts + path: | + common/build/libs/ + fabric/build/libs/ + fabric/build/devlibs/ + forge/build/libs/ + forge/build/devlibs/ + + test: + strategy: + matrix: + loader: [ forge, fabric ] + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: Artifacts + + - name: Setup Environment Variables + run: | + echo "MOD_VERSION=$(grep '^mod_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV" + echo "MINECRAFT_VERSION=$(grep '^minecraft_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV" + echo "FABRIC_API_VERSION=$(grep '^fabric_api_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ' | sed 's/+.*//')" >> "$GITHUB_ENV" + + - name: Move Test Mod and Flywheel into run/mods + run: | + mkdir -p run/mods + cp ${{ matrix.loader }}/build/libs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}.jar run/mods + cp ${{ matrix.loader }}/build/devlibs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}-testmod.jar run/mods + + # Lock to a specific commit, it would be bad if the tag is re-pushed with unwanted changes + - name: Run the MC client + uses: 3arthqu4ke/mc-runtime-test@e72f8fe1134aabf6fc749a2a8c09bb56dd7d283e + with: + mc: ${{ env.MINECRAFT_VERSION }} + modloader: ${{ matrix.loader }} + regex: .*${{ matrix.loader }}.* + mc-runtime-test: none + java: 17 + fabric-api: ${{ matrix.loader == 'fabric' && env.FABRIC_API_VERSION || 'none' }} diff --git a/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt b/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt index 6c3230f0d..e982ea04d 100644 --- a/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt +++ b/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt @@ -4,6 +4,7 @@ import dev.engine_room.gradle.jarset.JarSetExtension import dev.engine_room.gradle.nullability.PackageInfosExtension import dev.engine_room.gradle.transitive.TransitiveSourceSetsExtension import net.fabricmc.loom.api.LoomGradleExtensionAPI +import net.fabricmc.loom.task.RemapJarTask import org.gradle.api.JavaVersion import org.gradle.api.Plugin import org.gradle.api.Project @@ -11,6 +12,7 @@ import org.gradle.api.plugins.BasePluginExtension import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.tasks.GenerateModuleMetadata +import org.gradle.api.tasks.SourceSetContainer import org.gradle.api.tasks.bundling.AbstractArchiveTask import org.gradle.api.tasks.compile.JavaCompile import org.gradle.api.tasks.javadoc.Javadoc @@ -18,6 +20,7 @@ import org.gradle.jvm.tasks.Jar import org.gradle.jvm.toolchain.JavaLanguageVersion import org.gradle.kotlin.dsl.* import org.gradle.language.jvm.tasks.ProcessResources +import java.io.File class SubprojectPlugin: Plugin { override fun apply(project: Project) { @@ -32,6 +35,9 @@ class SubprojectPlugin: Plugin { setupDependencies(project) configureTasks(project) setupPublishing(project) + + if (project.path != ":common") + setupTestMod(project) } private fun setBaseProperties(project: Project) { @@ -164,6 +170,26 @@ class SubprojectPlugin: Plugin { } } } + + private fun setupTestMod(project: Project) { + val sourceSets = project.extensions.getByName("sourceSets") as SourceSetContainer + + val testmodJar = project.tasks.register("testmodJar") { + from (sourceSets["testmod"].output) + val file = File(project.layout.buildDirectory.asFile.get(), "devlibs"); + destinationDirectory.set(file) + archiveClassifier = "testmod" + } + + val remapTestmodJar = project.tasks.register("remapTestmodJar") { + dependsOn(testmodJar) + inputFile.set(testmodJar.get().archiveFile) + archiveClassifier = "testmod" + addNestedDependencies = false + classpath.from(sourceSets["testmod"].compileClasspath) + } + project.tasks["build"].dependsOn(remapTestmodJar) + } } val processResourcesExpandFiles = listOf("pack.mcmeta", "fabric.mod.json", "META-INF/mods.toml") diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 865773be5..9922f335e 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -12,6 +12,10 @@ val lib = sourceSets.create("lib") val backend = sourceSets.create("backend") val stubs = sourceSets.create("stubs") val main = sourceSets.getByName("main") +val testmod = sourceSets.create("testmod") { + compileClasspath += main.compileClasspath + runtimeClasspath += main.runtimeClasspath +} transitiveSourceSets { compileClasspath = main.compileClasspath diff --git a/fabric/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/fabric/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java new file mode 100644 index 000000000..070fa1c16 --- /dev/null +++ b/fabric/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -0,0 +1,22 @@ +package dev.engine_room.flywheel; + +import org.spongepowered.asm.mixin.MixinEnvironment; + +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; + +public class FlywheelTestModClient implements ClientModInitializer { + private int ticks = 0; + + @Override + public void onInitializeClient() { + if (Boolean.getBoolean("flywheel.autoTest")) { + ClientTickEvents.END_CLIENT_TICK.register(client -> { + if (++ticks == 50) { + MixinEnvironment.getCurrentEnvironment().audit(); + client.stop(); + } + }); + } + } +} diff --git a/fabric/src/testmod/resources/fabric.mod.json b/fabric/src/testmod/resources/fabric.mod.json new file mode 100644 index 000000000..e7059786b --- /dev/null +++ b/fabric/src/testmod/resources/fabric.mod.json @@ -0,0 +1,13 @@ +{ + "schemaVersion": 1, + "id": "${mod_id}-testmod", + "name": "${mod_name} Test Mod", + "version": "1.0.0", + "environment": "*", + "license": "${mod_license}", + "entrypoints": { + "client": [ + "dev.engine_room.flywheel.FlywheelTestModClient" + ] + } +} diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index d1c6b3617..06e4a2619 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -12,6 +12,10 @@ val lib = sourceSets.create("lib") val backend = sourceSets.create("backend") val stubs = sourceSets.create("stubs") val main = sourceSets.getByName("main") +val testmod = sourceSets.create("testmod") { + compileClasspath += main.compileClasspath + runtimeClasspath += main.runtimeClasspath +} transitiveSourceSets { compileClasspath = main.compileClasspath diff --git a/forge/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/forge/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java new file mode 100644 index 000000000..cb2b9513f --- /dev/null +++ b/forge/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -0,0 +1,30 @@ +package dev.engine_room.flywheel; + +import org.spongepowered.asm.mixin.MixinEnvironment; + +import net.minecraft.client.Minecraft; +import net.minecraftforge.event.TickEvent; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + +@Mod("flywheel-testmod") +public class FlywheelTestModClient { + private int ticks = 0; + + public FlywheelTestModClient() { + if (Boolean.getBoolean("flywheel.autoTest")) { + IEventBus modEventBus = FMLJavaModLoadingContext.get() + .getModEventBus(); + + modEventBus.addListener((TickEvent.ClientTickEvent e) -> { + if (e.phase == TickEvent.Phase.END) { + if (++ticks == 50) { + MixinEnvironment.getCurrentEnvironment().audit(); + Minecraft.getInstance().stop(); + } + } + }); + } + } +} diff --git a/forge/src/testmod/resources/META-INF/mods.toml b/forge/src/testmod/resources/META-INF/mods.toml new file mode 100644 index 000000000..52d518889 --- /dev/null +++ b/forge/src/testmod/resources/META-INF/mods.toml @@ -0,0 +1,8 @@ +modLoader = "javafml" +loaderVersion = "[0,)" +license = "${mod_license}" + +[[mods]] +modId = "${mod_id}-testmod" +version = "1.0.0" +displayName = "${mod_name} Test Mod" From 491d134edff85c58cdfc6a790c5dc02759a8b5cd Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 21 Oct 2024 23:03:03 -0700 Subject: [PATCH 02/18] Testing testing - Use 2 spaces for indents yaml - Move setupTestMod to PlatformExtension - Allow specifying the sourceSet for the testMod artifact - Rename things to camelCase - Use rootCompile from transitiveSourceSets for the testMod source sets - Use a blanket remapTestModJar task in the gh actions build --- .editorconfig | 3 + .github/workflows/build.yml | 133 +++++++++--------- .../gradle/platform/PlatformExtension.kt | 31 +++- .../gradle/subproject/SubprojectPlugin.kt | 26 ---- fabric/build.gradle.kts | 9 +- .../flywheel/FlywheelTestModClient.java | 0 .../resources/fabric.mod.json | 0 forge/build.gradle.kts | 9 +- .../flywheel/FlywheelTestModClient.java | 0 .../resources/META-INF/mods.toml | 0 10 files changed, 107 insertions(+), 104 deletions(-) rename fabric/src/{testmod => testMod}/java/dev/engine_room/flywheel/FlywheelTestModClient.java (100%) rename fabric/src/{testmod => testMod}/resources/fabric.mod.json (100%) rename forge/src/{testmod => testMod}/java/dev/engine_room/flywheel/FlywheelTestModClient.java (100%) rename forge/src/{testmod => testMod}/resources/META-INF/mods.toml (100%) diff --git a/.editorconfig b/.editorconfig index 038bc765e..294e122e9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,6 +9,9 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true +[*.yml] +indent_size = 2 + [*.json] indent_size = 2 max_line_length = 500 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05578a5a3..855592727 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,80 +3,81 @@ name: Build on: [ pull_request, push ] jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 - - name: Setup Java - run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV" + - name: Setup Java + run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV" - - name: Loom Cache - uses: actions/cache@v4 - with: - path: "**/.gradle/loom-cache" - key: "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}" - restore-keys: "${{ runner.os }}-gradle-" + - name: Loom Cache + uses: actions/cache@v4 + with: + path: "**/.gradle/loom-cache" + key: "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}" + restore-keys: "${{ runner.os }}-gradle-" - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - with: - gradle-home-cache-cleanup: true - cache-read-only: ${{ !endsWith(github.ref_name, '/dev') }} + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true + cache-read-only: ${{ !endsWith(github.ref_name, '/dev') }} - - name: Validate Gradle Wrapper Integrity - uses: gradle/wrapper-validation-action@v2 + - name: Validate Gradle Wrapper Integrity + uses: gradle/wrapper-validation-action@v2 - - name: Build - # doesn't actually publish, as no secrets are passed in, just makes sure that publishing works - run: ./gradlew :forge:remapTestmodJar :fabric:remapTestmodJar publish --no-daemon + - name: Build + # Doesn't actually publish, as no secrets are passed in, just makes sure that publishing works + # Also generate the mod jars for the test job + run: ./gradlew remapTestModJar publish --no-daemon - - name: Capture Build Artifacts - uses: actions/upload-artifact@v4 - with: - name: Artifacts - path: | - common/build/libs/ - fabric/build/libs/ - fabric/build/devlibs/ - forge/build/libs/ - forge/build/devlibs/ + - name: Capture Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: Artifacts + path: | + common/build/libs/ + fabric/build/libs/ + fabric/build/devlibs/ + forge/build/libs/ + forge/build/devlibs/ - test: - strategy: - matrix: - loader: [ forge, fabric ] - needs: build - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 + test: + strategy: + matrix: + loader: [ forge, fabric ] + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 - - name: Download build artifact - uses: actions/download-artifact@v4 - with: - name: Artifacts + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: Artifacts - - name: Setup Environment Variables - run: | - echo "MOD_VERSION=$(grep '^mod_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV" - echo "MINECRAFT_VERSION=$(grep '^minecraft_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV" - echo "FABRIC_API_VERSION=$(grep '^fabric_api_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ' | sed 's/+.*//')" >> "$GITHUB_ENV" + - name: Setup Environment Variables + run: | + echo "MOD_VERSION=$(grep '^mod_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV" + echo "MINECRAFT_VERSION=$(grep '^minecraft_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV" + echo "FABRIC_API_VERSION=$(grep '^fabric_api_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ' | sed 's/+.*//')" >> "$GITHUB_ENV" - - name: Move Test Mod and Flywheel into run/mods - run: | - mkdir -p run/mods - cp ${{ matrix.loader }}/build/libs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}.jar run/mods - cp ${{ matrix.loader }}/build/devlibs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}-testmod.jar run/mods + - name: Move Test Mod and Flywheel into run/mods + run: | + mkdir -p run/mods + cp ${{ matrix.loader }}/build/libs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}.jar run/mods + cp ${{ matrix.loader }}/build/devlibs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}-testmod.jar run/mods - # Lock to a specific commit, it would be bad if the tag is re-pushed with unwanted changes - - name: Run the MC client - uses: 3arthqu4ke/mc-runtime-test@e72f8fe1134aabf6fc749a2a8c09bb56dd7d283e - with: - mc: ${{ env.MINECRAFT_VERSION }} - modloader: ${{ matrix.loader }} - regex: .*${{ matrix.loader }}.* - mc-runtime-test: none - java: 17 - fabric-api: ${{ matrix.loader == 'fabric' && env.FABRIC_API_VERSION || 'none' }} + # Lock to a specific commit, it would be bad if the tag is re-pushed with unwanted changes + - name: Run the MC client + uses: 3arthqu4ke/mc-runtime-test@e72f8fe1134aabf6fc749a2a8c09bb56dd7d283e + with: + mc: ${{ env.MINECRAFT_VERSION }} + modloader: ${{ matrix.loader }} + regex: .*${{ matrix.loader }}.* + mc-runtime-test: none + java: 17 + fabric-api: ${{ matrix.loader == 'fabric' && env.FABRIC_API_VERSION || 'none' }} diff --git a/buildSrc/src/main/kotlin/dev/engine_room/gradle/platform/PlatformExtension.kt b/buildSrc/src/main/kotlin/dev/engine_room/gradle/platform/PlatformExtension.kt index 66831cedf..2addef1dc 100644 --- a/buildSrc/src/main/kotlin/dev/engine_room/gradle/platform/PlatformExtension.kt +++ b/buildSrc/src/main/kotlin/dev/engine_room/gradle/platform/PlatformExtension.kt @@ -2,17 +2,17 @@ package dev.engine_room.gradle.platform import dev.engine_room.gradle.jarset.JarTaskSet import net.fabricmc.loom.api.LoomGradleExtensionAPI +import net.fabricmc.loom.task.RemapJarTask import org.gradle.api.Project +import org.gradle.api.Task import org.gradle.api.tasks.SourceSet import org.gradle.api.tasks.SourceSetContainer import org.gradle.api.tasks.compile.JavaCompile import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.jvm.tasks.Jar -import org.gradle.kotlin.dsl.named -import org.gradle.kotlin.dsl.provideDelegate -import org.gradle.kotlin.dsl.the -import org.gradle.kotlin.dsl.withType +import org.gradle.kotlin.dsl.* import org.gradle.language.jvm.tasks.ProcessResources +import java.io.File import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty @@ -102,6 +102,29 @@ open class PlatformExtension(val project: Project) { } } + fun setupTestMod(sourceSet: SourceSet) { + project.tasks.apply { + val testModJar = register("testModJar") { + from(sourceSet.output) + val file = File(project.layout.buildDirectory.asFile.get(), "devlibs"); + destinationDirectory.set(file) + archiveClassifier = "testmod" + } + + val remapTestModJar = register("remapTestModJar") { + dependsOn(testModJar) + inputFile.set(testModJar.get().archiveFile) + archiveClassifier = "testmod" + addNestedDependencies = false + classpath.from(sourceSet.compileClasspath) + } + + named("build").configure { + dependsOn(remapTestModJar) + } + } + } + private class DependentProject(private val thisProject: Project) : ReadWriteProperty { private var value: Project? = null diff --git a/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt b/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt index e982ea04d..6c3230f0d 100644 --- a/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt +++ b/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt @@ -4,7 +4,6 @@ import dev.engine_room.gradle.jarset.JarSetExtension import dev.engine_room.gradle.nullability.PackageInfosExtension import dev.engine_room.gradle.transitive.TransitiveSourceSetsExtension import net.fabricmc.loom.api.LoomGradleExtensionAPI -import net.fabricmc.loom.task.RemapJarTask import org.gradle.api.JavaVersion import org.gradle.api.Plugin import org.gradle.api.Project @@ -12,7 +11,6 @@ import org.gradle.api.plugins.BasePluginExtension import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.tasks.GenerateModuleMetadata -import org.gradle.api.tasks.SourceSetContainer import org.gradle.api.tasks.bundling.AbstractArchiveTask import org.gradle.api.tasks.compile.JavaCompile import org.gradle.api.tasks.javadoc.Javadoc @@ -20,7 +18,6 @@ import org.gradle.jvm.tasks.Jar import org.gradle.jvm.toolchain.JavaLanguageVersion import org.gradle.kotlin.dsl.* import org.gradle.language.jvm.tasks.ProcessResources -import java.io.File class SubprojectPlugin: Plugin { override fun apply(project: Project) { @@ -35,9 +32,6 @@ class SubprojectPlugin: Plugin { setupDependencies(project) configureTasks(project) setupPublishing(project) - - if (project.path != ":common") - setupTestMod(project) } private fun setBaseProperties(project: Project) { @@ -170,26 +164,6 @@ class SubprojectPlugin: Plugin { } } } - - private fun setupTestMod(project: Project) { - val sourceSets = project.extensions.getByName("sourceSets") as SourceSetContainer - - val testmodJar = project.tasks.register("testmodJar") { - from (sourceSets["testmod"].output) - val file = File(project.layout.buildDirectory.asFile.get(), "devlibs"); - destinationDirectory.set(file) - archiveClassifier = "testmod" - } - - val remapTestmodJar = project.tasks.register("remapTestmodJar") { - dependsOn(testmodJar) - inputFile.set(testmodJar.get().archiveFile) - archiveClassifier = "testmod" - addNestedDependencies = false - classpath.from(sourceSets["testmod"].compileClasspath) - } - project.tasks["build"].dependsOn(remapTestmodJar) - } } val processResourcesExpandFiles = listOf("pack.mcmeta", "fabric.mod.json", "META-INF/mods.toml") diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 9922f335e..b1b04dad8 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -12,10 +12,7 @@ val lib = sourceSets.create("lib") val backend = sourceSets.create("backend") val stubs = sourceSets.create("stubs") val main = sourceSets.getByName("main") -val testmod = sourceSets.create("testmod") { - compileClasspath += main.compileClasspath - runtimeClasspath += main.runtimeClasspath -} +val testMod = sourceSets.create("testMod") transitiveSourceSets { compileClasspath = main.compileClasspath @@ -39,6 +36,9 @@ transitiveSourceSets { compile(stubs) implementation(api, lib, backend) } + sourceSet(testMod) { + rootCompile() + } createCompileConfigurations() } @@ -49,6 +49,7 @@ platform { setupLoomMod(api, lib, backend, main) setupLoomRuns() setupFatJar(api, lib, backend, main) + setupTestMod(testMod) } jarSets { diff --git a/fabric/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java similarity index 100% rename from fabric/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java rename to fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java diff --git a/fabric/src/testmod/resources/fabric.mod.json b/fabric/src/testMod/resources/fabric.mod.json similarity index 100% rename from fabric/src/testmod/resources/fabric.mod.json rename to fabric/src/testMod/resources/fabric.mod.json diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 06e4a2619..6900fd197 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -12,10 +12,7 @@ val lib = sourceSets.create("lib") val backend = sourceSets.create("backend") val stubs = sourceSets.create("stubs") val main = sourceSets.getByName("main") -val testmod = sourceSets.create("testmod") { - compileClasspath += main.compileClasspath - runtimeClasspath += main.runtimeClasspath -} +val testMod = sourceSets.create("testMod") transitiveSourceSets { compileClasspath = main.compileClasspath @@ -37,6 +34,9 @@ transitiveSourceSets { sourceSet(main) { compile(api, lib, backend, stubs) } + sourceSet(testMod) { + rootCompile() + } createCompileConfigurations() } @@ -47,6 +47,7 @@ platform { setupLoomMod(api, lib, backend, main) setupLoomRuns() setupFatJar(api, lib, backend, main) + setupTestMod(testMod) } jarSets { diff --git a/forge/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java similarity index 100% rename from forge/src/testmod/java/dev/engine_room/flywheel/FlywheelTestModClient.java rename to forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java diff --git a/forge/src/testmod/resources/META-INF/mods.toml b/forge/src/testMod/resources/META-INF/mods.toml similarity index 100% rename from forge/src/testmod/resources/META-INF/mods.toml rename to forge/src/testMod/resources/META-INF/mods.toml From 1220bcfce76675db26ec64fc3231f3e59ef5a5af Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 21 Oct 2024 23:09:57 -0700 Subject: [PATCH 03/18] Fail slowly - We want to know the results of both tests regardless --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 855592727..6dce8be05 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,6 +46,7 @@ jobs: test: strategy: + fail-fast: false matrix: loader: [ forge, fabric ] needs: build From 7ec7e2f7376d3ec88fb5b6e697cfd270fe07ee04 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Tue, 22 Oct 2024 06:56:20 -0400 Subject: [PATCH 04/18] Add workflow dispatch --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6dce8be05..4927f8ed0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,6 @@ name: Build -on: [ pull_request, push ] +on: [ workflow_dispatch, pull_request, push ] jobs: build: From 0545ea1d63d70c53bb0eafcf0b6991e217fdbb79 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Tue, 22 Oct 2024 10:18:55 -0400 Subject: [PATCH 05/18] Shoes should be steel toed, dangerous stuff --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4927f8ed0..ec24e373b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,3 +82,5 @@ jobs: mc-runtime-test: none java: 17 fabric-api: ${{ matrix.loader == 'fabric' && env.FABRIC_API_VERSION || 'none' }} + xvfb: false + headlessmc-command: -lwjgl --jvm -Djava.awt.headless=true From 23a1e3ee01e449e4b997f0b40515b90e8ab1200c Mon Sep 17 00:00:00 2001 From: IThundxr Date: Tue, 22 Oct 2024 13:12:41 -0400 Subject: [PATCH 06/18] Update build.yml --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec24e373b..4927f8ed0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,5 +82,3 @@ jobs: mc-runtime-test: none java: 17 fabric-api: ${{ matrix.loader == 'fabric' && env.FABRIC_API_VERSION || 'none' }} - xvfb: false - headlessmc-command: -lwjgl --jvm -Djava.awt.headless=true From 502d487b7506ceb7b77cc712428223d271b52ce6 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Tue, 22 Oct 2024 15:48:30 -0400 Subject: [PATCH 07/18] fix modid --- forge/src/testMod/resources/META-INF/mods.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge/src/testMod/resources/META-INF/mods.toml b/forge/src/testMod/resources/META-INF/mods.toml index 52d518889..4d76a503e 100644 --- a/forge/src/testMod/resources/META-INF/mods.toml +++ b/forge/src/testMod/resources/META-INF/mods.toml @@ -3,6 +3,6 @@ loaderVersion = "[0,)" license = "${mod_license}" [[mods]] -modId = "${mod_id}-testmod" +modId = "${mod_id}_testmod" version = "1.0.0" displayName = "${mod_name} Test Mod" From 61847a73fbd41ecac1dbb57bb825efe8e2c1cda5 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Tue, 22 Oct 2024 22:47:55 -0400 Subject: [PATCH 08/18] Update FlywheelTestModClient.java --- .../java/dev/engine_room/flywheel/FlywheelTestModClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java index cb2b9513f..f1992d60d 100644 --- a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java +++ b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -8,7 +8,7 @@ import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -@Mod("flywheel-testmod") +@Mod("flywheel_testmod") public class FlywheelTestModClient { private int ticks = 0; From d917a87a2eb58ff4432d1be0bafa1626987004d2 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 23 Oct 2024 10:34:59 -0400 Subject: [PATCH 09/18] add debug logging --- .../dev/engine_room/flywheel/FlywheelTestModClient.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java index f1992d60d..302330f9c 100644 --- a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java +++ b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -13,12 +13,17 @@ public class FlywheelTestModClient { private int ticks = 0; public FlywheelTestModClient() { + log("Loading test mod") + if (Boolean.getBoolean("flywheel.autoTest")) { + log("running autotest") + IEventBus modEventBus = FMLJavaModLoadingContext.get() .getModEventBus(); modEventBus.addListener((TickEvent.ClientTickEvent e) -> { if (e.phase == TickEvent.Phase.END) { + log("current ticks" + ticks) if (++ticks == 50) { MixinEnvironment.getCurrentEnvironment().audit(); Minecraft.getInstance().stop(); @@ -27,4 +32,8 @@ public class FlywheelTestModClient { }); } } + + public static void log(String s) { + System.out.println("[Flywheel Test Mod] " + s) + } } From 3544e49be64b114d642732fd5484bfafe1e0c7d6 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 23 Oct 2024 10:39:19 -0400 Subject: [PATCH 10/18] fix syntax issues --- .../dev/engine_room/flywheel/FlywheelTestModClient.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java index 302330f9c..685d1e910 100644 --- a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java +++ b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -13,17 +13,17 @@ public class FlywheelTestModClient { private int ticks = 0; public FlywheelTestModClient() { - log("Loading test mod") + log("Loading test mod"); if (Boolean.getBoolean("flywheel.autoTest")) { - log("running autotest") + log("running autotest"); IEventBus modEventBus = FMLJavaModLoadingContext.get() .getModEventBus(); modEventBus.addListener((TickEvent.ClientTickEvent e) -> { if (e.phase == TickEvent.Phase.END) { - log("current ticks" + ticks) + log("current ticks" + ticks); if (++ticks == 50) { MixinEnvironment.getCurrentEnvironment().audit(); Minecraft.getInstance().stop(); @@ -34,6 +34,6 @@ public class FlywheelTestModClient { } public static void log(String s) { - System.out.println("[Flywheel Test Mod] " + s) + System.out.println("[Flywheel Test Mod] " + s); } } From 6383cebda9a3f4ec0617dcc873c4f88ba1814930 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 23 Oct 2024 10:42:43 -0400 Subject: [PATCH 11/18] fix issues --- .github/workflows/build.yml | 8 ++++++-- .../engine_room/flywheel/FlywheelTestModClient.java | 2 +- .../engine_room/flywheel/FlywheelTestModClient.java | 10 +--------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4927f8ed0..2e106b297 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,12 +5,14 @@ on: [ workflow_dispatch, pull_request, push ] jobs: build: runs-on: ubuntu-latest + env: + JAVA_VERSION: 17 steps: - name: Checkout Repository uses: actions/checkout@v4 - name: Setup Java - run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV" + run: echo "JAVA_HOME=$JAVA_HOME_${{ env.JAVA_VERSION }}_X64" >> "$GITHUB_ENV" - name: Loom Cache uses: actions/cache@v4 @@ -75,10 +77,12 @@ jobs: # Lock to a specific commit, it would be bad if the tag is re-pushed with unwanted changes - name: Run the MC client uses: 3arthqu4ke/mc-runtime-test@e72f8fe1134aabf6fc749a2a8c09bb56dd7d283e + env: + FLYWHEEL_AUTO_TEST: true with: mc: ${{ env.MINECRAFT_VERSION }} modloader: ${{ matrix.loader }} regex: .*${{ matrix.loader }}.* mc-runtime-test: none - java: 17 + java: ${{ env.JAVA_VERSION }} fabric-api: ${{ matrix.loader == 'fabric' && env.FABRIC_API_VERSION || 'none' }} diff --git a/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java index 070fa1c16..8e192acbf 100644 --- a/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java +++ b/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -10,7 +10,7 @@ public class FlywheelTestModClient implements ClientModInitializer { @Override public void onInitializeClient() { - if (Boolean.getBoolean("flywheel.autoTest")) { + if (Boolean.parseBoolean(System.getProperty("FLYWHEEL_AUTO_TEST"))) { ClientTickEvents.END_CLIENT_TICK.register(client -> { if (++ticks == 50) { MixinEnvironment.getCurrentEnvironment().audit(); diff --git a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java index 685d1e910..d9c727aa9 100644 --- a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java +++ b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -13,17 +13,13 @@ public class FlywheelTestModClient { private int ticks = 0; public FlywheelTestModClient() { - log("Loading test mod"); - - if (Boolean.getBoolean("flywheel.autoTest")) { - log("running autotest"); + if (Boolean.parseBoolean(System.getProperty("FLYWHEEL_AUTO_TEST"))) { IEventBus modEventBus = FMLJavaModLoadingContext.get() .getModEventBus(); modEventBus.addListener((TickEvent.ClientTickEvent e) -> { if (e.phase == TickEvent.Phase.END) { - log("current ticks" + ticks); if (++ticks == 50) { MixinEnvironment.getCurrentEnvironment().audit(); Minecraft.getInstance().stop(); @@ -32,8 +28,4 @@ public class FlywheelTestModClient { }); } } - - public static void log(String s) { - System.out.println("[Flywheel Test Mod] " + s); - } } From fd31f42c9083252fd59c825640da1fe396c9e0a0 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 23 Oct 2024 10:53:41 -0400 Subject: [PATCH 12/18] Update build.yml --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e106b297..ea0e1bb70 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,14 +5,12 @@ on: [ workflow_dispatch, pull_request, push ] jobs: build: runs-on: ubuntu-latest - env: - JAVA_VERSION: 17 steps: - name: Checkout Repository uses: actions/checkout@v4 - name: Setup Java - run: echo "JAVA_HOME=$JAVA_HOME_${{ env.JAVA_VERSION }}_X64" >> "$GITHUB_ENV" + run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV" - name: Loom Cache uses: actions/cache@v4 @@ -84,5 +82,5 @@ jobs: modloader: ${{ matrix.loader }} regex: .*${{ matrix.loader }}.* mc-runtime-test: none - java: ${{ env.JAVA_VERSION }} + java: 17 fabric-api: ${{ matrix.loader == 'fabric' && env.FABRIC_API_VERSION || 'none' }} From c2120d87eac9a08d455b3628ee0bf7d352922530 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 23 Oct 2024 11:25:37 -0400 Subject: [PATCH 13/18] Add debug logging --- .github/workflows/build.yml | 2 -- .../flywheel/FlywheelTestModClient.java | 25 +++++++++++------ .../flywheel/FlywheelTestModClient.java | 27 +++++++++++-------- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e106b297..01106290b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -77,8 +77,6 @@ jobs: # Lock to a specific commit, it would be bad if the tag is re-pushed with unwanted changes - name: Run the MC client uses: 3arthqu4ke/mc-runtime-test@e72f8fe1134aabf6fc749a2a8c09bb56dd7d283e - env: - FLYWHEEL_AUTO_TEST: true with: mc: ${{ env.MINECRAFT_VERSION }} modloader: ${{ matrix.loader }} diff --git a/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java index 8e192acbf..9d833d9ec 100644 --- a/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java +++ b/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -1,22 +1,31 @@ package dev.engine_room.flywheel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.spongepowered.asm.mixin.MixinEnvironment; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; public class FlywheelTestModClient implements ClientModInitializer { + private static final Logger LOGGER = LoggerFactory.getLogger("Flywheel Test Mod"); + private int ticks = 0; @Override public void onInitializeClient() { - if (Boolean.parseBoolean(System.getProperty("FLYWHEEL_AUTO_TEST"))) { - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (++ticks == 50) { - MixinEnvironment.getCurrentEnvironment().audit(); - client.stop(); - } - }); - } + LOGGER.info("Starting Test Mod"); + + ClientTickEvents.END_CLIENT_TICK.register(client -> { + LOGGER.info("Tick Count: {}", ticks); + + if (++ticks == 50) { + LOGGER.info("Running mixin audit"); + MixinEnvironment.getCurrentEnvironment().audit(); + + LOGGER.info("Ran mixin audit, stopping client."); + client.stop(); + } + }); } } diff --git a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java index d9c727aa9..96b8c8b76 100644 --- a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java +++ b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -1,5 +1,9 @@ package dev.engine_room.flywheel; +import net.minecraftforge.common.MinecraftForge; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.spongepowered.asm.mixin.MixinEnvironment; import net.minecraft.client.Minecraft; @@ -10,22 +14,23 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @Mod("flywheel_testmod") public class FlywheelTestModClient { + private static final Logger LOGGER = LoggerFactory.getLogger("Flywheel Test Mod"); + private int ticks = 0; public FlywheelTestModClient() { - if (Boolean.parseBoolean(System.getProperty("FLYWHEEL_AUTO_TEST"))) { + MinecraftForge.EVENT_BUS.addListener((TickEvent.ClientTickEvent e) -> { + if (e.phase == TickEvent.Phase.END) { + LOGGER.info("Tick Count: {}", ticks); - IEventBus modEventBus = FMLJavaModLoadingContext.get() - .getModEventBus(); + if (++ticks == 50) { + LOGGER.info("Running mixin audit"); + MixinEnvironment.getCurrentEnvironment().audit(); - modEventBus.addListener((TickEvent.ClientTickEvent e) -> { - if (e.phase == TickEvent.Phase.END) { - if (++ticks == 50) { - MixinEnvironment.getCurrentEnvironment().audit(); - Minecraft.getInstance().stop(); - } + LOGGER.info("Ran mixin audit, stopping client."); + Minecraft.getInstance().stop(); } - }); - } + } + }); } } From abad081e38fe5720946d2d23a401d98d2ca032d1 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 23 Oct 2024 11:38:13 -0400 Subject: [PATCH 14/18] more logging --- .../java/dev/engine_room/flywheel/FlywheelTestModClient.java | 4 +++- .../java/dev/engine_room/flywheel/FlywheelTestModClient.java | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java index 9d833d9ec..71e4370e4 100644 --- a/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java +++ b/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -1,5 +1,7 @@ package dev.engine_room.flywheel; +import net.fabricmc.loader.api.FabricLoader; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spongepowered.asm.mixin.MixinEnvironment; @@ -14,7 +16,7 @@ public class FlywheelTestModClient implements ClientModInitializer { @Override public void onInitializeClient() { - LOGGER.info("Starting Test Mod"); + LOGGER.info("Starting Test Mod, on Env: {}", FabricLoader.getInstance().getEnvironmentType()); ClientTickEvents.END_CLIENT_TICK.register(client -> { LOGGER.info("Tick Count: {}", ticks); diff --git a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java index 96b8c8b76..35edb4882 100644 --- a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java +++ b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -2,6 +2,8 @@ package dev.engine_room.flywheel; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.loading.FMLLoader; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spongepowered.asm.mixin.MixinEnvironment; @@ -19,6 +21,8 @@ public class FlywheelTestModClient { private int ticks = 0; public FlywheelTestModClient() { + LOGGER.info("Starting Test Mod, on Dist: {}", FMLLoader.getDist()); + MinecraftForge.EVENT_BUS.addListener((TickEvent.ClientTickEvent e) -> { if (e.phase == TickEvent.Phase.END) { LOGGER.info("Tick Count: {}", ticks); From 6e5c4b8fb835e24a1e6102f1037090498abbb9d8 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Thu, 24 Oct 2024 06:47:33 -0400 Subject: [PATCH 15/18] get testmod from correct dir --- .github/workflows/build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4927f8ed0..53ec45f3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,9 +40,7 @@ jobs: path: | common/build/libs/ fabric/build/libs/ - fabric/build/devlibs/ forge/build/libs/ - forge/build/devlibs/ test: strategy: @@ -70,7 +68,7 @@ jobs: run: | mkdir -p run/mods cp ${{ matrix.loader }}/build/libs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}.jar run/mods - cp ${{ matrix.loader }}/build/devlibs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}-testmod.jar run/mods + cp ${{ matrix.loader }}/build/libs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}-testmod.jar run/mods # Lock to a specific commit, it would be bad if the tag is re-pushed with unwanted changes - name: Run the MC client From ed4379aa8f580f17916ad3ea3820df8510a5181f Mon Sep 17 00:00:00 2001 From: IThundxr Date: Sat, 26 Oct 2024 13:04:27 -0400 Subject: [PATCH 16/18] switch to env var --- .github/workflows/build.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 53ec45f3a..cf5b1c501 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,9 @@ name: Build on: [ workflow_dispatch, pull_request, push ] +env: + JAVA_VERSION: 17 + jobs: build: runs-on: ubuntu-latest @@ -10,7 +13,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Java - run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV" + run: echo "JAVA_HOME=$JAVA_HOME_${{ env.JAVA_VERSION }}_X64" >> "$GITHUB_ENV" - name: Loom Cache uses: actions/cache@v4 @@ -78,5 +81,5 @@ jobs: modloader: ${{ matrix.loader }} regex: .*${{ matrix.loader }}.* mc-runtime-test: none - java: 17 + java: ${{ env.JAVA_VERSION }} fabric-api: ${{ matrix.loader == 'fabric' && env.FABRIC_API_VERSION || 'none' }} From 03f94fe88c3ad44668db0132fc8acc536f556608 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Fri, 25 Oct 2024 13:13:05 -0700 Subject: [PATCH 17/18] Why wait? - Immediately audit on client tick --- .../flywheel/FlywheelTestModClient.java | 18 +++++--------- .../flywheel/FlywheelTestModClient.java | 24 +++++++------------ 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java index 71e4370e4..4db1ef980 100644 --- a/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java +++ b/fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -1,33 +1,27 @@ package dev.engine_room.flywheel; -import net.fabricmc.loader.api.FabricLoader; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spongepowered.asm.mixin.MixinEnvironment; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.fabricmc.loader.api.FabricLoader; public class FlywheelTestModClient implements ClientModInitializer { private static final Logger LOGGER = LoggerFactory.getLogger("Flywheel Test Mod"); - private int ticks = 0; - @Override public void onInitializeClient() { LOGGER.info("Starting Test Mod, on Env: {}", FabricLoader.getInstance().getEnvironmentType()); ClientTickEvents.END_CLIENT_TICK.register(client -> { - LOGGER.info("Tick Count: {}", ticks); + LOGGER.info("Running mixin audit"); + MixinEnvironment.getCurrentEnvironment() + .audit(); - if (++ticks == 50) { - LOGGER.info("Running mixin audit"); - MixinEnvironment.getCurrentEnvironment().audit(); - - LOGGER.info("Ran mixin audit, stopping client."); - client.stop(); - } + LOGGER.info("Ran mixin audit, stopping client."); + client.stop(); }); } } diff --git a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java index 35edb4882..a2fcbcf4e 100644 --- a/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java +++ b/forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java @@ -1,39 +1,31 @@ package dev.engine_room.flywheel; -import net.minecraftforge.common.MinecraftForge; - -import net.minecraftforge.fml.loading.FMLLoader; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spongepowered.asm.mixin.MixinEnvironment; import net.minecraft.client.Minecraft; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.TickEvent; -import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.fml.loading.FMLLoader; @Mod("flywheel_testmod") public class FlywheelTestModClient { private static final Logger LOGGER = LoggerFactory.getLogger("Flywheel Test Mod"); - private int ticks = 0; - public FlywheelTestModClient() { LOGGER.info("Starting Test Mod, on Dist: {}", FMLLoader.getDist()); MinecraftForge.EVENT_BUS.addListener((TickEvent.ClientTickEvent e) -> { if (e.phase == TickEvent.Phase.END) { - LOGGER.info("Tick Count: {}", ticks); + LOGGER.info("Running mixin audit"); + MixinEnvironment.getCurrentEnvironment() + .audit(); - if (++ticks == 50) { - LOGGER.info("Running mixin audit"); - MixinEnvironment.getCurrentEnvironment().audit(); - - LOGGER.info("Ran mixin audit, stopping client."); - Minecraft.getInstance().stop(); - } + LOGGER.info("Ran mixin audit, stopping client."); + Minecraft.getInstance() + .stop(); } }); } From 84e27867d38313f9cc01bb7aa2634595d4f10961 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 28 Oct 2024 13:36:39 -0700 Subject: [PATCH 18/18] DidObfuscate - Fix RenderSystemMixin on fabric - setShaderFogShape's arguments need to be remapped, but the name of the function should not be. Fortunately mixin allows matching by function name alone --- .../flywheel/backend/mixin/RenderSystemMixin.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/src/backend/java/dev/engine_room/flywheel/backend/mixin/RenderSystemMixin.java b/common/src/backend/java/dev/engine_room/flywheel/backend/mixin/RenderSystemMixin.java index 9a51df11b..b08444dc7 100644 --- a/common/src/backend/java/dev/engine_room/flywheel/backend/mixin/RenderSystemMixin.java +++ b/common/src/backend/java/dev/engine_room/flywheel/backend/mixin/RenderSystemMixin.java @@ -27,7 +27,10 @@ abstract class RenderSystemMixin { FogUniforms.update(); } - @Inject(method = "setShaderFogShape(Lcom/mojang/blaze3d/shaders/FogShape;)V", at = @At("RETURN")) + // Fabric fails to resolve the mixin in prod when the full signature is specified. + // I suspect it's because this method references a class name in its signature, + // and that needs to be remapped while the function names in RenderSystem are marked with @DontObfuscate. + @Inject(method = "setShaderFogShape", at = @At("RETURN")) private static void flywheel$onSetFogShape(CallbackInfo ci) { FogUniforms.update(); }