mirror of
				https://github.com/minetest-mods/mesecons.git
				synced 2025-11-04 04:55:26 +01:00 
			
		
		
		
	Add smoke test with engine using Docker
This commit is contained in:
		@@ -1,10 +1,10 @@
 | 
			
		||||
on: [push, pull_request]
 | 
			
		||||
name: Check & Release
 | 
			
		||||
name: "Check"
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  lint:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
 | 
			
		||||
    name: "Luacheck"
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@main
 | 
			
		||||
    - name: apt
 | 
			
		||||
@@ -14,9 +14,9 @@ jobs:
 | 
			
		||||
    - name: luacheck run
 | 
			
		||||
      run: $HOME/.luarocks/bin/luacheck ./
 | 
			
		||||
 | 
			
		||||
  test:
 | 
			
		||||
  mineunit:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
 | 
			
		||||
    name: "Mineunit tests"
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@main
 | 
			
		||||
    - name: apt
 | 
			
		||||
							
								
								
									
										26
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
on: [push, pull_request]
 | 
			
		||||
name: "Test"
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  test:
 | 
			
		||||
    name: "Smoke Test ${{ matrix.cfg.image }}"
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    timeout-minutes: 5
 | 
			
		||||
    strategy:
 | 
			
		||||
      matrix:
 | 
			
		||||
        cfg:
 | 
			
		||||
          - { image: 'registry.gitlab.com/minetest/minetest/server:5.0.1', mtg: false }
 | 
			
		||||
          - { image: 'ghcr.io/minetest/minetest:5.9.0', mtg: true }
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@main
 | 
			
		||||
 | 
			
		||||
    - uses: actions/checkout@main
 | 
			
		||||
      with:
 | 
			
		||||
        repository: 'minetest/minetest_game'
 | 
			
		||||
        path: ./.test/minetest_game
 | 
			
		||||
      if: ${{ matrix.cfg.mtg }}
 | 
			
		||||
 | 
			
		||||
    - name: Run tests
 | 
			
		||||
      run: ./.test/run.sh
 | 
			
		||||
      env:
 | 
			
		||||
        DOCKER_IMAGE: "${{ matrix.cfg.image }}"
 | 
			
		||||
							
								
								
									
										3
									
								
								.test/minetest.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								.test/minetest.conf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
mg_name = singlenode
 | 
			
		||||
mesecon.internal_test = true
 | 
			
		||||
random_mod_load_order = true
 | 
			
		||||
							
								
								
									
										31
									
								
								.test/run.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								.test/run.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
tempdir=$(mktemp -d)
 | 
			
		||||
confpath=$tempdir/minetest.conf
 | 
			
		||||
worldpath=$tempdir/world
 | 
			
		||||
trap 'rm -rf "$tempdir" || :' EXIT
 | 
			
		||||
 | 
			
		||||
[ -f mesecons/mod.conf ] || { echo "Must be run in modpack root folder." >&2; exit 1; }
 | 
			
		||||
 | 
			
		||||
command -v docker >/dev/null || { echo "Docker is not installed." >&2; exit 1; }
 | 
			
		||||
mtg=.test/minetest_game
 | 
			
		||||
[ -d $mtg ] || echo "A source checkout of minetest_game was not found. This can fail if your docker image does not ship a game." >&2
 | 
			
		||||
 | 
			
		||||
mkdir "$worldpath"
 | 
			
		||||
cp -v .test/minetest.conf "$confpath"
 | 
			
		||||
chmod -R 777 "$tempdir"
 | 
			
		||||
 | 
			
		||||
args=(
 | 
			
		||||
	-v "$confpath":/etc/minetest/minetest.conf
 | 
			
		||||
	-v "$tempdir":/var/lib/minetest/.minetest
 | 
			
		||||
	-v "$PWD":/var/lib/minetest/.minetest/world/worldmods/mesecons
 | 
			
		||||
)
 | 
			
		||||
[ -d $mtg ] && args+=(
 | 
			
		||||
	-v "$(realpath $mtg)":/var/lib/minetest/.minetest/games/minetest_game
 | 
			
		||||
)
 | 
			
		||||
args+=("$DOCKER_IMAGE")
 | 
			
		||||
[ -d $mtg ] && args+=(--gameid minetest)
 | 
			
		||||
docker run --rm -i "${args[@]}"
 | 
			
		||||
 | 
			
		||||
ls -la "$worldpath"
 | 
			
		||||
test -f "$worldpath/mesecon_actionqueue" || exit 1
 | 
			
		||||
exit 0
 | 
			
		||||
@@ -123,3 +123,11 @@ dofile(minetest.get_modpath("mesecons").."/legacy.lua");
 | 
			
		||||
 | 
			
		||||
--Services like turnoff receptor on dignode and so on
 | 
			
		||||
dofile(minetest.get_modpath("mesecons").."/services.lua");
 | 
			
		||||
 | 
			
		||||
-- Automated test run
 | 
			
		||||
if mesecon.setting("internal_test", false) then
 | 
			
		||||
	-- currently does nothing, we only fail if some error happens right on startup
 | 
			
		||||
	minetest.after(5, function()
 | 
			
		||||
		minetest.request_shutdown()
 | 
			
		||||
	end)
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user