Skip to content

Commit bcd7f3f

Browse files
Migrate tests to Fabric Client GameTest API
1 parent 84b3c91 commit bcd7f3f

35 files changed

+1231
-1151
lines changed

.github/workflows/gradle.yml

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -87,57 +87,29 @@ jobs:
8787
done
8888
echo "</details>" >> $GITHUB_STEP_SUMMARY
8989
90-
- name: Run the mod and take screenshots
91-
# TODO: Migrate to Fabric Client Gametest API so this can run with configuration cache enabled
92-
run: xvfb-run --auto-servernum ./gradlew runEndToEndTest --stacktrace --warning-mode=fail --no-configuration-cache
90+
- name: Run client gametests
91+
env:
92+
IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }}
93+
run: xvfb-run --auto-servernum ./gradlew runClientGameTest --stacktrace --warning-mode=fail
9394

94-
- name: Upload screenshots.zip artifact
95+
- name: Upload screenshots
9596
uses: actions/upload-artifact@v5
9697
if: ${{ success() || failure() }}
9798
with:
9899
name: screenshots
99-
path: run/screenshots
100+
path: build/run/*/screenshots
100101
compression-level: 0
101102

102-
- name: Upload crash-reports.zip artifact
103+
- name: Upload logs
104+
uses: actions/upload-artifact@v5
105+
if: ${{ success() || failure() }}
106+
with:
107+
name: logs
108+
path: build/run/*/logs/latest.log
109+
110+
- name: Upload crash reports
103111
uses: actions/upload-artifact@v5
104112
if: ${{ failure() }}
105113
with:
106114
name: crash-reports
107-
path: run/crash-reports
108-
109-
- name: Create test screenshot gallery
110-
env:
111-
IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }}
112-
if: ${{ env.IMGUR_CLIENT_ID && (success() || failure()) }}
113-
# Imgur uploads randomly fail sometimes, probably because of the low rate limit.
114-
# TODO: Find a better place to upload the screenshots.
115-
continue-on-error: true
116-
run: |
117-
echo "<details open>" >> $GITHUB_STEP_SUMMARY
118-
echo "<summary>📸 Test Screenshots</summary>" >> $GITHUB_STEP_SUMMARY
119-
echo "" >> $GITHUB_STEP_SUMMARY
120-
for img in run/screenshots/*.png; do
121-
if [ -f "$img" ]; then
122-
filename=$(basename "$img")
123-
name_without_ext="${filename%.*}"
124-
# Upload to Imgur
125-
response=$(curl -s -X POST \
126-
-H "Authorization: Client-ID $IMGUR_CLIENT_ID" \
127-
-F "image=@$img" \
128-
https://api.imgur.com/3/image)
129-
# Extract the URL from the response
130-
url=$(echo $response | grep -o '"link":"[^"]*"' | cut -d'"' -f4)
131-
if [ ! -z "$url" ]; then
132-
# Convert underscores to spaces and capitalize first letter of each word
133-
title=$(echo "$name_without_ext" | tr '_' ' ' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
134-
echo "### $title" >> $GITHUB_STEP_SUMMARY
135-
echo "![${name_without_ext}]($url)" >> $GITHUB_STEP_SUMMARY
136-
echo "" >> $GITHUB_STEP_SUMMARY
137-
else
138-
echo "Failed to upload $filename" >> $GITHUB_STEP_SUMMARY
139-
echo "Imgur upload response for $filename: $response"
140-
fi
141-
fi
142-
done
143-
echo "</details>" >> $GITHUB_STEP_SUMMARY
115+
path: build/run/*/crash-reports

build.gradle

Lines changed: 10 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ buildscript {
22
dependencies {
33
classpath "org.kohsuke:github-api:1.330"
44
}
5-
6-
configurations.classpath {
7-
resolutionStrategy {
8-
// v28.0-jre, used by fabric-loom 1.13.3, is vulnerable to CVE-2020-8908 and CVE-2023-2976
9-
force "com.google.guava:guava:32.0.1-jre"
10-
}
11-
}
125
}
136

147
plugins {
@@ -33,24 +26,6 @@ repositories {
3326
// for more information about repositories.
3427
}
3528

36-
// Override vulnerable dependencies until Minecraft updates to newer versions
37-
configurations.all {
38-
resolutionStrategy {
39-
// v2.5.1, used by Minecraft 1.21.4 - 1.21.10, is vulnerable to CVE-2024-57699
40-
force "net.minidev:json-smart:2.5.2"
41-
// v2.13.4, used by Minecraft 1.21.4 - 1.21.10, is vulnerable to CVE-2025-52999
42-
force "com.fasterxml.jackson.core:jackson-core:2.15.0"
43-
// v3.17.0, used by Minecraft 1.21.4 - 1.21.10, is vulnerable to CVE-2025-48924
44-
force "org.apache.commons:commons-lang3:3.18.0"
45-
// v9.40, used by Minecraft 1.21.4 - 1.21.10, is vulnerable to CVE-2025-53864
46-
force "com.nimbusds:nimbus-jose-jwt:10.0.2"
47-
// v4.1.118.Final, used by Minecraft 1.21.5 - 1.21.10, is vulnerable to CVE-2025-58057
48-
force "io.netty:netty-codec:4.1.125.Final"
49-
// v4.1.118.Final, used by Minecraft 1.21.5 - 1.21.10, is vulnerable to CVE-2025-58056
50-
force "io.netty:netty-codec-http:4.1.125.Final"
51-
}
52-
}
53-
5429
dependencies {
5530
// To change the versions see the gradle.properties file
5631
minecraft "com.mojang:minecraft:${project.minecraft_version}"
@@ -70,53 +45,16 @@ dependencies {
7045
modImplementation "com.google.code.findbugs:jsr305:3.0.2"
7146
}
7247

73-
loom {
74-
accessWidenerPath = file("src/main/resources/wurst.accesswidener")
75-
}
76-
77-
configurations {
78-
productionRuntime {
79-
extendsFrom configurations.minecraftLibraries
80-
extendsFrom configurations.loaderLibraries
81-
extendsFrom configurations.minecraftRuntimeLibraries
82-
}
83-
}
84-
85-
dependencies {
86-
productionRuntime "net.fabricmc:fabric-loader:${project.loader_version}"
87-
productionRuntime "net.fabricmc:intermediary:${project.minecraft_version}"
48+
fabricApi.configureTests {
49+
createSourceSet = true
50+
enableGameTests = false
51+
enableClientGameTests = true
52+
modId = "wurst_testmod"
53+
username = "Wurst-Bot"
8854
}
8955

90-
import net.fabricmc.loom.util.Platform
91-
tasks.register('runEndToEndTest', JavaExec) {
92-
dependsOn remapJar, downloadAssets
93-
classpath.from configurations.productionRuntime
94-
mainClass = "net.fabricmc.loader.impl.launch.knot.KnotClient"
95-
workingDir = file("run")
96-
97-
doFirst {
98-
classpath.from loom.minecraftProvider.minecraftClientJar
99-
workingDir.mkdirs()
100-
101-
args(
102-
"--assetIndex", loom.minecraftProvider.versionInfo.assetIndex().fabricId(loom.minecraftProvider.minecraftVersion()),
103-
"--assetsDir", new File(loom.files.userCache, "assets").absolutePath,
104-
"--gameDir", workingDir.absolutePath
105-
)
106-
107-
if (Platform.CURRENT.operatingSystem.isMacOS()) {
108-
jvmArgs("-XstartOnFirstThread")
109-
}
110-
111-
jvmArgs(
112-
"-Dfabric.addMods=${configurations.modImplementation.find { it.name.contains('fabric-api') }.absolutePath}${File.pathSeparator}${remapJar.archiveFile.get().asFile.absolutePath}",
113-
"-Dwurst.e2eTest",
114-
"-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail",
115-
"-Dfabric-tag-conventions-v1.legacyTagWarning=fail",
116-
"-Dmixin.debug.verify=true",
117-
"-Dmixin.debug.countInjections=true"
118-
)
119-
}
56+
loom {
57+
accessWidenerPath = file("src/main/resources/wurst.accesswidener")
12058
}
12159

12260
processResources {
@@ -164,13 +102,13 @@ spotless {
164102
eclipse().configFile(file("codestyle/formatter.xml"))
165103
}
166104
format("licenseHeader") {
167-
target("src/*/java/**/*.java", "src/test/java/**/*.java")
105+
target("src/*/java/**/*.java")
168106
def header_file = file("codestyle/license_header.txt")
169107
def delimiter = LicenseHeaderStep.DEFAULT_JAVA_HEADER_DELIMITER
170108
licenseHeaderFile(header_file, delimiter).updateYearWithLatest(true)
171109
}
172110
json {
173-
target "src/**/*.json"
111+
target("src/**/*.json", "src/**/*.mcmeta")
174112
gson().indentWithSpaces(2).version("2.11.0")
175113
}
176114
}

0 commit comments

Comments
 (0)