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
50 changes: 50 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: E2E

on:
pull_request:
workflow_dispatch:

# Supersede an in-flight run when the same pull request is pushed to again, so
# a burst of commits does not queue duplicate server boots.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Check out
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'

# The unit suite already ran in Tests on this commit.
- name: Build the plugin jar
run: mvn -B clean package -DskipTests

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Run the end-to-end suite
run: ./gradlew plugwrightTest --no-daemon

- name: Upload the server logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-server-logs
path: run/logs/
if-no-files-found: warn
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,11 @@ buildNumber.properties

# Common working directory
run/

# End-to-end suite build output.
.gradle/
src/test/e2e/node_modules/
src/test/e2e/dist/

# The blanket *.jar rule above would otherwise swallow the wrapper.
!gradle/wrapper/gradle-wrapper.jar
59 changes: 59 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Gradle is the end-to-end test runner and nothing else. Maven builds the jar;
// useExternalPluginsOnly stops Plugwright looking for a Gradle jar task.
plugins {
id("io.github.drownek.plugwright") version "2.0.3"
}

// The shade plugin also leaves original-SetHomesTwo-*.jar in target/, and jars
// from earlier versions linger until mvn clean, so take the newest match.
fun newestPluginJar(): File {
val jars = file("target")
.listFiles { f -> f.isFile && f.name.startsWith("SetHomesTwo-") && f.name.endsWith(".jar") }
?.sortedByDescending { it.lastModified() }
.orEmpty()
if (jars.isEmpty()) {
throw GradleException("No SetHomesTwo-*.jar found in target/. Run: mvn package")
}
return jars.first()
}

plugwright {
minecraftVersion.set("1.21.11")
acceptEula.set(true)
testsDir.set(file("src/test/e2e"))
useExternalPluginsOnly.set(true)

// Never report to the public bStats dashboard from a server we run.
jvmArgs.set(listOf("-Xmx2G", "-Dsethomestwo.metrics.disabled=true"))

// CI installs Node itself; a workstation may have none.
downloadNode.set(System.getenv("CI") != "true")

writeFiles {
file(
"plugins/SetHomesTwo/config.yml",
"""
inventoryTitle: "E2E homes"
maxHomeEnabled: false
delay: 0
cancelOnMove: false
teleportSafety: false
checkForUpdates: false
debugLevel: "info"
permissions:
sh2.player: op
""".trimIndent()
)
}
}

// Lazy, so an unbuilt target/ fails when the suite runs rather than on every
// Gradle command.
tasks.named<me.drownek.plugwright.PlugwrightTestTask>("plugwrightTest") {
pluginJar.set(providers.provider { newestPluginJar() })
dependsOn("plugwrightClean")
}

tasks.named<me.drownek.plugwright.PlugwrightRunTask>("plugwrightRunServer") {
pluginJar.set(providers.provider { newestPluginJar() })
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
252 changes: 252 additions & 0 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading