-
Notifications
You must be signed in to change notification settings - Fork 10
/
test
executable file
·54 lines (44 loc) · 2.06 KB
/
test
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
#!/usr/bin/env bash
set -euox pipefail
docker rm -f -t=1 storeys || true
./make
# Delete the stuff which the previous run of the tests created
rm -f minecraft-server-test-data/config/storeys-web/workspace/a01e3843-e521-3998-958a-f459800e4d11
rm -f minecraft-server-test-data/config/storeys-web/new-scripts/a01e3843-e521-3998-958a-f459800e4d11
docker run --name storeys --detach --rm \
-e WORLD=/data/world-init \
-e OPS=5153e34b-c326-3040-ab45-048f8f35eb13,73551f35-7acb-45c0-bc65-8083c53eec69,fb79c1a9-72bd-34dc-9775-c2ac868d7ccf \
-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
docker logs -f storeys &
RETRIES=90
if [ $(command -v podman) ]; then
until docker 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
else
until [[ $(docker inspect --format='{{json .State.Health.Status}}' storeys) =~ 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
fi
docker run --network host --rm -v $PWD/test-mineflayer:/project:Z minecraft-storeys-maker-build bash -c "npm install && 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)