Skip to content

Commit 649d614

Browse files
committed
fix(build): add -DmcVersion to build.yml for correct 26.x Loom selection
- Add -DmcVersion to PROP_ARGS in build.yml (critical for 26.x builds) - Rename src/mc-1.20.0-1.20.3 -> src/mc-1.20-1.20.3 to match versions.json - Rename src/mc-1.20.5 -> src/mc-1.20.5-1.20.6 to include 1.20.6 - Fix instances key in versions.json: 1.20.0 -> 1.20 - Clean up dead jq filter code in release.yml - Add game tests for all 6 missing version groups (1.20.x, 1.21.5+) - Add optional run-tests input to multi-release workflow
1 parent d96082c commit 649d614

31 files changed

Lines changed: 2579 additions & 17 deletions

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
fi
5353
5454
echo "Building $VER..."
55-
PROP_ARGS=(-PmcVersion="$MC_SRC" -Pminecraft_version="$MC_VER" -Pfabric_api_version="$FABRIC_API")
55+
PROP_ARGS=(-DmcVersion="$MC_SRC" -PmcVersion="$MC_SRC" -Pminecraft_version="$MC_VER" -Pfabric_api_version="$FABRIC_API")
5656
[ -n "$YARN" ] && PROP_ARGS+=(-Pyarn_mappings="$YARN")
5757
[ -n "$LOADER" ] && PROP_ARGS+=(-Ploader_version="$LOADER")
5858

.github/workflows/release.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
type: string
99
required: false
1010
default: ""
11+
run-tests:
12+
description: "Run game tests after build"
13+
type: boolean
14+
required: false
15+
default: false
1116

1217
permissions:
1318
contents: write
@@ -21,15 +26,6 @@ jobs:
2126
- uses: actions/checkout@v4
2227
- id: gen_matrix
2328
run: |
24-
INCLUDE=$(jq -c '[.versions[] | {
25-
version: .version,
26-
mc_src: (.mcVersion // .version),
27-
mc_ver: .minecraft_version,
28-
fabric_api: .fabric_api_version,
29-
yarn: (.yarn_mappings // ""),
30-
loader: (.loader_version // "")
31-
}]' versions.json | jq -c '[.[] | select("src/mc-" + .mc_src as $d | $d | type == "string")]' 2>/dev/null || echo "[]")
32-
# Fallback: filter by directory existence
3329
ENTRIES=$(jq -c '[.versions[] | {version, mc_src: (.mcVersion // .version), mc_ver: .minecraft_version, fabric_api: .fabric_api_version, yarn: (.yarn_mappings // ""), loader: (.loader_version // "")}]' versions.json)
3430
FILTERED="[]"
3531
while read -r entry; do
@@ -75,6 +71,14 @@ jobs:
7571
[ -n "${{ matrix.loader }}" ] && PROPS+=(-Ploader_version="${{ matrix.loader }}")
7672
./gradlew clean build "${PROPS[@]}" --no-daemon -q
7773
74+
- name: Run game tests
75+
if: steps.check_src.outputs.exists == 'true' && github.event.inputs.run-tests == 'true' && !startsWith(matrix.mc_src, '26')
76+
run: |
77+
PROPS=(-DmcVersion="${{ matrix.mc_src }}" -PmcVersion="${{ matrix.mc_src }}" -Pminecraft_version="${{ matrix.mc_ver }}" -Pfabric_api_version="${{ matrix.fabric_api }}" -PenableGameTests=true)
78+
[ -n "${{ matrix.yarn }}" ] && PROPS+=(-Pyarn_mappings="${{ matrix.yarn }}")
79+
[ -n "${{ matrix.loader }}" ] && PROPS+=(-Ploader_version="${{ matrix.loader }}")
80+
./gradlew runGameTest "${PROPS[@]}" --no-daemon -q
81+
7882
- name: Get mod version
7983
if: steps.check_src.outputs.exists == 'true'
8084
id: mod_info
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
package stackabletools
2+
3+
import java.lang.reflect.Method
4+
5+
import net.minecraft.test.GameTest
6+
import net.minecraft.test.TestContext
7+
import net.minecraft.item.ItemStack
8+
import net.minecraft.item.Items
9+
import net.minecraft.block.Blocks
10+
11+
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest
12+
import stackabletools.StackableToolsUtils
13+
import stackabletools.config.ConfigManager
14+
import stackabletools.config.StackableToolsConfig
15+
import stackabletools.config.StackingCategory
16+
17+
public class StackableToolsGameTest : FabricGameTest {
18+
19+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
20+
public fun testIdenticalToolsCanStack(context: TestContext) {
21+
val pickaxe1 = ItemStack(Items.DIAMOND_PICKAXE, 1)
22+
val pickaxe2 = ItemStack(Items.DIAMOND_PICKAXE, 1)
23+
24+
if (StackableToolsUtils.canStackItems(pickaxe1, pickaxe2)) {
25+
context.complete()
26+
} else {
27+
context.throwGameTestException("Identical diamond pickaxes should be stackable")
28+
}
29+
}
30+
31+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
32+
public fun testDamagedToolsCannotStack(context: TestContext) {
33+
val pickaxe1 = ItemStack(Items.DIAMOND_PICKAXE, 1)
34+
val pickaxe2 = ItemStack(Items.DIAMOND_PICKAXE, 1)
35+
36+
pickaxe2.damage = 5
37+
38+
if (!StackableToolsUtils.canStackItems(pickaxe1, pickaxe2)) {
39+
context.complete()
40+
} else {
41+
context.throwGameTestException("Damaged and undamaged tools should not be stackable")
42+
}
43+
}
44+
45+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
46+
public fun testDifferentItemsCannotStack(context: TestContext) {
47+
val pickaxe = ItemStack(Items.DIAMOND_PICKAXE, 1)
48+
val axe = ItemStack(Items.DIAMOND_AXE, 1)
49+
50+
if (!StackableToolsUtils.canStackItems(pickaxe, axe)) {
51+
context.complete()
52+
} else {
53+
context.throwGameTestException("Different tool types should not be stackable")
54+
}
55+
}
56+
57+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
58+
public fun testEmptyStacksCannotStack(context: TestContext) {
59+
val pickaxe = ItemStack(Items.DIAMOND_PICKAXE, 1)
60+
val empty = ItemStack.EMPTY
61+
62+
if (!StackableToolsUtils.canStackItems(pickaxe, empty)) {
63+
context.complete()
64+
} else {
65+
context.throwGameTestException("Empty stacks should not be stackable")
66+
}
67+
}
68+
69+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
70+
public fun testToolsAreStackableWhenCategoryActive(context: TestContext) {
71+
val pickaxe = ItemStack(Items.DIAMOND_PICKAXE, 1)
72+
73+
if (StackableToolsUtils.isStackableItem(pickaxe)) {
74+
context.complete()
75+
} else {
76+
context.throwGameTestException("Diamond pickaxe should be stackable when tools category is active")
77+
}
78+
}
79+
80+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
81+
public fun testPotionsAreStackableWhenCategoryActive(context: TestContext) {
82+
val potion = ItemStack(Items.POTION, 1)
83+
84+
if (StackableToolsUtils.isStackableItem(potion)) {
85+
context.complete()
86+
} else {
87+
context.throwGameTestException("Potion should be stackable when potions category is active")
88+
}
89+
}
90+
91+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
92+
public fun testEnchantedBooksAreStackable(context: TestContext) {
93+
val enchantedBook = ItemStack(Items.ENCHANTED_BOOK, 1)
94+
95+
if (StackableToolsUtils.isStackableItem(enchantedBook)) {
96+
context.complete()
97+
} else {
98+
context.throwGameTestException("Enchanted book should be stackable")
99+
}
100+
}
101+
102+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
103+
public fun testWeaponsAreStackableWhenCategoryActive(context: TestContext) {
104+
val sword = ItemStack(Items.DIAMOND_SWORD, 1)
105+
106+
if (StackableToolsUtils.isStackableItem(sword)) {
107+
context.complete()
108+
} else {
109+
context.throwGameTestException("Diamond sword should be stackable when weapons category is active")
110+
}
111+
}
112+
113+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
114+
public fun testArmorIsStackableWhenCategoryActive(context: TestContext) {
115+
val helmet = ItemStack(Items.DIAMOND_HELMET, 1)
116+
117+
if (StackableToolsUtils.isStackableItem(helmet)) {
118+
context.complete()
119+
} else {
120+
context.throwGameTestException("Diamond helmet should be stackable when armors category is active")
121+
}
122+
}
123+
124+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
125+
public fun testElytraIsStackableWhenCategoryActive(context: TestContext) {
126+
val elytra = ItemStack(Items.ELYTRA, 1)
127+
128+
if (StackableToolsUtils.isStackableItem(elytra)) {
129+
context.complete()
130+
} else {
131+
context.throwGameTestException("Elytra should be stackable when elytra category is active")
132+
}
133+
}
134+
135+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
136+
public fun testRegularItemsNotStackable(context: TestContext) {
137+
val dirt = ItemStack(Items.DIRT, 1)
138+
139+
if (!StackableToolsUtils.isStackableItem(dirt)) {
140+
context.complete()
141+
} else {
142+
context.throwGameTestException("Dirt should not be stackable by default")
143+
}
144+
}
145+
146+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
147+
public fun testEmptyStackNotStackable(context: TestContext) {
148+
val empty = ItemStack.EMPTY
149+
150+
if (!StackableToolsUtils.isStackableItem(empty)) {
151+
context.complete()
152+
} else {
153+
context.throwGameTestException("Empty stack should not be stackable")
154+
}
155+
}
156+
157+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
158+
public fun testIdenticalSwordsCanStack(context: TestContext) {
159+
val sword1 = ItemStack(Items.DIAMOND_SWORD, 1)
160+
val sword2 = ItemStack(Items.DIAMOND_SWORD, 1)
161+
162+
if (StackableToolsUtils.canStackItems(sword1, sword2)) {
163+
context.complete()
164+
} else {
165+
context.throwGameTestException("Identical swords without damage should be stackable")
166+
}
167+
}
168+
169+
@GameTest(templateName = "fabric-gametest-api-v1:empty")
170+
public fun testDifferentlyDamagedArmorCannotStack(context: TestContext) {
171+
val helmet1 = ItemStack(Items.DIAMOND_HELMET, 1)
172+
val helmet2 = ItemStack(Items.DIAMOND_HELMET, 1)
173+
174+
helmet2.damage = 10
175+
176+
if (!StackableToolsUtils.canStackItems(helmet1, helmet2)) {
177+
context.complete()
178+
} else {
179+
context.throwGameTestException("Armor with different damage levels should not be stackable")
180+
}
181+
}
182+
183+
override fun invokeTestMethod(context: TestContext, method: Method) {
184+
try {
185+
ConfigManager.loadConfig()
186+
method.invoke(this, context)
187+
} catch (e: java.lang.reflect.InvocationTargetException) {
188+
context.throwGameTestException("Test failed: ${e.cause?.message ?: e.cause?.javaClass?.simpleName ?: "Unknown error"}")
189+
} catch (e: Exception) {
190+
context.throwGameTestException("Test failed: ${e.message ?: e.javaClass.simpleName}")
191+
}
192+
}
193+
}

0 commit comments

Comments
 (0)