diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 10f5d99..8611354 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,8 +3,14 @@ on: [push, pull_request] jobs: test: - name: "Unit Tests" + name: "Unit Tests ${{ matrix.cfg.image }}" runs-on: ubuntu-latest + timeout-minutes: 5 + strategy: + matrix: + cfg: + - { image: 'registry.gitlab.com/minetest/minetest/server:5.5.1', mtg: false } + - { image: '', mtg: true } # latest mater steps: - uses: actions/checkout@v4 @@ -12,6 +18,9 @@ jobs: with: repository: 'minetest/minetest_game' path: minetest_game + if: ${{ matrix.cfg.mtg }} - name: Run tests run: ./.util/run_tests.sh --docker + env: + DOCKER_IMAGE: "${{ matrix.cfg.image }}" diff --git a/.util/run_tests.sh b/.util/run_tests.sh index 6d8c9e0..1b8b481 100755 --- a/.util/run_tests.sh +++ b/.util/run_tests.sh @@ -9,7 +9,7 @@ trap 'rm -rf "$tempdir"' EXIT mtserver= if [ "$1" == "--docker" ]; then command -v docker >/dev/null || { echo "Docker is not installed." >&2; exit 1; } - [ -d minetest_game ] || { echo "To run the test with Docker, a source checkout of minetest_game is required." >&2; exit 1; } + [ -d minetest_game ] || echo "A source checkout of minetest_game was not found. This can fail if your docker image does not ship a game." >&2; else mtserver=$(command -v minetestserver) [[ -z "$mtserver" && -x ../../bin/minetestserver ]] && mtserver=../../bin/minetestserver @@ -23,12 +23,15 @@ printf '%s\n' worldedit_run_tests=true >$confpath if [ -z "$mtserver" ]; then chmod -R 777 $tempdir [ -z "$DOCKER_IMAGE" ] && DOCKER_IMAGE="ghcr.io/minetest/minetest:master" - docker run --rm -i \ - -v "$confpath":/etc/minetest/minetest.conf \ - -v "$tempdir":/var/lib/minetest/.minetest \ - -v "$PWD/minetest_game":/var/lib/minetest/.minetest/games/minetest_game \ - -v "$PWD/worldedit":/var/lib/minetest/.minetest/world/worldmods/worldedit \ - "$DOCKER_IMAGE" + vol=( + -v "$confpath":/etc/minetest/minetest.conf + -v "$tempdir":/var/lib/minetest/.minetest + -v "$PWD/worldedit":/var/lib/minetest/.minetest/world/worldmods/worldedit + ) + [ -d minetest_game ] && vol+=( + -v "$PWD/minetest_game":/var/lib/minetest/.minetest/games/minetest_game + ) + docker run --rm -i "${vol[@]}" "$DOCKER_IMAGE" else mkdir $worldpath/worldmods ln -s "$PWD/worldedit" $worldpath/worldmods/worldedit