Skip to content

Commit

Permalink
Add basic end-to-end test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Jan 5, 2025
1 parent 4aacb18 commit ee3af0b
Show file tree
Hide file tree
Showing 6 changed files with 636 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,55 @@ jobs:
echo "- [$filename]($url)" >> $GITHUB_STEP_SUMMARY
done
echo "</details>" >> $GITHUB_STEP_SUMMARY
- name: Run the mod and take screenshots
uses: modmuss50/xvfb-action@c56c7da0c8fc9a7cb5df2e50dd2a43a80b64c5cb
with:
run: ./gradlew runEndToEndTest --stacktrace --warning-mode=fail

# Needed because the screenshot gallery won't be created on pull requests.
# Also useful if Imgur uploads fail.
- name: Upload Test Screenshots.zip artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: Test Screenshots
path: run/screenshots

- name: Create test screenshot gallery
if: ${{ env.IMGUR_CLIENT_ID && (success() || failure()) }}
# Imgur uploads randomly fail sometimes, probably because of the low rate limit.
# TODO: Find a better place to upload the screenshots.
continue-on-error: true
run: |
echo "<details open>" >> $GITHUB_STEP_SUMMARY
echo "<summary>📸 Test Screenshots</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
for img in run/screenshots/*.png; do
if [ -f "$img" ]; then
filename=$(basename "$img")
name_without_ext="${filename%.*}"
# Upload to Imgur
response=$(curl -s -X POST \
-H "Authorization: Client-ID $IMGUR_CLIENT_ID" \
-F "image=@$img" \
https://api.imgur.com/3/image)
# Extract the URL from the response
url=$(echo $response | grep -o '"link":"[^"]*"' | cut -d'"' -f4)
if [ ! -z "$url" ]; then
# Convert underscores to spaces and capitalize first letter of each word
title=$(echo "$name_without_ext" | tr '_' ' ' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
echo "### $title" >> $GITHUB_STEP_SUMMARY
echo "![${name_without_ext}]($url)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
else
echo "Failed to upload $filename" >> $GITHUB_STEP_SUMMARY
echo "Imgur upload response for $filename: $response"
fi
fi
done
echo "</details>" >> $GITHUB_STEP_SUMMARY
49 changes: 49 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,55 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}

loom {
accessWidenerPath = file("src/main/resources/wi-zoom.accesswidener")
}

configurations {
productionRuntime {
extendsFrom configurations.minecraftLibraries
extendsFrom configurations.loaderLibraries
extendsFrom configurations.minecraftRuntimeLibraries
}
}

dependencies {
productionRuntime "net.fabricmc:fabric-loader:${project.loader_version}"
productionRuntime "net.fabricmc:intermediary:${project.minecraft_version}"
}

import net.fabricmc.loom.util.Platform
tasks.register('runEndToEndTest', JavaExec) {
dependsOn remapJar, downloadAssets
classpath.from configurations.productionRuntime
mainClass = "net.fabricmc.loader.impl.launch.knot.KnotClient"
workingDir = file("run")

doFirst {
classpath.from loom.minecraftProvider.minecraftClientJar
workingDir.mkdirs()

args(
"--assetIndex", loom.minecraftProvider.versionInfo.assetIndex().fabricId(loom.minecraftProvider.minecraftVersion()),
"--assetsDir", new File(loom.files.userCache, "assets").absolutePath,
"--gameDir", workingDir.absolutePath
)

if (Platform.CURRENT.operatingSystem.isMacOS()) {
jvmArgs("-XstartOnFirstThread")
}

jvmArgs(
"-Dfabric.addMods=${configurations.modImplementation.find { it.name.contains('fabric-api') }.absolutePath}${File.pathSeparator}${remapJar.archiveFile.get().asFile.absolutePath}",
"-Dwi_zoom.e2eTest",
"-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail",
"-Dfabric-tag-conventions-v1.legacyTagWarning=fail",
"-Dmixin.debug.verify=true",
"-Dmixin.debug.countInjections=true"
)
}
}

processResources {
inputs.property "version", project.version

Expand Down
Loading

0 comments on commit ee3af0b

Please sign in to comment.