Skip to content

Commit 0031914

Browse files
3arthqu4keChipWolfCopilot
authored
feat!: Default to github cache, blacksmith or no cache are configurable, extensive 1.7.10 logging (#74)
Co-authored-by: Chip Wolf ‮ <hello@chipwolf.uk> Co-authored-by: Chip Wolf ‮ <chipukyt@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3dea483 commit 0031914

File tree

6 files changed

+74
-19
lines changed

6 files changed

+74
-19
lines changed

.github/workflows/lifecycle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ jobs:
256256
timeout-minutes: 3
257257
uses: ./
258258
with:
259+
cache-mc: "blacksmith"
259260
mc: ${{ matrix.version.mc }}
260261
mc-runtime-test: none
261262
modloader: ${{ matrix.version.modloader }}

.github/workflows/run-gametests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs: # TODO: add cleanup job
6060
timeout-minutes: 3
6161
uses: ./
6262
with:
63+
cache-mc: "blacksmith"
6364
mc: ${{ matrix.mc }}
6465
modloader: ${{ matrix.modloader }}
6566
regex: ${{ matrix.regex }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package me.earth.mc_runtime_test.mixin;
2+
3+
import io.netty.channel.ChannelHandlerContext;
4+
import io.netty.util.concurrent.GenericFutureListener;
5+
import net.minecraft.network.NetworkManager;
6+
import net.minecraft.network.Packet;
7+
import org.apache.logging.log4j.Logger;
8+
import org.spongepowered.asm.mixin.Final;
9+
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.Shadow;
11+
import org.spongepowered.asm.mixin.injection.At;
12+
import org.spongepowered.asm.mixin.injection.Inject;
13+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
14+
15+
@Mixin(NetworkManager.class)
16+
public class MixinNetworkManager {
17+
@Shadow
18+
@Final
19+
private static Logger logger;
20+
21+
@Inject(method = "scheduleOutboundPacket", at = @At("HEAD"))
22+
protected void scheduleOutboundPacketHook(Packet packet, GenericFutureListener<?>[] futureListeners, CallbackInfo ci) {
23+
logger.info("Sending packet: {}", packet.getClass().getName());
24+
}
25+
26+
@Inject(method = "channelRead0", at = @At("HEAD"))
27+
protected void channelRead0Hook(ChannelHandlerContext context, Packet packet, CallbackInfo ci) {
28+
logger.info("Packet received: {}", packet.getClass().getName());
29+
}
30+
31+
@Inject(method = "exceptionCaught", at = @At("HEAD"))
32+
private void exceptionCaughtHook(ChannelHandlerContext context, Throwable throwable, CallbackInfo ci) {
33+
logger.error("Exception caught", throwable);
34+
}
35+
36+
}

1_7_10/src/main/resources/mc_runtime_test.mixins.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"package": "me.earth.mc_runtime_test.mixin",
55
"compatibilityLevel": "JAVA_8",
66
"client": [
7-
"MixinMinecraft"
7+
"MixinMinecraft",
8+
"MixinNetworkManager"
89
],
910
"injectors": {
1011
"defaultRequire": 1

README.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,33 @@ More examples:
9999
## Inputs
100100
The following table summarizes the available inputs for customization:
101101

102-
| Input | Description | Required | Example |
103-
|-----------------------|----------------------------------------|----------|------------------------------------------|
104-
| `mc` | Minecraft version to run | Yes | `1.20.4` |
105-
| `modloader` | Modloader to install | Yes | `forge`, `neoforge`, `fabric` |
106-
| `regex` | Regex to match the modloader jar | Yes | `.*fabric.*` |
107-
| `java` | Java version to use | Yes | `8`, `16`, `17`, `21` |
108-
| `mc-runtime-test` | MC-Runtime-Test jar to download | Yes | `none`, `lexforge`, `neoforge`, `fabric` |
109-
| `dummy-assets` | Use dummy assets during testing | | `true`, `false` |
110-
| `xvfb` | Runs the game with Xvfb | | `true`, `false` |
111-
| `headlessmc-command` | Command-line arguments for HeadlessMC | | `--jvm "-Djava.awt.headless=true"` |
112-
| `fabric-api` | Fabric API version to download or none | | `0.97.0`, `none` |
113-
| `fabric-gametest-api` | Fabric GameTest API version or none | | `1.3.5+85d85a934f`, `none` |
114-
| `download-hmc` | Download HeadlessMC | | `true`, `false` |
115-
| `hmc-version` | HeadlessMC version | | `2.5.1`, `1.5.0` |
116-
| `cache-mc` | Cache `.minecraft` | | `true`, `false` |
102+
| Input | Description | Required | Example |
103+
|-----------------------|-----------------------------------------------------------|----------|------------------------------------------|
104+
| `mc` | Minecraft version to run | Yes | `1.20.4` |
105+
| `modloader` | Modloader to install | Yes | `forge`, `neoforge`, `fabric` |
106+
| `regex` | Regex to match the modloader jar | Yes | `.*fabric.*` |
107+
| `java` | Java version to use | Yes | `8`, `16`, `17`, `21` |
108+
| `mc-runtime-test` | MC-Runtime-Test jar to download | Yes | `none`, `lexforge`, `neoforge`, `fabric` |
109+
| `dummy-assets` | Use dummy assets during testing | | `true`, `false` |
110+
| `xvfb` | Runs the game with Xvfb | | `true`, `false` |
111+
| `headlessmc-command` | Command-line arguments for HeadlessMC | | `--jvm "-Djava.awt.headless=true"` |
112+
| `fabric-api` | Fabric API version to download or none | | `0.97.0`, `none` |
113+
| `fabric-gametest-api` | Fabric GameTest API version or none | | `1.3.5+85d85a934f`, `none` |
114+
| `download-hmc` | Download HeadlessMC | | `true`, `false` |
115+
| `hmc-version` | HeadlessMC version | | `2.5.1`, `1.5.0` |
116+
| `cache-mc` | Cache `.minecraft` <br/>(`true` defaults to `blacksmith`) | | `github`, `blacksmith`, `true`, `false` |
117117

118118
---
119119

120+
## Caching
121+
MC-Runtime-Test optionally caches `.minecraft` to improve execution time.
122+
By default `cache-mc` is set to `github`, which uses `actions/cache`.
123+
Set `cache-mc` to `false` to disable caching.
124+
125+
Another option is `blacksmith` for `blacksmith/cache`.
126+
Simply follow the instructions [here](https://docs.blacksmith.sh/introduction/quickstart)
127+
to enable blacksmith for your repositories and enable the `cache-mc` input.
128+
120129
## Running Your Own Tests
121130
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.
122131

action.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ inputs:
4343
description: HeadlessMC version
4444
default: "2.5.1"
4545
cache-mc:
46-
description: Cache .minecraft
47-
default: "true"
46+
description: Cache .minecraft (blacksmith, github, true (defaults to blacksmith), false)
47+
default: "github"
4848

4949
runs:
5050
using: composite
@@ -74,13 +74,20 @@ runs:
7474
tag: ${{ inputs.hmc-version }}
7575
fileName: headlessmc-launcher-${{ inputs.hmc-version }}.jar
7676

77-
- if: inputs.cache-mc == 'true'
77+
- if: inputs.cache-mc == 'true' || inputs.cache-mc == 'blacksmith'
7878
name: Cache Minecraft
7979
uses: useblacksmith/cache@c5fe29eb0efdf1cf4186b9f7fcbbcbc0cf025662 # v5
8080
with:
8181
path: /home/runner/.minecraft
8282
key: ${{ inputs.mc }}-${{ inputs.modloader }}-hmc
8383

84+
- if: inputs.cache-mc == 'github'
85+
name: Cache Minecraft
86+
uses: actions/cache@v4
87+
with:
88+
path: /home/runner/.minecraft
89+
key: ${{ inputs.mc }}-${{ inputs.modloader }}-hmc
90+
8491
- name: Download ${{ inputs.modloader }}-${{ inputs.mc }}
8592
run: |
8693
if [ ! -f "$HOME/.minecraft/versions/${{ inputs.mc }}/${{ inputs.mc }}.json" ]; then

0 commit comments

Comments
 (0)