wait for minecraft sever to start in tests #327
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically build the project and run any configured tests for every push | |
# and submitted pull request. This can help catch issues that only occur on | |
# certain platforms or Java versions, and provides a first line of defence | |
# against bad commits. | |
name: build and test | |
on: [pull_request, push] | |
defaults: | |
run: | |
shell: bash -l {0} | |
jobs: | |
build: | |
name: build | |
runs-on: self-hosted | |
strategy: | |
matrix: | |
# Use these Java versions | |
java: [ 21, ] # Current Java LTS & minimum supported by Minecraft | |
steps: | |
- name: lock file | |
run: lockfile /tmp/minecraft-test-lock | |
- name: checkout repository | |
uses: actions/checkout@v2 | |
- name: validate gradle wrapper | |
uses: gradle/wrapper-validation-action@v1 | |
- name: setup jdk ${{ matrix.java }} | |
uses: actions/setup-java@v1 | |
with: | |
java-version: ${{ matrix.java }} | |
- name: make gradle wrapper executable | |
if: ${{ runner.os != 'Windows' }} | |
run: chmod +x ./gradlew | |
- name: build | |
run: ./gradlew build | |
- name: install vereya | |
run: rm /home/tester/.minecraft/mods/* && cp $GITHUB_WORKSPACE/build/libs/* /home/tester/.minecraft/mods/ && | |
rsync -v $GITHUB_WORKSPACE/build/libs/* $GITHUB_WORKSPACE/server/mods/ | |
- name: install fabric | |
run: rsync -v $GITHUB_WORKSPACE/fabric/* /home/tester/.minecraft/mods/ && | |
rsync -v $GITHUB_WORKSPACE/fabric/* $GITHUB_WORKSPACE/server/mods/ | |
- name: remove lock | |
if: failure() | |
run: rm -f /tmp/minecraft-test-lock | |
- name: start minecraft | |
run: ./launch.sh & | |
env: | |
DISPLAY: :99 | |
GITHUB_WORKSPACE: $GITHUB_WORKSPACE | |
- name: start minecraft server | |
run: cd server && ./launch.sh & | |
env: | |
GITHUB_WORKSPACE: $GITHUB_WORKSPACE | |
- name: checkout tagilmo | |
uses: actions/checkout@v3 | |
with: | |
repository: trueagi-io/minecraft-demo | |
path: minecraft-demo | |
- name: install tagilmo | |
run: conda activate py31 && cd $GITHUB_WORKSPACE/minecraft-demo && pip install . | |
- name: Check server health | |
run: | | |
timeout 60s bash -c "while ! curl -v -s http://localhost:25565/health 2>&1 | grep -q 'Empty reply'; do sleep 5s; done" | |
- name: run test | |
run: | | |
ps a|grep [j]ava && | |
conda activate py31 && cd $GITHUB_WORKSPACE/minecraft-demo/tests/vereya && | |
python run_tests.py | |
- name: save java logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: java.log | |
path: logs/app.log | |
- name: save python logs | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: PythonLog | |
path: minecraft-demo/tests/vereya/app.log | |
- name: save test observations | |
uses: actions/upload-artifact@v3 | |
with: | |
name: TestObservations | |
path: minecraft-demo/tests/vereya/observations/observations.txt | |
- name: cleanup | |
if: success() | |
run: rm -r `pwd`/* | |
- name: remove lock | |
if: always() | |
run: rm -f /tmp/minecraft-test-lock |