-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtest
More file actions
executable file
·80 lines (67 loc) · 2.87 KB
/
Copy pathtest
File metadata and controls
executable file
·80 lines (67 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
set -euox pipefail
if command -v podman >/dev/null 2>&1; then
CONTAINER=podman
VOL_SUFFIX=:Z
else
CONTAINER=docker
VOL_SUFFIX=
fi
cleanup() {
if [ -n "${LOGS_PID:-}" ]; then
kill "$LOGS_PID" 2>/dev/null || true
fi
if [ "$CONTAINER" = podman ]; then
$CONTAINER rm -f -t=1 storeys 2>/dev/null || true
else
$CONTAINER rm -f storeys 2>/dev/null || true
fi
}
trap cleanup EXIT
if [ "$CONTAINER" = podman ]; then
$CONTAINER rm -f -t=1 storeys || true
else
$CONTAINER rm -f storeys || true
fi
./make
# Delete the stuff which the previous run of the tests created
rm -f minecraft-server-test-data/config/storeys/workspace/a01e3843-e521-3998-958a-f459800e4d11
rm -f minecraft-server-test-data/config/storeys/new-scripts/a01e3843-e521-3998-958a-f459800e4d11
# Sponge's download endpoint used by itzg/minecraft-server is broken; fetch the jar directly.
SPONGE_JAR=minecraft-server-test-data/spongevanilla-1.16.5-8.2.0.jar
if ! file "$SPONGE_JAR" 2>/dev/null | grep -qE 'Java archive|Zip archive'; then
rm -f minecraft-server-test-data/spongevanilla*.jar
curl -fsSL \
"https://repo.spongepowered.org/repository/maven-releases/org/spongepowered/spongevanilla/1.16.5-8.2.0/spongevanilla-1.16.5-8.2.0-universal.jar" \
-o "$SPONGE_JAR"
fi
$CONTAINER run --name storeys --detach --rm \
-e WORLD=/data/world-init \
-e SPONGEVERSION=1.16.5-8.2.0 \
-e ONLINE_MODE=FALSE \
-v $PWD/minecraft-server-test-data:/data$VOL_SUFFIX -e UID=0 -e GID=0 \
-p 25565:25565 -p 8080:8080 -p 7070:7070 minecraft-storeys-maker
$CONTAINER logs -f storeys &
LOGS_PID=$!
RETRIES=90
until [ "$($CONTAINER inspect --format='{{.State.Health.Status}}' storeys 2>/dev/null)" = healthy ]; 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
# Playwright does not yet support Ubuntu 26.04; use 24.04 deps until it does.
$CONTAINER run --network host --rm -e PLAYWRIGHT_HOST_PLATFORM_OVERRIDE=ubuntu24.04-x64 \
-v $PWD/test-mineflayer:/project$VOL_SUFFIX minecraft-storeys-maker-build \
bash -c "npm install && npx playwright install-deps chromium && npx playwright install chromium && npm test"
# 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`),
# and that (somewhat counter intuitively) will actually run as your unprivileged user on the host,
# see https://github.com/itzg/docker-minecraft-server#running-as-alternate-usergroup-id
# and https://github.com/containers/podman/blob/v2.2.1/docs/tutorials/rootless_tutorial.md#using-volumes.
# TODO HOW-TO --userns keep-id
# NOT --uidmap=0:100000:65536 --uidmap=1000:100000:65536 --gidmap=1000:100000:65536 --gidmap=0:100000:65536
# NOT --userns=host --user=$(id -un):$(id -gn)