Skip to content

fix(mod): better logging for 1.7.10, default to github caching #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/lifecycle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ jobs:
timeout-minutes: 3
uses: ./
with:
cache-mc: "blacksmith"
mc: ${{ matrix.version.mc }}
mc-runtime-test: none
modloader: ${{ matrix.version.modloader }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/run-gametests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs: # TODO: add cleanup job
timeout-minutes: 3
uses: ./
with:
cache-mc: "blacksmith"
mc: ${{ matrix.mc }}
modloader: ${{ matrix.modloader }}
regex: ${{ matrix.regex }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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)
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);
}

}
3 changes: 2 additions & 1 deletion 1_7_10/src/main/resources/mc_runtime_test.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"package": "me.earth.mc_runtime_test.mixin",
"compatibilityLevel": "JAVA_8",
"client": [
"MixinMinecraft"
"MixinMinecraft",
"MixinNetworkManager"
],
"injectors": {
"defaultRequire": 1
Expand Down
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,33 @@ 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` <br/>(`true` defaults to `blacksmith`) | | `github`, `blacksmith`, `true`, `false` |

---

## Caching
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.

Expand Down
13 changes: 10 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ inputs:
description: HeadlessMC version
default: "2.5.1"
cache-mc:
description: Cache .minecraft
default: "true"
description: Cache .minecraft (blacksmith, github, true (defaults to blacksmith), false)
default: "github"

runs:
using: composite
Expand Down Expand Up @@ -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
Expand Down
Loading