From 337f12034932cbb3ca350d9a5469ded39f5b05f9 Mon Sep 17 00:00:00 2001 From: 3arthqu4ke <56741599+3arthqu4ke@users.noreply.github.com> Date: Wed, 14 May 2025 12:32:37 +1000 Subject: [PATCH 1/6] fix(mod): Better logging for 1.7.10 --- .../mixin/MixinNetworkManager.java | 37 +++++++++++++++++++ .../resources/mc_runtime_test.mixins.json | 3 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java diff --git a/1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java b/1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java new file mode 100644 index 0000000..463811e --- /dev/null +++ b/1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java @@ -0,0 +1,37 @@ +package me.earth.mc_runtime_test.mixin; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.util.concurrent.GenericFutureListener; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import org.apache.logging.log4j.Logger; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(NetworkManager.class) +@SuppressWarnings("StringConcatenationArgumentToLogCall") +public class MixinNetworkManager { + @Shadow + @Final + private static Logger logger; + + @Inject(method = "scheduleOutboundPacket", at = @At("HEAD")) + protected void scheduleOutboundPacketHook(Packet packet, GenericFutureListener[] futureListeners, CallbackInfo ci) { + logger.info("Sending packet: " + packet.getClass().getName()); + } + + @Inject(method = "channelRead0", at = @At("HEAD")) + protected void channelRead0Hook(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { + logger.info("Packet received: " + packet.getClass().getName()); + } + + @Inject(method = "exceptionCaught", at = @At("HEAD")) + private void exceptionCaughtHook(ChannelHandlerContext context, Throwable throwable, CallbackInfo ci) { + logger.error("Exception caught", throwable); + } + +} diff --git a/1_7_10/src/main/resources/mc_runtime_test.mixins.json b/1_7_10/src/main/resources/mc_runtime_test.mixins.json index 9b6682e..3ffa82d 100644 --- a/1_7_10/src/main/resources/mc_runtime_test.mixins.json +++ b/1_7_10/src/main/resources/mc_runtime_test.mixins.json @@ -4,7 +4,8 @@ "package": "me.earth.mc_runtime_test.mixin", "compatibilityLevel": "JAVA_8", "client": [ - "MixinMinecraft" + "MixinMinecraft", + "MixinNetworkManager" ], "injectors": { "defaultRequire": 1 From 5a761fecf6cba4b67979a7defa3a02e6aef7141a Mon Sep 17 00:00:00 2001 From: 3arthqu4ke <56741599+3arthqu4ke@users.noreply.github.com> Date: Wed, 14 May 2025 12:50:22 +1000 Subject: [PATCH 2/6] chore(docs): Document use of blacksmith for caching --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 1d9e301..2016dbb 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,10 @@ The following table summarizes the available inputs for customization: --- +## Caching +Mc-Runtime-test uses `blacksmith/cache`, simply follow the instructions [here](https://docs.blacksmith.sh/introduction/quickstart) +to enable blacksmith for your repositories. + ## Running Your Own Tests MC-Runtime-Test supports Minecraft’s [Game-Test Framework](https://www.minecraft.net/en-us/creator/article/get-started-gametest-framework). It executes `/test runall` upon joining a world. From dc1c3e258098c83951dae86094e8eaf997a246e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chip=20Wolf=20=E2=80=AE?= Date: Sat, 31 May 2025 21:03:28 +0100 Subject: [PATCH 3/6] chore: disable cache by default --- .github/workflows/lifecycle.yml | 1 + .github/workflows/run-gametests.yml | 1 + .github/workflows/test-local-action.yml | 1 - README.md | 3 +-- action.yml | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lifecycle.yml b/.github/workflows/lifecycle.yml index 294b1f2..7f1cd83 100644 --- a/.github/workflows/lifecycle.yml +++ b/.github/workflows/lifecycle.yml @@ -256,6 +256,7 @@ jobs: timeout-minutes: 3 uses: ./ with: + cache-mc: "true" mc: ${{ matrix.version.mc }} mc-runtime-test: none modloader: ${{ matrix.version.modloader }} diff --git a/.github/workflows/run-gametests.yml b/.github/workflows/run-gametests.yml index 3bb1803..4f6fb15 100644 --- a/.github/workflows/run-gametests.yml +++ b/.github/workflows/run-gametests.yml @@ -60,6 +60,7 @@ jobs: # TODO: add cleanup job timeout-minutes: 3 uses: ./ with: + cache-mc: "true" mc: ${{ matrix.mc }} modloader: ${{ matrix.modloader }} regex: ${{ matrix.regex }} diff --git a/.github/workflows/test-local-action.yml b/.github/workflows/test-local-action.yml index b7c6c41..6635710 100644 --- a/.github/workflows/test-local-action.yml +++ b/.github/workflows/test-local-action.yml @@ -69,4 +69,3 @@ jobs: fabric-api: ${{ github.event.inputs.fabric-api }} fabric-gametest-api: ${{ github.event.inputs.fabric-gametest-api }} hmc-version: ${{ github.event.inputs.hmc-version }} - cache-mc: false diff --git a/README.md b/README.md index 2016dbb..a329998 100644 --- a/README.md +++ b/README.md @@ -118,8 +118,7 @@ The following table summarizes the available inputs for customization: --- ## Caching -Mc-Runtime-test uses `blacksmith/cache`, simply follow the instructions [here](https://docs.blacksmith.sh/introduction/quickstart) -to enable blacksmith for your repositories. +Mc-Runtime-Test optionally caches `.minecraft` to improve execution time, for this we use `blacksmith/cache` simply follow the instructions [here](https://docs.blacksmith.sh/introduction/quickstart) to enable blacksmith for your repositories and enable the `cache-mc` input. ## Running Your Own Tests MC-Runtime-Test supports Minecraft’s [Game-Test Framework](https://www.minecraft.net/en-us/creator/article/get-started-gametest-framework). It executes `/test runall` upon joining a world. diff --git a/action.yml b/action.yml index 5898729..428994a 100644 --- a/action.yml +++ b/action.yml @@ -44,7 +44,7 @@ inputs: default: "2.5.1" cache-mc: description: Cache .minecraft - default: "true" + default: "false" runs: using: composite From fbd814dbdd7eedf3c3620338a070342d09190c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chip=20Wolf=20=E2=80=AE?= Date: Sat, 31 May 2025 21:08:46 +0100 Subject: [PATCH 4/6] Update 1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../me/earth/mc_runtime_test/mixin/MixinNetworkManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java b/1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java index 463811e..1a95e44 100644 --- a/1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java +++ b/1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java @@ -21,12 +21,12 @@ public class MixinNetworkManager { @Inject(method = "scheduleOutboundPacket", at = @At("HEAD")) protected void scheduleOutboundPacketHook(Packet packet, GenericFutureListener[] futureListeners, CallbackInfo ci) { - logger.info("Sending packet: " + packet.getClass().getName()); + logger.info("Sending packet: {}", packet.getClass().getName()); } @Inject(method = "channelRead0", at = @At("HEAD")) protected void channelRead0Hook(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { - logger.info("Packet received: " + packet.getClass().getName()); + logger.info("Packet received: {}", packet.getClass().getName()); } @Inject(method = "exceptionCaught", at = @At("HEAD")) From 4624f28f4e676bbede2c65d713e9fa6acc706410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chip=20Wolf=20=E2=80=AE?= Date: Sat, 31 May 2025 21:09:41 +0100 Subject: [PATCH 5/6] chore(docs): capitalisation nitpick --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a329998..bb7128b 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ The following table summarizes the available inputs for customization: --- ## Caching -Mc-Runtime-Test optionally caches `.minecraft` to improve execution time, for this we use `blacksmith/cache` simply follow the instructions [here](https://docs.blacksmith.sh/introduction/quickstart) to enable blacksmith for your repositories and enable the `cache-mc` input. +MC-Runtime-Test optionally caches `.minecraft` to improve execution time, for this we use `blacksmith/cache` simply follow the instructions [here](https://docs.blacksmith.sh/introduction/quickstart) to enable blacksmith for your repositories and enable the `cache-mc` input. ## Running Your Own Tests MC-Runtime-Test supports Minecraft’s [Game-Test Framework](https://www.minecraft.net/en-us/creator/article/get-started-gametest-framework). It executes `/test runall` upon joining a world. From 8e2ccc9934abc8664adfb8e4bbb3601533233180 Mon Sep 17 00:00:00 2001 From: 3arthqu4ke <56741599+3arthqu4ke@users.noreply.github.com> Date: Sun, 1 Jun 2025 12:14:51 +1000 Subject: [PATCH 6/6] chore(docs): Make cache step configurable, default to github cache --- .github/workflows/lifecycle.yml | 2 +- .github/workflows/run-gametests.yml | 2 +- .github/workflows/test-local-action.yml | 1 + .../mixin/MixinNetworkManager.java | 1 - README.md | 38 +++++++++++-------- action.yml | 13 +++++-- 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/.github/workflows/lifecycle.yml b/.github/workflows/lifecycle.yml index 7f1cd83..2767c90 100644 --- a/.github/workflows/lifecycle.yml +++ b/.github/workflows/lifecycle.yml @@ -256,7 +256,7 @@ jobs: timeout-minutes: 3 uses: ./ with: - cache-mc: "true" + cache-mc: "blacksmith" mc: ${{ matrix.version.mc }} mc-runtime-test: none modloader: ${{ matrix.version.modloader }} diff --git a/.github/workflows/run-gametests.yml b/.github/workflows/run-gametests.yml index 4f6fb15..887489b 100644 --- a/.github/workflows/run-gametests.yml +++ b/.github/workflows/run-gametests.yml @@ -60,7 +60,7 @@ jobs: # TODO: add cleanup job timeout-minutes: 3 uses: ./ with: - cache-mc: "true" + cache-mc: "blacksmith" mc: ${{ matrix.mc }} modloader: ${{ matrix.modloader }} regex: ${{ matrix.regex }} diff --git a/.github/workflows/test-local-action.yml b/.github/workflows/test-local-action.yml index 6635710..b7c6c41 100644 --- a/.github/workflows/test-local-action.yml +++ b/.github/workflows/test-local-action.yml @@ -69,3 +69,4 @@ jobs: fabric-api: ${{ github.event.inputs.fabric-api }} fabric-gametest-api: ${{ github.event.inputs.fabric-gametest-api }} hmc-version: ${{ github.event.inputs.hmc-version }} + cache-mc: false diff --git a/1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java b/1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java index 1a95e44..22c7bc1 100644 --- a/1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java +++ b/1_7_10/src/main/java/me/earth/mc_runtime_test/mixin/MixinNetworkManager.java @@ -13,7 +13,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(NetworkManager.class) -@SuppressWarnings("StringConcatenationArgumentToLogCall") public class MixinNetworkManager { @Shadow @Final diff --git a/README.md b/README.md index bb7128b..c93e38c 100644 --- a/README.md +++ b/README.md @@ -99,26 +99,32 @@ More examples: ## Inputs The following table summarizes the available inputs for customization: -| Input | Description | Required | Example | -|-----------------------|----------------------------------------|----------|------------------------------------------| -| `mc` | Minecraft version to run | Yes | `1.20.4` | -| `modloader` | Modloader to install | Yes | `forge`, `neoforge`, `fabric` | -| `regex` | Regex to match the modloader jar | Yes | `.*fabric.*` | -| `java` | Java version to use | Yes | `8`, `16`, `17`, `21` | -| `mc-runtime-test` | MC-Runtime-Test jar to download | Yes | `none`, `lexforge`, `neoforge`, `fabric` | -| `dummy-assets` | Use dummy assets during testing | | `true`, `false` | -| `xvfb` | Runs the game with Xvfb | | `true`, `false` | -| `headlessmc-command` | Command-line arguments for HeadlessMC | | `--jvm "-Djava.awt.headless=true"` | -| `fabric-api` | Fabric API version to download or none | | `0.97.0`, `none` | -| `fabric-gametest-api` | Fabric GameTest API version or none | | `1.3.5+85d85a934f`, `none` | -| `download-hmc` | Download HeadlessMC | | `true`, `false` | -| `hmc-version` | HeadlessMC version | | `2.5.1`, `1.5.0` | -| `cache-mc` | Cache `.minecraft` | | `true`, `false` | +| Input | Description | Required | Example | +|-----------------------|-----------------------------------------------------------|----------|------------------------------------------| +| `mc` | Minecraft version to run | Yes | `1.20.4` | +| `modloader` | Modloader to install | Yes | `forge`, `neoforge`, `fabric` | +| `regex` | Regex to match the modloader jar | Yes | `.*fabric.*` | +| `java` | Java version to use | Yes | `8`, `16`, `17`, `21` | +| `mc-runtime-test` | MC-Runtime-Test jar to download | Yes | `none`, `lexforge`, `neoforge`, `fabric` | +| `dummy-assets` | Use dummy assets during testing | | `true`, `false` | +| `xvfb` | Runs the game with Xvfb | | `true`, `false` | +| `headlessmc-command` | Command-line arguments for HeadlessMC | | `--jvm "-Djava.awt.headless=true"` | +| `fabric-api` | Fabric API version to download or none | | `0.97.0`, `none` | +| `fabric-gametest-api` | Fabric GameTest API version or none | | `1.3.5+85d85a934f`, `none` | +| `download-hmc` | Download HeadlessMC | | `true`, `false` | +| `hmc-version` | HeadlessMC version | | `2.5.1`, `1.5.0` | +| `cache-mc` | Cache `.minecraft`
(`true` defaults to `blacksmith`) | | `github`, `blacksmith`, `true`, `false` | --- ## Caching -MC-Runtime-Test optionally caches `.minecraft` to improve execution time, for this we use `blacksmith/cache` simply follow the instructions [here](https://docs.blacksmith.sh/introduction/quickstart) to enable blacksmith for your repositories and enable the `cache-mc` input. +MC-Runtime-Test optionally caches `.minecraft` to improve execution time. +By default `cache-mc` is set to `github`, which uses `actions/cache`. +Set `cache-mc` to `false` to disable caching. + +Another option is `blacksmith` for `blacksmith/cache`. +Simply follow the instructions [here](https://docs.blacksmith.sh/introduction/quickstart) +to enable blacksmith for your repositories and enable the `cache-mc` input. ## Running Your Own Tests MC-Runtime-Test supports Minecraft’s [Game-Test Framework](https://www.minecraft.net/en-us/creator/article/get-started-gametest-framework). It executes `/test runall` upon joining a world. diff --git a/action.yml b/action.yml index 428994a..294b6a3 100644 --- a/action.yml +++ b/action.yml @@ -43,8 +43,8 @@ inputs: description: HeadlessMC version default: "2.5.1" cache-mc: - description: Cache .minecraft - default: "false" + description: Cache .minecraft (blacksmith, github, true (defaults to blacksmith), false) + default: "github" runs: using: composite @@ -74,13 +74,20 @@ runs: tag: ${{ inputs.hmc-version }} fileName: headlessmc-launcher-${{ inputs.hmc-version }}.jar - - if: inputs.cache-mc == 'true' + - if: inputs.cache-mc == 'true' || inputs.cache-mc == 'blacksmith' name: Cache Minecraft uses: useblacksmith/cache@c5fe29eb0efdf1cf4186b9f7fcbbcbc0cf025662 # v5 with: path: /home/runner/.minecraft key: ${{ inputs.mc }}-${{ inputs.modloader }}-hmc + - if: inputs.cache-mc == 'github' + name: Cache Minecraft + uses: actions/cache@v4 + with: + path: /home/runner/.minecraft + key: ${{ inputs.mc }}-${{ inputs.modloader }}-hmc + - name: Download ${{ inputs.modloader }}-${{ inputs.mc }} run: | if [ ! -f "$HOME/.minecraft/versions/${{ inputs.mc }}/${{ inputs.mc }}.json" ]; then