diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f8085df16..a00943822a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,10 +60,7 @@ jobs: if: ${{ env.COVERALLS_REPO_TOKEN }} run: ./gradlew test jacocoTestReport coveralls - name: 'Game Test' - env: - GAME_TEST: ${{ secrets.GAME_TEST }} - if: ${{ env.GAME_TEST }} - run: ./gradlew runGameTestServer + run: ./gradlew runGameTestServer -x :loader-forge:downloadAssets - name: 'Deploy as GitHub CI artifacts' uses: actions/upload-artifact@v4 with: diff --git a/buildSrc/src/main/groovy/multiloader-loader-fabric.gradle b/buildSrc/src/main/groovy/multiloader-loader-fabric.gradle index e80d202b34..5e2372e33b 100644 --- a/buildSrc/src/main/groovy/multiloader-loader-fabric.gradle +++ b/buildSrc/src/main/groovy/multiloader-loader-fabric.gradle @@ -38,9 +38,20 @@ loom { ideConfigGenerated(true) runDir('runs/server') } + gameTest { + server() + setConfigName('Loader-fabric: GameTestServer') + ideConfigGenerated(true) + runDir('runs/gametest') + vmArg "-Dfabric-api.gametest" + } } } +task runGameTestServer { + dependsOn tasks.runGameTest +} + publishing { publications { PublicationContainer publicationContainer -> publicationContainer.getByName("maven") { MavenPublication publication -> diff --git a/buildSrc/src/main/groovy/multiloader-loader-forge.gradle b/buildSrc/src/main/groovy/multiloader-loader-forge.gradle index b3244597d7..8fca39a20f 100644 --- a/buildSrc/src/main/groovy/multiloader-loader-forge.gradle +++ b/buildSrc/src/main/groovy/multiloader-loader-forge.gradle @@ -52,6 +52,7 @@ minecraft { runs { client { + property 'forge.enabledGameTestNamespaces', "cyclopscore,${mod_id}" workingDirectory file('runs/client') ideaModule "${rootProject.name}.${project.name}.main" taskName 'Client' @@ -63,6 +64,8 @@ minecraft { } server { + property 'forge.enabledGameTestNamespaces', "cyclopscore,${mod_id}" + args '--nogui' workingDirectory file('runs/server') ideaModule "${rootProject.name}.${project.name}.main" taskName 'Server' @@ -73,6 +76,18 @@ minecraft { } } + gameTestServer { + property 'forge.enabledGameTestNamespaces', "cyclopscore,${mod_id}" + workingDirectory file('runs/gametest') + ideaModule "${rootProject.name}.${project.name}.main" + taskName 'runGameTestServer' + mods { + modDataRun { + source sourceSets.main + } + } + } + data { workingDirectory file('runs/data') ideaModule "${rootProject.name}.${project.name}.main" @@ -108,3 +123,4 @@ sourceSets.forEach { it.output.resourcesDir = dir it.java.destinationDirectory = dir } + diff --git a/buildSrc/src/main/groovy/multiloader-loader-neoforge.gradle b/buildSrc/src/main/groovy/multiloader-loader-neoforge.gradle index 3508f9a370..e0eb0c81c6 100644 --- a/buildSrc/src/main/groovy/multiloader-loader-neoforge.gradle +++ b/buildSrc/src/main/groovy/multiloader-loader-neoforge.gradle @@ -59,16 +59,16 @@ runs { } client { - systemProperty 'neoforge.enabledGameTestNamespaces', mod_id + systemProperty 'neoforge.enabledGameTestNamespaces', "cyclopscore,${mod_id}" } server { - systemProperty 'neoforge.enabledGameTestNamespaces', mod_id + systemProperty 'neoforge.enabledGameTestNamespaces', "cyclopscore,${mod_id}" programArgument '--nogui' } gameTestServer { - systemProperty 'neoforge.enabledGameTestNamespaces', mod_id + systemProperty 'neoforge.enabledGameTestNamespaces', "cyclopscore,${mod_id}" } data { diff --git a/loader-common/src/main/resources/data/cyclopscore/structure/empty.nbt b/loader-common/src/main/resources/data/cyclopscore/structure/empty.nbt new file mode 100644 index 0000000000..fc8fcd4495 Binary files /dev/null and b/loader-common/src/main/resources/data/cyclopscore/structure/empty.nbt differ diff --git a/loader-fabric/src/main/java/org/cyclops/cyclopscore/gametest/StartupTestFabric.java b/loader-fabric/src/main/java/org/cyclops/cyclopscore/gametest/StartupTestFabric.java new file mode 100644 index 0000000000..a3adec04cc --- /dev/null +++ b/loader-fabric/src/main/java/org/cyclops/cyclopscore/gametest/StartupTestFabric.java @@ -0,0 +1,18 @@ +package org.cyclops.cyclopscore.gametest; + +import net.minecraft.gametest.framework.GameTest; +import net.minecraft.gametest.framework.GameTestHelper; +import org.cyclops.cyclopscore.Reference; + +/** + * @author rubensworks + */ +public class StartupTestFabric { + + @GameTest(template = Reference.MOD_ID + ":empty") + public void testDummy(GameTestHelper helper) { + // A dummy test to ensure the server starts properly + helper.succeed(); + } + +} diff --git a/loader-fabric/src/main/resources/fabric.mod.json b/loader-fabric/src/main/resources/fabric.mod.json index a2ece377e0..993d5cea1d 100644 --- a/loader-fabric/src/main/resources/fabric.mod.json +++ b/loader-fabric/src/main/resources/fabric.mod.json @@ -20,6 +20,9 @@ "entrypoints": { "main": [ "org.cyclops.cyclopscore.CyclopsCoreFabric" + ], + "fabric-gametest": [ + "org.cyclops.cyclopscore.gametest.StartupTestFabric" ] }, "accessWidener" : "cyclopscore.accesswidener", diff --git a/loader-forge/build.gradle b/loader-forge/build.gradle index e01781e1e5..70c985ab11 100644 --- a/loader-forge/build.gradle +++ b/loader-forge/build.gradle @@ -82,6 +82,20 @@ minecraft { } } + gameTestServer { + property 'forge.enableGameTest', 'true' + property 'forge.enabledGameTestNamespaces', mod_id + workingDirectory file('runs/gametest') + ideaModule "${rootProject.name}.${project.name}.main" + taskName 'runGameTestServer' + mods { + modDataRun { + source sourceSets.main + source sourceSets.api + } + } + } + data { workingDirectory file('runs/data') ideaModule "${rootProject.name}.${project.name}.main" diff --git a/loader-forge/src/main/java/org/cyclops/cyclopscore/gametest/StartupTestForge.java b/loader-forge/src/main/java/org/cyclops/cyclopscore/gametest/StartupTestForge.java new file mode 100644 index 0000000000..1d78d00a9f --- /dev/null +++ b/loader-forge/src/main/java/org/cyclops/cyclopscore/gametest/StartupTestForge.java @@ -0,0 +1,20 @@ +package org.cyclops.cyclopscore.gametest; + +import net.minecraft.gametest.framework.GameTest; +import net.minecraft.gametest.framework.GameTestHelper; +import net.minecraftforge.gametest.GameTestHolder; +import org.cyclops.cyclopscore.Reference; + +/** + * @author rubensworks + */ +@GameTestHolder(Reference.MOD_ID) +public class StartupTestForge { + + @GameTest(template = Reference.MOD_ID + ":empty") + public void testDummy(GameTestHelper helper) { + // A dummy test to ensure the server starts properly + helper.succeed(); + } + +} diff --git a/loader-neoforge/src/main/java/org/cyclops/cyclopscore/gametest/StartupTestNeoForge.java b/loader-neoforge/src/main/java/org/cyclops/cyclopscore/gametest/StartupTestNeoForge.java new file mode 100644 index 0000000000..6778f91149 --- /dev/null +++ b/loader-neoforge/src/main/java/org/cyclops/cyclopscore/gametest/StartupTestNeoForge.java @@ -0,0 +1,22 @@ +package org.cyclops.cyclopscore.gametest; + +import net.minecraft.gametest.framework.GameTest; +import net.minecraft.gametest.framework.GameTestHelper; +import net.neoforged.neoforge.gametest.GameTestHolder; +import net.neoforged.neoforge.gametest.PrefixGameTestTemplate; +import org.cyclops.cyclopscore.Reference; + +/** + * @author rubensworks + */ +@GameTestHolder(Reference.MOD_ID) +@PrefixGameTestTemplate(false) +public class StartupTestNeoForge { + + @GameTest(template = "empty") + public void testDummy(GameTestHelper helper) { + // A dummy test to ensure the server starts properly + helper.succeed(); + } + +}