Skip to content

GH-1051 Add integrational tests #1051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
99 changes: 99 additions & 0 deletions .github/workflows/test-mc-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: MC Plugin Compatibility Test

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]

jobs:
test-minecraft-versions:
runs-on: self-hosted
strategy:
fail-fast: false
matrix:
mc_version: [1.18.2, 1.19.4, 1.20.6, 1.21.7]

env:
MC_VERSION: ${{ matrix.mc_version }}
PLUGIN_GLOB: "eternalcore-plugin/build/libs/EternalCore*.jar"
MC_PORT: 25560

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 21

- name: Make gradlew executable
run: chmod +x gradlew

- name: Build the plugin JAR
run: ./gradlew clean eternalcore-plugin:shadowJar

- name: Find plugin JAR
id: find-jar
run: |
PLUGIN_JAR=$(find ./eternalcore-plugin/build/libs -name 'EternalCore*.jar' | head -n1)
echo "PLUGIN_JAR=$PLUGIN_JAR" >> $GITHUB_ENV
if [ -z "$PLUGIN_JAR" ]; then
echo "❌ Plugin JAR not found!"
exit 1
fi

- name: Get latest PaperMC build number
id: get_build_number
run: |
BUILD_NUMBER=$(curl -s "https://api.papermc.io/v2/projects/paper/versions/${MC_VERSION}/builds" \
| jq '.builds | max_by(.build) | .build')
echo "build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT

- name: Setup PaperMC server for $MC_VERSION
run: |
mkdir mc-server
cd mc-server
wget "https://api.papermc.io/v2/projects/paper/versions/${MC_VERSION}/builds/${{ steps.get_build_number.outputs.build_number }}/downloads/paper-${MC_VERSION}-${{ steps.get_build_number.outputs.build_number }}.jar" \
-O paper.jar
mkdir plugins
cp "../$PLUGIN_JAR" plugins/

- name: Agree to EULA
run: echo "eula=true" > mc-server/eula.txt

- name: Configure server.properties
run: |
cat > mc-server/server.properties <<EOF
server-port=${MC_PORT}
allow-nether=false
level-type=FLAT
max-world-size=16
EOF

- name: Configure bukkit.yml
run: |
cat > mc-server/bukkit.yml <<EOF
settings:
allow-end: false
EOF

- name: Run server and fail on errors
working-directory: mc-server
run: |
java -Xmx1G -jar paper.jar nogui > server.log 2>&1 &
PID=$!
echo "Started MC ${MC_VERSION} on port ${MC_PORT} (PID=${PID})"
sleep 60
kill $PID || true
wait $PID || true
if grep -iE 'error|exception|failed' server.log; then
echo "❌ Errors detected in server.log"
cat server.log
exit 1
else
echo "✅ No errors detected for MC ${MC_VERSION}"
fi
Loading