diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 0000000..a0241f2 --- /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 + + steps: + - uses: actions/checkout@v1 + - uses: textbook/git-checkout-submodule-action@master + + - name: test + run: ./integration-test.sh diff --git a/.github/workflows_disabled/luacheck.yml b/.github/workflows_disabled/luacheck.yml new file mode 100644 index 0000000..d00f53a --- /dev/null +++ b/.github/workflows_disabled/luacheck.yml @@ -0,0 +1,17 @@ +name: luacheck + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: apt + run: sudo apt-get install -y luarocks + - name: luacheck install + run: luarocks install --local luacheck + - name: luacheck run + run: $HOME/.luarocks/bin/luacheck ./ diff --git a/integration-test.sh b/integration-test.sh index 7da661a..5f43bd4 100755 --- a/integration-test.sh +++ b/integration-test.sh @@ -4,13 +4,18 @@ CFG=/tmp/minetest.conf MTDIR=/tmp/mt WORLDDIR=${MTDIR}/worlds/world +WORLDMODDIR=${WORLDDIR}/worldmods -# TODO: pipeworks / basic_materials +# settings cat < ${CFG} enable_technic_integration_test = true EOF -mkdir -p ${WORLDDIR} +rm -rf ${WORLDDIR} +mkdir -p ${WORLDMODDIR} +git clone https://gitlab.com/VanessaE/basic_materials.git ${WORLDMODDIR}/basic_materials +git clone https://gitlab.com/VanessaE/pipeworks.git ${WORLDMODDIR}/pipeworks + chmod 777 ${MTDIR} -R docker run --rm -i \ -v ${CFG}:/etc/minetest/minetest.conf:ro \ diff --git a/technic/init.lua b/technic/init.lua index 370c71b..2a38800 100644 --- a/technic/init.lua +++ b/technic/init.lua @@ -51,3 +51,6 @@ if minetest.settings:get_bool("log_mods") then print(S("[Technic] Loaded in %f seconds"):format(os.clock() - load_start)) end +if minetest.settings:get_bool("enable_technic_integration_test") then + dofile(modpath.."/integration_test.lua") +end diff --git a/technic/integration_test.lua b/technic/integration_test.lua new file mode 100644 index 0000000..c687a8b --- /dev/null +++ b/technic/integration_test.lua @@ -0,0 +1,56 @@ + +minetest.log("warning", "[technic] integration-test enabled!") + +-- those mods have to be present +local assert_mods = { + "technic", + "pipeworks" +} + +-- those nodes have to be present +local assert_nodes = { + "technic:admin_anchor" +} + +-- defered integration test function +minetest.register_on_mods_loaded(function() + minetest.log("warning", "[technic] all mods loaded, starting delayed test-function") + + minetest.after(1, function() + minetest.log("warning", "[technic] starting integration test") + + -- export stats + local 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 + + -- 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 + + -- write success flag + local data = minetest.write_json({ success = true }, true); + file = io.open(minetest.get_worldpath().."/integration_test.json", "w" ); + if file then + file:write(data) + file:close() + end + + minetest.log("warning", "[technic] integration tests done!") + minetest.request_shutdown("success") + end) +end)