Skip to content

Commit 4ec933d

Browse files
committed
Added automata for better testing
- Created automata for testing player interaction - Updated tests workflow - Added "node_modules" to gitignore
1 parent 06e8d9c commit 4ec933d

File tree

8 files changed

+1375
-1
lines changed

8 files changed

+1375
-1
lines changed

.github/workflows/tests.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [push]
55
jobs:
66
test:
77
runs-on: ubuntu-latest
8-
timeout-minutes: 15
8+
timeout-minutes: 8
99
strategy:
1010
fail-fast: false
1111
matrix:
@@ -23,6 +23,17 @@ jobs:
2323
distribution: 'adopt'
2424
java-version: '11'
2525

26+
# Setup Node.js
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v2
29+
with:
30+
node-version: '16'
31+
32+
# Setup automata
33+
- name: Setup automata
34+
working-directory: ./automata
35+
run: npm install
36+
2637
# Build plugin
2738
- name: Build with Maven
2839
run: mvn --batch-mode --update-snapshots verify
@@ -44,6 +55,9 @@ jobs:
4455
wget -nv "$url" -O server.jar
4556
java -jar server.jar || true
4657
sed -i 's/eula=false/eula=true/g' eula.txt
58+
echo "online-mode=false" >> server.properties
59+
echo "enable-rcon=true" >> server.properties
60+
echo "rcon.password=rcon" >> server.properties
4761
echo "allow-nether=false" >> server.properties
4862
echo "allow-end=false" >> server.properties
4963
echo 'generate-structures=false' >> server.properties
@@ -70,6 +84,7 @@ jobs:
7084
- name: Run plugin in server
7185
working-directory: ./server
7286
run: |
87+
(cd ../automata && npm run start) &
7388
timeout -s SIGINT 90s java -DIReallyKnowWhatIAmDoingISwear -jar server.jar nogui | tee server.log || true
7489
if ! grep -Fq '[YamipaPlugin] Loading YamipaPlugin' server.log; then
7590
echo "Plugin did not load"
@@ -83,3 +98,19 @@ jobs:
8398
echo "Plugin did not read image directory"
8499
exit 1
85100
fi
101+
if ! grep -Fq '[YamipaPlugin] Fixed command permissions' server.log; then
102+
echo "Plugin did not fixed command permissions"
103+
exit 1
104+
fi
105+
if ! grep -Fq '[YamipaPlugin] Created FakeImage' server.log; then
106+
echo "Plugin did not place the fake image"
107+
exit 1
108+
fi
109+
if ! grep -Fq '[YamipaPlugin] Invalidated FakeImage' server.log; then
110+
echo "Plugin did not remove the fake image"
111+
exit 1
112+
fi
113+
if grep -iFq 'exception' server.log; then
114+
echo "Server threw an exception"
115+
exit 1
116+
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.idea
22
/target
33
/*.iml
4+
node_modules

automata/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { placeBlockOnTheFloor, startBot } from './src/bot.js'
2+
import { wait } from './src/common.js'
3+
import { getRconClient, waitForServer } from './src/rcon.js'
4+
5+
(async() => {
6+
console.log('Waiting for Minecraft server to be ready...')
7+
await waitForServer()
8+
9+
console.log('Making test account an OP...')
10+
const conn = await getRconClient()
11+
await conn.send('op @p')
12+
await conn.send('gamemode creative @p')
13+
await conn.end()
14+
15+
console.log('Logging in as test account...')
16+
const bot = await startBot()
17+
await bot.look(0, -Math.PI/2)
18+
bot.chat('/give @p minecraft:dirt')
19+
20+
console.log('Placing image on the floor...')
21+
bot.chat('/image place pic-1.jpg 4 4')
22+
await wait(2000)
23+
placeBlockOnTheFloor(bot)
24+
await wait(2000)
25+
26+
console.log('Removing image from floor...')
27+
bot.chat('/image remove')
28+
await wait(2000)
29+
placeBlockOnTheFloor(bot)
30+
await wait(2000)
31+
32+
console.log('Logging off...')
33+
bot.end()
34+
console.log('Done!')
35+
})()

0 commit comments

Comments
 (0)