Skip to content
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

initial version of the mineflayer based npm test #348

Merged
merged 3 commits into from
Apr 24, 2022
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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ENV ENABLE_RCON=false
ENV MOTD="\u00A7a\u00A7l/make\u00A7r your \u00A7bown\u00A7r Plugins/Mods, \u00A7l\u00A76with Scratch\!"
EXPOSE 25565 25575 7070 8080
ENTRYPOINT [ "/data-init/start-custom" ]
HEALTHCHECK --start-period=1m --timeout=3s --interval=17s --retries=1 CMD mc-health

# TODO When https://github.com/itzg/docker-minecraft-server/issues/1449,
# then "ENV ICON=/data-init/server-icon.png", but until then that's in the start-custom
1 change: 1 addition & 0 deletions Dockerfile-local
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ENV ENABLE_RCON=false
ENV MOTD="\u00A7a\u00A7l/make\u00A7r your \u00A7bown\u00A7r Plugins/Mods, \u00A7l\u00A76with Scratch\!"
EXPOSE 25565 25575 7070 8080
ENTRYPOINT [ "/data-init/start-custom" ]
HEALTHCHECK --start-period=1m --timeout=3s --interval=17s --retries=1 CMD mc-health

# TODO When https://github.com/itzg/docker-minecraft-server/issues/1449,
# then "ENV ICON=/data-init/server-icon.png", but until then that's in the start-custom
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include 'test-utils', 'engine', 'api', 'storeys', 'web', 'scratch3'
include 'test-utils', 'engine', 'api', 'storeys', 'web', 'scratch3', 'test-mineflayer'
vorburger marked this conversation as resolved.
Show resolved Hide resolved

rootProject.name = 'minecraft-storeys-maker'
28 changes: 21 additions & 7 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,32 @@
set -euox pipefail

# https://github.com/OASIS-learn-study/minecraft-storeys-maker#build-it
# NB --format=docker because the "oci" default looses the mc-health HEALTHCHECK of the parent image
./gradlew build
podman build -f Dockerfile-local -t minecraft-storeys-maker .
podman run -it --rm --name storeys \
-e OPS=73551f35-7acb-45c0-bc65-8083c53eec69,fb79c1a9-72bd-34dc-9775-c2ac868d7ccf \
podman build -f Dockerfile-local --format=docker -t minecraft-storeys-maker .

podman stop --time 7 storeys || true

podman run --name storeys --detach --rm \
-e ONLINE_MODE=FALSE \
-v $PWD/minecraft-server-test-data:/data:Z -e UID=0 -e GID=0 \
-p 25565:25565 -p 8080:8080 -p 7070:7070 minecraft-storeys-maker

# TODO for PR #348 with mineflayer: -e ONLINE_MODE=FALSE \
# BUT this requires LuckPerms integration first (because OPS won't work anymore, nor Mineflayer)
podman logs -f storeys &

RETRIES=30
until podman healthcheck run storeys; do
RETRIES=$(($RETRIES - 1))
if [ $RETRIES -eq 0 ]; then
echo "Minecraft container failed to become healthy, giving up now"
exit 1
fi
sleep 1
done

./gradlew test-mineflayer:npmTest

# The `OPS` with your Minecraft ID is required because the command requires permission;
# alternatively [use permissions](https://github.com/OASIS-learn-study/minecraft-storeys-maker/issues/276).
podman stop storeys

# Note that `-e UID=0 -e GID=0` makes `itzg/minecraft-server`'s processes run as `root`
# (instead of its default UID/GID `1000` which is hard-coded in its `setup-user.sh`),
Expand Down
22 changes: 22 additions & 0 deletions test-mineflayer/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id "com.github.node-gradle.node" version "3.2.1"
}

node {
// https://github.com/srs/gradle-node-plugin/blob/master/docs/node.md#configuring-the-plugin
version = '16.0.0'
npmVersion = '7.24.0'
download = true
}

task npmInstallDep(type: NpmTask, dependsOn: 'npmSetup') {
inputs.file('package.json')
outputs.upToDateWhen { file('node_modules').exists() }

npmCommand = ['install']
}

task npmTest(type: NpmTask, dependsOn: 'npmInstallDep') {
args = ['test']
}

Loading