Skip to content

Commit

Permalink
Merge branch 'master' into yeet-the-wrench
Browse files Browse the repository at this point in the history
  • Loading branch information
OgelGames authored Aug 6, 2023
2 parents b951f4b + 2614489 commit 55603b4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 45 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/mineunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ name: mineunit
on: [push, pull_request]

jobs:
build:
mineunit:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- id: mineunit
uses: mt-mods/mineunit-actions@master
with:
working-directory: ./technic
mineunit-args: --fetch-core 5.4.1 --engine-version 5.4.1
mineunit-args: --engine-version 5.4.1
badge-label: Test coverage

- uses: RubbaBoy/BYOB@v1.2.0
- uses: RubbaBoy/BYOB@v1.3.0
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
NAME: "${{ steps.mineunit.outputs.badge-name }}"
Expand All @@ -33,7 +33,7 @@ jobs:
badge-name: coverage-cnc
badge-label: Test coverage

- uses: RubbaBoy/BYOB@v1.2.0
- uses: RubbaBoy/BYOB@v1.3.0
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
NAME: "${{ steps.mineunit-cnc.outputs.badge-name }}"
Expand All @@ -49,6 +49,15 @@ jobs:
badge-name: coverage-chests
badge-label: Test coverage

- uses: RubbaBoy/[email protected]
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
NAME: "${{ steps.mineunit-chests.outputs.badge-name }}"
LABEL: "${{ steps.mineunit-chests.outputs.badge-label }}"
STATUS: "${{ steps.mineunit-chests.outputs.badge-status }}"
COLOR: "${{ steps.mineunit-chests.outputs.badge-color }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: KeisukeYamashita/create-comment@v1
if: success() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
with:
Expand Down
28 changes: 12 additions & 16 deletions technic/spec/hv_network_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,22 @@ describe("HV machine network", function()

local machines = {
"technic:hv_generator",
"technic:hv_solar_array",
"technic:hv_solar_array",
"technic:hv_solar_array",
"technic:hv_solar_array",
"technic:hv_solar_array",
"technic:hv_battery_box0",
"technic:hv_electric_furnace",
"technic:hv_grinder",
"technic:hv_compressor",
"technic:hv_nuclear_reactor_core",
"technic:quarry",
"technic:hv_solar_array",
}

world.clear()
world.place_node({x=100,y=1,z=0}, "technic:switching_station", player)
for x = 1, 100 do
world.place_node({x=x,y=0,z=0}, "technic:hv_cable", player)
world.place_node({x=0,y=51,z=0}, "technic:switching_station", player)
for x = 0, 10 do
world.place_node({x=x,y=50,z=0}, "technic:hv_cable", player)
end
for x, name in ipairs(machines) do
world.place_node({x=x,y=1,z=0}, name, player)
world.place_node({x=x,y=51,z=0}, name, player)
end

-- Helper function to execute netowork
Expand Down Expand Up @@ -72,33 +68,33 @@ describe("HV machine network", function()
spy.on(technic, "network_run")
run_network(60)
assert.spy(technic.network_run).called(60)
local id = technic.pos2network({x=100,y=0,z=0})
local id = technic.pos2network({x=0,y=50,z=0})
assert.not_nil(technic.networks[id])
assert.gt(technic.networks[id].supply, 0)
end)

it("kills network when switching station disappear", function()
local id = technic.pos2network({x=100,y=0,z=0})
local id = technic.pos2network({x=0,y=50,z=0})
assert.not_nil(technic.networks[id])
-- Remove switching station and execute globalstep
world.set_node({x=100,y=1,z=0}, {name="air"})
world.set_node({x=0,y=51,z=0}, {name="air"})
mineunit:execute_globalstep(1)
-- Network should be gone
assert.is_nil(technic.networks[id])
-- Build new switching station to restore network
world.place_node({x=100,y=1,z=0}, {name="technic:switching_station"})
world.place_node({x=0,y=51,z=0}, {name="technic:switching_station"})
mineunit:execute_globalstep(1)
assert.not_nil(technic.networks[id])
end)

it("charges battery box", function()
local id = technic.pos2network({x=100,y=0,z=0})
local id = technic.pos2network({x=0,y=50,z=0})
local net = technic.networks[id]
assert.gt(net.battery_charge, 1000)
end)

it("smelts ores", function()
local machine_pos = {x=8,y=1,z=0}
local machine_pos = {x=3,y=51,z=0}
place_itemstack(machine_pos, "technic:lead_lump 99")
run_network(60)
-- Check results, at least 10 items processed and results in correct stuff
Expand All @@ -108,7 +104,7 @@ describe("HV machine network", function()
end)

it("grinds ores", function()
local machine_pos = {x=9,y=1,z=0}
local machine_pos = {x=4,y=51,z=0}
place_itemstack(machine_pos, "technic:lead_lump 99")
run_network(60)
-- Check results, at least 10 items processed and results in correct stuff
Expand Down
46 changes: 22 additions & 24 deletions technic/spec/lv_network_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ describe("LV machine network", function()
world.set_default_node("air")

local machines = {
"technic:lv_generator",
"technic:geothermal",
"technic:solar_panel",
"technic:lv_solar_array",
"technic:lv_solar_array",
"technic:lv_solar_array",
"technic:lv_battery_box0",
"technic:lv_electric_furnace",
"technic:lv_extractor",
Expand All @@ -34,22 +28,26 @@ describe("LV machine network", function()
"technic:lv_led",
"technic:lv_lamp",
"technic:water_mill",
"technic:lv_generator",
"technic:geothermal",
"technic:solar_panel",
"technic:lv_solar_array",
}

world.clear()
world.place_node({x=100,y=1,z=0}, "technic:switching_station", player)
for x = 1, 100 do
world.place_node({x=x,y=0,z=0}, "technic:lv_cable", player)
world.place_node({x=0,y=51,z=0}, "technic:switching_station", player)
for x = 0, 15 do
world.place_node({x=x,y=50,z=0}, "technic:lv_cable", player)
end
for x, name in ipairs(machines) do
world.place_node({x=x,y=1,z=0}, name, player)
world.place_node({x=x,y=51,z=0}, name, player)
end

-- Helper to destroy nodes in test world returning list of removed nodes indexed by coordinates
local function remove_nodes(nodes)
local removed = {}
for x = 1, 100 do
local pos = {x=x,y=1,z=0}
for x = 0, 15 do
local pos = {x=x,y=51,z=0}
local node = minetest.get_node(pos)
if nodes[node.name] then
removed[pos] = node
Expand Down Expand Up @@ -96,33 +94,33 @@ describe("LV machine network", function()
spy.on(technic, "network_run")
run_network(60)
assert.spy(technic.network_run).called(60)
local id = technic.pos2network({x=100,y=0,z=0})
local id = technic.pos2network({x=0,y=50,z=0})
assert.not_nil(technic.networks[id])
assert.gt(technic.networks[id].supply, 0)
end)

it("kills network when switching station disappear", function()
local id = technic.pos2network({x=100,y=0,z=0})
local id = technic.pos2network({x=0,y=50,z=0})
assert.not_nil(technic.networks[id])
-- Remove switching station and execute globalstep
world.remove_node({x=100,y=1,z=0})
world.remove_node({x=0,y=51,z=0})
run_network()
-- Network should be gone
assert.is_nil(technic.networks[id])
-- Build new switching station to restore network
world.place_node({x=100,y=1,z=0}, {name="technic:switching_station"})
world.place_node({x=0,y=51,z=0}, {name="technic:switching_station"})
run_network()
assert.not_nil(technic.networks[id])
end)

it("charges battery box", function()
local id = technic.pos2network({x=100,y=0,z=0})
local id = technic.pos2network({x=0,y=50,z=0})
local net = technic.networks[id]
assert.gt(net.battery_charge, 1000)
end)

it("smelts ores", function()
local machine_pos = {x=8,y=1,z=0}
local machine_pos = {x=2,y=51,z=0}
place_itemstack(machine_pos, "technic:lead_lump 99")
run_network(60)
-- Check results, at least 10 items processed and results in correct stuff
Expand All @@ -132,7 +130,7 @@ describe("LV machine network", function()
end)

it("grinds ores", function()
local machine_pos = {x=10,y=1,z=0}
local machine_pos = {x=4,y=51,z=0}
place_itemstack(machine_pos, "technic:lead_lump 99")
run_network(60)
-- Check results, at least 10 items processed and results in correct stuff
Expand All @@ -142,7 +140,7 @@ describe("LV machine network", function()
end)

it("comperess sand", function()
local machine_pos = {x=12,y=1,z=0}
local machine_pos = {x=6,y=51,z=0}
place_itemstack(machine_pos, "default:sand 99")
run_network(60)
-- Check results, at least 10 items processed and results in correct stuff
Expand All @@ -152,10 +150,10 @@ describe("LV machine network", function()
end)

it("cuts power when generators disappear", function()
place_itemstack({x=8,y=1,z=0}, "technic:lead_lump 99")
place_itemstack({x=10,y=1,z=0}, "technic:lead_lump 99")
place_itemstack({x=12,y=1,z=0}, "default:sand 99")
local id = technic.pos2network({x=100,y=0,z=0})
place_itemstack({x=2,y=51,z=0}, "technic:lead_lump 99")
place_itemstack({x=4,y=51,z=0}, "technic:lead_lump 99")
place_itemstack({x=6,y=51,z=0}, "default:sand 99")
local id = technic.pos2network({x=0,y=50,z=0})
assert.not_nil(technic.networks[id])

-- Remove generators and run network 60 times
Expand Down
4 changes: 4 additions & 0 deletions technic_chests/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Technic chests
==============

![luacheck](https://github.com/mt-mods/technic/workflows/luacheck/badge.svg)
![mineunit](https://github.com/mt-mods/technic/workflows/mineunit/badge.svg)
![](https://byob.yarr.is/mt-mods/technic/coverage-chests)

License
-------

Expand Down

0 comments on commit 55603b4

Please sign in to comment.