-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Automated testing * Testing testing - Use 2 spaces for indents yaml - Move setupTestMod to PlatformExtension - Allow specifying the sourceSet for the testMod artifact - Rename things to camelCase - Use rootCompile from transitiveSourceSets for the testMod source sets - Use a blanket remapTestModJar task in the gh actions build * Fail slowly - We want to know the results of both tests regardless * Add workflow dispatch * Shoes should be steel toed, dangerous stuff * Update build.yml * fix modid * Update FlywheelTestModClient.java * add debug logging * fix syntax issues * fix issues * Update build.yml * Add debug logging * more logging * get testmod from correct dir * switch to env var * Why wait? - Immediately audit on client tick * DidObfuscate - Fix RenderSystemMixin on fabric - setShaderFogShape's arguments need to be remapped, but the name of the function should not be. Fortunately mixin allows matching by function name alone * Clever commit title - Change the Fabric mod ID to match Forge - Move "Flywheel Test Mod" to static - Cleanup start/stop messages - Use the client start event on Fabric --------- Co-authored-by: Jozufozu <[email protected]>
- Loading branch information
Showing
10 changed files
with
197 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,85 @@ | ||
name: build | ||
name: Build | ||
|
||
on: [ pull_request, push ] | ||
on: [ workflow_dispatch, pull_request, push ] | ||
|
||
env: | ||
JAVA_VERSION: 17 | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
java: [ | ||
17 # Current Java LTS & minimum supported by Minecraft | ||
] | ||
os: [ ubuntu-latest ] | ||
runs-on: ${{ matrix.os }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Validate Gradle Wrapper | ||
uses: gradle/actions/wrapper-validation@v3 | ||
- name: Gradle Cache | ||
|
||
- name: Setup Java | ||
run: echo "JAVA_HOME=$JAVA_HOME_${{ env.JAVA_VERSION }}_X64" >> "$GITHUB_ENV" | ||
|
||
- name: Loom Cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
.gradle/loom-cache | ||
build/ | ||
key: ${{ runner.os }}-jdk${{ matrix.java }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle.properties', '**/gradle-wrapper.properties', '.github/workflows/build.yml') }} | ||
- name: Setup JDK ${{ matrix.java }} | ||
uses: actions/setup-java@v4 | ||
path: "**/.gradle/loom-cache" | ||
key: "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}" | ||
restore-keys: "${{ runner.os }}-gradle-" | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: ${{ matrix.java }} | ||
- name: Make Gradle Wrapper Executable | ||
if: ${{ runner.os != 'Windows' }} | ||
run: chmod +x ./gradlew | ||
gradle-home-cache-cleanup: true | ||
cache-read-only: ${{ !endsWith(github.ref_name, '/dev') }} | ||
|
||
- name: Validate Gradle Wrapper Integrity | ||
uses: gradle/wrapper-validation-action@v2 | ||
|
||
- name: Build | ||
# doesn't actually publish, as no secrets are passed in, just makes sure that publishing works | ||
run: ./gradlew publish --no-daemon | ||
# Doesn't actually publish, as no secrets are passed in, just makes sure that publishing works | ||
# Also generate the mod jars for the test job | ||
run: ./gradlew remapTestModJar publish --no-daemon | ||
|
||
- name: Capture Build Artifacts | ||
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Artifacts | ||
path: | | ||
common/build/libs/ | ||
fabric/build/libs/ | ||
forge/build/libs/ | ||
common/build/libs/ | ||
fabric/build/libs/ | ||
forge/build/libs/ | ||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
loader: [ forge, fabric ] | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download build artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: Artifacts | ||
|
||
- name: Setup Environment Variables | ||
run: | | ||
echo "MOD_VERSION=$(grep '^mod_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV" | ||
echo "MINECRAFT_VERSION=$(grep '^minecraft_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV" | ||
echo "FABRIC_API_VERSION=$(grep '^fabric_api_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ' | sed 's/+.*//')" >> "$GITHUB_ENV" | ||
- name: Move Test Mod and Flywheel into run/mods | ||
run: | | ||
mkdir -p run/mods | ||
cp ${{ matrix.loader }}/build/libs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}.jar run/mods | ||
cp ${{ matrix.loader }}/build/libs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}-testmod.jar run/mods | ||
# Lock to a specific commit, it would be bad if the tag is re-pushed with unwanted changes | ||
- name: Run the MC client | ||
uses: 3arthqu4ke/mc-runtime-test@e72f8fe1134aabf6fc749a2a8c09bb56dd7d283e | ||
with: | ||
mc: ${{ env.MINECRAFT_VERSION }} | ||
modloader: ${{ matrix.loader }} | ||
regex: .*${{ matrix.loader }}.* | ||
mc-runtime-test: none | ||
java: ${{ env.JAVA_VERSION }} | ||
fabric-api: ${{ matrix.loader == 'fabric' && env.FABRIC_API_VERSION || 'none' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
fabric/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package dev.engine_room.flywheel; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.spongepowered.asm.mixin.MixinEnvironment; | ||
|
||
import net.fabricmc.api.ClientModInitializer; | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
public class FlywheelTestModClient implements ClientModInitializer { | ||
public static final String NAME = "Flywheel Test Mod"; | ||
private static final Logger LOGGER = LoggerFactory.getLogger(NAME); | ||
|
||
@Override | ||
public void onInitializeClient() { | ||
LOGGER.info("Starting {} on EnvType: {}", NAME, FabricLoader.getInstance() | ||
.getEnvironmentType()); | ||
|
||
ClientLifecycleEvents.CLIENT_STARTED.register(client -> { | ||
LOGGER.info("Running mixin audit"); | ||
MixinEnvironment.getCurrentEnvironment() | ||
.audit(); | ||
|
||
LOGGER.info("Stopping client"); | ||
client.stop(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id" : "${mod_id}_testmod", | ||
"name": "${mod_name} Test Mod", | ||
"version": "1.0.0", | ||
"environment": "*", | ||
"license": "${mod_license}", | ||
"entrypoints": { | ||
"client": [ | ||
"dev.engine_room.flywheel.FlywheelTestModClient" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
forge/src/testMod/java/dev/engine_room/flywheel/FlywheelTestModClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package dev.engine_room.flywheel; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.spongepowered.asm.mixin.MixinEnvironment; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.event.TickEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.loading.FMLLoader; | ||
|
||
@Mod("flywheel_testmod") | ||
public class FlywheelTestModClient { | ||
public static final String NAME = "Flywheel Test Mod"; | ||
private static final Logger LOGGER = LoggerFactory.getLogger(NAME); | ||
|
||
public FlywheelTestModClient() { | ||
LOGGER.info("Starting {} on Dist: {}", NAME, FMLLoader.getDist()); | ||
|
||
MinecraftForge.EVENT_BUS.addListener((TickEvent.ClientTickEvent e) -> { | ||
if (e.phase == TickEvent.Phase.END) { | ||
LOGGER.info("Running mixin audit"); | ||
MixinEnvironment.getCurrentEnvironment() | ||
.audit(); | ||
|
||
LOGGER.info("Stopping client"); | ||
Minecraft.getInstance() | ||
.stop(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
modLoader = "javafml" | ||
loaderVersion = "[0,)" | ||
license = "${mod_license}" | ||
|
||
[[mods]] | ||
modId = "${mod_id}_testmod" | ||
version = "1.0.0" | ||
displayName = "${mod_name} Test Mod" |