Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ jobs:
steps:
- uses: actions/checkout@v4

# Set up JDK 17 for Fabric 1.20.x builds (Gradle toolchain will use this)
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "temurin"

# Set up JDK 21 as the primary JDK
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
Expand All @@ -46,6 +54,10 @@ jobs:
STORAGE_TYPE: ${{ matrix.storageType }}
run: ./gradlew build --build-cache --info

# Build all Fabric versions
- name: Build all Fabric versions
run: ./gradlew :fabric:1.20.1:remapJar :fabric:1.21.1:remapJar :fabric:1.21.4:remapJar --build-cache

- name: Publish to Maven Central
# only publish once
if: github.ref == 'refs/heads/master' && matrix.java == '21' && matrix.storageType == 'mariadb'
Expand Down
50 changes: 47 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,35 @@ jobs:
fail-fast: false
matrix:
include:
# Bukkit/Paper
- platform: Bukkit
task: testBukkit
build_task: ":BanManagerBukkit:shadowJar"
compose_dir: platforms/bukkit
- platform: Fabric
task: testFabric
build_task: ":BanManagerFabric:remapJar"
# Fabric 1.20.1 (legacy modded, Java 17)
- platform: Fabric-1.20.1
task: testFabric_1_20_1
build_task: ":fabric:1.20.1:remapJar"
compose_dir: platforms/fabric
mc_version: "1.20.1"
java_image: "java17"
fabric_loader: "0.16.10"
# Fabric 1.21.1 (stable 1.21, Java 21)
- platform: Fabric-1.21.1
task: testFabric_1_21_1
build_task: ":fabric:1.21.1:remapJar"
compose_dir: platforms/fabric
mc_version: "1.21.1"
java_image: "java21"
fabric_loader: "0.16.9"
# Fabric 1.21.4 (current latest, Java 21)
- platform: Fabric-1.21.4
task: testFabric_1_21_4
build_task: ":fabric:1.21.4:remapJar"
compose_dir: platforms/fabric
mc_version: "1.21.4"
java_image: "java21"
fabric_loader: "0.16.9"

steps:
- uses: actions/checkout@v4
Expand All @@ -33,6 +54,17 @@ jobs:
java-version: 21
distribution: "temurin"

# Also set up JDK 17 for Fabric 1.20.x builds
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "temurin"

# Ensure JDK 21 is the default
- name: Set JDK 21 as default
run: echo "JAVA_HOME=$JAVA_HOME_21_X64" >> $GITHUB_ENV

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
Expand Down Expand Up @@ -82,12 +114,20 @@ jobs:
- name: Run E2E tests
run: ./gradlew :BanManagerE2E:${{ matrix.task }}
timeout-minutes: 15
env:
MC_VERSION: ${{ matrix.mc_version }}
JAVA_IMAGE: ${{ matrix.java_image }}
FABRIC_LOADER: ${{ matrix.fabric_loader }}

- name: Collect logs on failure
if: failure()
working-directory: e2e/${{ matrix.compose_dir }}
run: |
docker compose logs > ../../e2e-logs-${{ matrix.platform }}.txt 2>&1 || true
env:
MC_VERSION: ${{ matrix.mc_version }}
JAVA_IMAGE: ${{ matrix.java_image }}
FABRIC_LOADER: ${{ matrix.fabric_loader }}

- name: Upload logs on failure
if: failure()
Expand All @@ -101,3 +141,7 @@ jobs:
if: always()
working-directory: e2e/${{ matrix.compose_dir }}
run: docker compose down -v || true
env:
MC_VERSION: ${{ matrix.mc_version }}
JAVA_IMAGE: ${{ matrix.java_image }}
FABRIC_LOADER: ${{ matrix.fabric_loader }}
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ dependencies {
implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:9.0.0-beta4")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:5.2.5")
implementation("org.spongepowered:spongegradle-plugin-development:2.3.0")
implementation("fabric-loom:fabric-loom.gradle.plugin:1.9-SNAPSHOT")
implementation("fabric-loom:fabric-loom.gradle.plugin:1.9.2")
}
8 changes: 6 additions & 2 deletions buildSrc/src/main/kotlin/CommonConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ fun Project.applyCommonConfiguration() {
}
}

// Only set Java 1.8 for non-Fabric modules
// Fabric uses toolchain configuration in its build.gradle.kts
plugins.withId("java") {
the<JavaPluginExtension>().setSourceCompatibility("1.8")
the<JavaPluginExtension>().setTargetCompatibility("1.8")
if (!plugins.hasPlugin("fabric-loom")) {
the<JavaPluginExtension>().setSourceCompatibility("1.8")
the<JavaPluginExtension>().setTargetCompatibility("1.8")
}
}
}
112 changes: 105 additions & 7 deletions e2e/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ plugins {

description = "E2E tests for BanManager using Docker and Mineflayer"

// Fabric version configurations
data class FabricVersion(val mcVersion: String, val javaImage: String, val fabricLoader: String)

val fabricVersions = listOf(
FabricVersion("1.20.1", "java17", "0.16.10"),
FabricVersion("1.21.1", "java21", "0.16.9"),
FabricVersion("1.21.4", "java21", "0.16.9")
)

// Helper function to create platform test tasks
fun createPlatformTestTask(
taskName: String,
platformDir: String,
pluginTask: String,
description: String
description: String,
environment: Map<String, String> = emptyMap()
) {
tasks.register<Exec>(taskName) {
group = "verification"
Expand All @@ -18,6 +28,12 @@ fun createPlatformTestTask(
dependsOn(pluginTask)

workingDir = file("platforms/$platformDir")

// Set environment variables for docker-compose
environment.forEach { (key, value) ->
environment(key, value)
}

commandLine(
"docker", "compose", "up",
"--build",
Expand All @@ -43,14 +59,47 @@ createPlatformTestTask(
"Run Bukkit E2E tests in Docker"
)

// Fabric E2E tests
// Fabric version-specific E2E tests
fabricVersions.forEach { version ->
val versionSuffix = version.mcVersion.replace(".", "_")

createPlatformTestTask(
"testFabric_${versionSuffix}",
"fabric",
":fabric:${version.mcVersion}:remapJar",
"Run Fabric ${version.mcVersion} E2E tests in Docker",
mapOf(
"MC_VERSION" to version.mcVersion,
"JAVA_IMAGE" to version.javaImage,
"FABRIC_LOADER" to version.fabricLoader
)
)
}

// Fabric E2E tests - runs latest version (1.21.4)
createPlatformTestTask(
"testFabric",
"fabric",
":BanManagerFabric:remapJar",
"Run Fabric E2E tests in Docker"
":fabric:1.21.4:remapJar",
"Run Fabric E2E tests in Docker (latest: 1.21.4)",
mapOf(
"MC_VERSION" to "1.21.4",
"JAVA_IMAGE" to "java21",
"FABRIC_LOADER" to "0.16.9"
)
)

// Test all Fabric versions
tasks.register("testFabricAll") {
group = "verification"
description = "Run Fabric E2E tests for all supported MC versions"

fabricVersions.forEach { version ->
val versionSuffix = version.mcVersion.replace(".", "_")
dependsOn("testFabric_${versionSuffix}")
}
}

tasks.register("testAll") {
group = "verification"
description = "Run E2E tests for all platforms"
Expand Down Expand Up @@ -93,14 +142,63 @@ tasks.register<Exec>("logsBukkit") {
commandLine("docker", "compose", "logs", "-f", "paper")
}

// Helper tasks for Fabric debugging
// Helper tasks for Fabric debugging (version-aware)
// Helper function to create versioned Fabric debug tasks
fun createFabricDebugTasks(mcVersion: String, javaImage: String, fabricLoader: String) {
val versionSuffix = mcVersion.replace(".", "_")
val envVars = mapOf(
"MC_VERSION" to mcVersion,
"JAVA_IMAGE" to javaImage,
"FABRIC_LOADER" to fabricLoader
)

tasks.register<Exec>("startFabric_${versionSuffix}") {
group = "verification"
description = "Start the Fabric $mcVersion test server without running tests (for debugging)"

dependsOn(":fabric:${mcVersion}:remapJar")

workingDir = file("platforms/fabric")
envVars.forEach { (key, value) -> environment(key, value) }
commandLine("docker", "compose", "up", "-d", "mariadb", "fabric")
}

tasks.register<Exec>("stopFabric_${versionSuffix}") {
group = "verification"
description = "Stop the Fabric $mcVersion test server"

workingDir = file("platforms/fabric")
envVars.forEach { (key, value) -> environment(key, value) }
commandLine("docker", "compose", "down", "-v")
isIgnoreExitValue = true
}

tasks.register<Exec>("logsFabric_${versionSuffix}") {
group = "verification"
description = "Show Fabric $mcVersion server logs"

workingDir = file("platforms/fabric")
envVars.forEach { (key, value) -> environment(key, value) }
commandLine("docker", "compose", "logs", "-f", "fabric")
}
}

// Create debug tasks for each Fabric version
fabricVersions.forEach { version ->
createFabricDebugTasks(version.mcVersion, version.javaImage, version.fabricLoader)
}

// Default Fabric debug tasks (latest version)
tasks.register<Exec>("startFabric") {
group = "verification"
description = "Start the Fabric test server without running tests (for debugging)"
description = "Start the Fabric test server without running tests (for debugging) - latest: 1.21.4"

dependsOn(":BanManagerFabric:remapJar")
dependsOn(":fabric:1.21.4:remapJar")

workingDir = file("platforms/fabric")
environment("MC_VERSION", "1.21.4")
environment("JAVA_IMAGE", "java21")
environment("FABRIC_LOADER", "0.16.9")
commandLine("docker", "compose", "up", "-d", "mariadb", "fabric")
}

Expand Down
22 changes: 16 additions & 6 deletions e2e/platforms/fabric/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Parameterized Fabric E2E testing
# Environment variables:
# MC_VERSION: Minecraft version (default: 1.21.4)
# JAVA_IMAGE: Java image tag (default: java21, use java17 for 1.20.x)
# FABRIC_LOADER: Fabric loader version (default: 0.16.9)

services:
mariadb:
image: mariadb:10.11
Expand All @@ -15,12 +21,12 @@ services:
- banmanager

fabric:
image: itzg/minecraft-server:java21
image: itzg/minecraft-server:${JAVA_IMAGE:-java21}
environment:
EULA: "TRUE"
TYPE: "FABRIC"
VERSION: "1.21.4"
FABRIC_LOADER_VERSION: "0.16.9"
VERSION: "${MC_VERSION:-1.21.4}"
FABRIC_LOADER_VERSION: "${FABRIC_LOADER:-0.16.9}"
ONLINE_MODE: "false"
ENABLE_RCON: "true"
RCON_PASSWORD: "testing"
Expand All @@ -43,11 +49,12 @@ services:
COPY_CONFIG_DEST: "/data/config/banmanager"
volumes:
# Mount the mod JAR to a source directory (will be copied on startup)
- ../../../fabric/build/libs/BanManagerFabric.jar:/mods-src/BanManager.jar:ro
# Uses versioned jar name from Stonecutter build
- ../../../fabric/versions/${MC_VERSION:-1.21.4}/build/libs/BanManagerFabric-mc${MC_VERSION:-1.21.4}.jar:/mods-src/BanManager.jar:ro
# Mount the plugin config source (will be copied on startup)
- ./configs:/config:ro
# Cache server data between runs (Fabric JAR, world data)
- fabric-data:/data
- fabric-data-${MC_VERSION:-1.21.4}:/data
ports:
- "25565:25565"
- "25575:25575"
Expand Down Expand Up @@ -76,6 +83,7 @@ services:
RCON_HOST: fabric
RCON_PORT: 25575
RCON_PASSWORD: testing
MC_VERSION: "${MC_VERSION:-1.21.4}"
networks:
- banmanager

Expand All @@ -84,4 +92,6 @@ networks:
driver: bridge

volumes:
fabric-data:
fabric-data-1.20.1:
fabric-data-1.21.1:
fabric-data-1.21.4:
Loading