From 6d6432940fd3bd192af3dec6e76eacf9d0255394 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Mon, 11 May 2020 10:38:12 +0200 Subject: [PATCH] add integration-test --- .github/workflows/integration-test.yml | 15 ++++++++++ README.md | 1 + test/integration-test.sh | 25 ++++++++++++++++ test/test_mod/init.lua | 40 ++++++++++++++++++++++++++ test/test_mod/mod.conf | 2 ++ 5 files changed, 83 insertions(+) create mode 100644 .github/workflows/integration-test.yml create mode 100755 test/integration-test.sh create mode 100644 test/test_mod/init.lua create mode 100644 test/test_mod/mod.conf diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 0000000..5a614a9 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,15 @@ +name: integration-test + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v1 + + - name: integration-test + run: ./test/integration-test-standalone.sh diff --git a/README.md b/README.md index 6bfaaf6..0197588 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ # scifi_nodes ![](https://github.com/D00Med/scifi_nodes/workflows/luacheck/badge.svg) +![](https://github.com/D00Med/scifi_nodes/workflows/integration-test/badge.svg) Minetest mod that adds scifi themed blocks, doors, materials, plants and other assets. diff --git a/test/integration-test.sh b/test/integration-test.sh new file mode 100755 index 0000000..d3b8429 --- /dev/null +++ b/test/integration-test.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# Spins up a test world to ensure proper working recipes and registrations + +CWD=$(dirname $0) +cd ${CWD}/../ + +CFG=/tmp/minetest.conf +MTDIR=/tmp/mt +WORLDDIR=${MTDIR}/worlds/world + +cat < ${CFG} + # empty +EOF + +mkdir -p ${WORLDDIR} +chmod 777 ${MTDIR} -R +docker run --rm -i \ + -v ${CFG}:/etc/minetest/minetest.conf:ro \ + -v ${MTDIR}:/var/lib/minetest/.minetest \ + -v $(pwd)/:/var/lib/minetest/.minetest/worlds/world/worldmods/scifi_nodes \ + -v $(pwd)/test/test_mod/:/var/lib/minetest/.minetest/worlds/world/worldmods/scifi_nodes_test \ + --network host \ + registry.gitlab.com/minetest/minetest/server:5.2.0 + +test -f ${WORLDDIR}/integration_test.json && exit 0 || exit 1 diff --git a/test/test_mod/init.lua b/test/test_mod/init.lua new file mode 100644 index 0000000..7b986fa --- /dev/null +++ b/test/test_mod/init.lua @@ -0,0 +1,40 @@ + +minetest.log("warning", "[TEST] integration-test enabled!") + +-- those mods have to be present +local assert_mods = { + "scifi_nodes" +} + +-- those nodes have to be present +local assert_nodes = { + "scifi_nodes:crate", + "scifi_nodes:door1a" +} + +minetest.register_on_mods_loaded(function() + minetest.after(0, function() + -- check mods + for _, modname in ipairs(assert_mods) do + if not minetest.get_modpath(modname) then + error("Mod not present: " .. modname) + end + end + + -- check nodes + for _, nodename in ipairs(assert_nodes) do + if not minetest.registered_nodes[nodename] then + error("Node not present: " .. nodename) + end + end + + local data = minetest.write_json({ success = true }, true); + local file = io.open(minetest.get_worldpath().."/integration_test.json", "w" ); + if file then + file:write(data) + file:close() + end + minetest.request_shutdown("success") + + end) +end) diff --git a/test/test_mod/mod.conf b/test/test_mod/mod.conf new file mode 100644 index 0000000..8065d95 --- /dev/null +++ b/test/test_mod/mod.conf @@ -0,0 +1,2 @@ +name = scifi_nodes_test +depends = scifi_nodes