From f9348593aae6b2f6f06845965e4ab21d0ca56773 Mon Sep 17 00:00:00 2001 From: David Leal Date: Wed, 4 Nov 2020 15:26:05 -0600 Subject: [PATCH 1/3] Add Integration Test --- .github/workflows/integration-test.yml | 13 +++++++++++++ init.lua | 5 +++++ integration-test.sh | 20 ++++++++++++++++++++ integration_test.lua | 25 +++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 .github/workflows/integration-test.yml create mode 100644 integration-test.sh create mode 100644 integration_test.lua diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 0000000..fdb28b5 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,13 @@ +name: integration-test +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@master + + - name: integration-test + run: ./integration-test.sh diff --git a/init.lua b/init.lua index 8dfa0a2..1be4d4d 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,8 @@ +-- integration test +if minetest.settings:get_bool("technic_armor.enable_technic_armor_integration_test") then + dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/integration_test.lua") +end + -- support for i18n local S = minetest.get_translator("3d_armor") diff --git a/integration-test.sh b/integration-test.sh new file mode 100644 index 0000000..6e12968 --- /dev/null +++ b/integration-test.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# simple integration test + +CFG=/tmp/minetest.conf +MTDIR=/tmp/mt +WORLDDIR=${MTDIR}/worlds/world + +cat < ${CFG} + technic_armor.enable_technic_armor_integration_test = true +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/technic_armor \ + registry.gitlab.com/minetest/minetest/server:5.3.0 + +test -f ${WORLDDIR}/integration_test.json && exit 0 || exit 1 diff --git a/integration_test.lua b/integration_test.lua new file mode 100644 index 0000000..65e9dfd --- /dev/null +++ b/integration_test.lua @@ -0,0 +1,25 @@ + +minetest.log("warning", "[TEST] integration-test enabled!") + +minetest.register_on_mods_loaded(function() + minetest.after(1, function() + + 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 + + file = io.open(minetest.get_worldpath().."/registered_nodes.txt", "w" ); + if file then + for name in pairs(minetest.registered_nodes) do + file:write(name .. '\n') + end + file:close() + end + + minetest.log("warning", "[TEST] integration tests done!") + minetest.request_shutdown("success") + end) +end) From 2eb77818c137b2e00e64515ca69e0dd51c27c1e7 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Thu, 5 Nov 2020 07:17:44 +0100 Subject: [PATCH 2/3] make script executable --- integration-test.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 integration-test.sh diff --git a/integration-test.sh b/integration-test.sh old mode 100644 new mode 100755 From 688c8221371f50b674ea3776dd8e752ae021d143 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Thu, 5 Nov 2020 13:35:29 +0100 Subject: [PATCH 3/3] clone 3d_armor mod for integration test --- integration-test.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integration-test.sh b/integration-test.sh index 6e12968..221027f 100755 --- a/integration-test.sh +++ b/integration-test.sh @@ -4,11 +4,15 @@ CFG=/tmp/minetest.conf MTDIR=/tmp/mt WORLDDIR=${MTDIR}/worlds/world +WORLDMODDIR=${WORLDDIR}/worldmods cat < ${CFG} technic_armor.enable_technic_armor_integration_test = true EOF +# clone dependencies +git clone --depth 1 https://github.com/minetest-mods/3d_armor.git ${WORLDMODDIR}/3d_armor + mkdir -p ${WORLDDIR} chmod 777 ${MTDIR} -R docker run --rm -i \