Skip to content

Commit

Permalink
Add Docker test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Mar 25, 2024
1 parent 64937ea commit 34fbfc4
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Integration test"
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4

- name: docker
run: ./test/run.sh
3 changes: 3 additions & 0 deletions mods/default/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1654,3 +1654,6 @@ dofile(modpath .. "/furnace.lua")
dofile(modpath .. "/sao.lua")
dofile(modpath .. "/mapgen_setup.lua")
dofile(modpath .. "/abm.lua")
if minetest.settings:get_bool("minetest_classic_internal_test") then
dofile(modpath .. "/test.lua")
end
38 changes: 38 additions & 0 deletions mods/default/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
local function wait_map(callback)
local pos = vector.new(5, 30, 5)
for y = 0, 4 do
assert(minetest.forceload_block(
vector.new(pos.x, y*16, pos.z), true, -1
))
end

local function check()
if minetest.get_node(pos).name ~= "ignore" then
return callback(pos)
end
minetest.after(0, check)
end
check()
end


minetest.after(0, function()
wait_map(function(pos)
for x = -1, 1 do
for z = -1, 1 do
minetest.add_node(pos:offset(x, 0, z), {name="default:dirt"})
end
end

pos = pos:offset(0, 1, 0)
minetest.add_entity(pos, "default:rat")
minetest.add_entity(pos, "default:oerkki1")
minetest.add_entity(pos, "default:firefly")
default.spawn_mobv2(pos, default.get_mob_dungeon_master())

minetest.after(2.5, function()
minetest.request_shutdown()
end)
end)
end)

3 changes: 3 additions & 0 deletions test/minetest.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mg_name = v6
minetest_classic_internal_test = true
max_forceloaded_blocks = 500
15 changes: 15 additions & 0 deletions test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -e

[ -f game.conf ] || { echo "Must be run in game root folder." >&2; exit 1; }

[ -z "$DOCKER_IMAGE" ] && DOCKER_IMAGE="ghcr.io/minetest/minetest:master"
docker run --rm -i \
-v "$PWD/test/minetest.conf":/etc/minetest/minetest.conf \
--tmpfs /root/.minetest \
-v "$PWD":/root/.minetest/games/minetest_classic \
-v "$PWD/test/world.mt":/root/.minetest/world/world.mt \
-u 0:0 "$DOCKER_IMAGE"
# -u 0:0 is needed here because MT's image defaults to an unprivileged user
# but all of our mounts are created as root...

exit 0
3 changes: 3 additions & 0 deletions test/world.mt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enable_damage = true
creative_mode = false
gameid = minetest_classic

0 comments on commit 34fbfc4

Please sign in to comment.