Merge origin/main into feature/dynamic-commands
Restore multi-step smoke workflow (openssh-client, netcat, wait-for-tcp). Resolve run-tests.sh and TESTING.md with feature JSON-RPC coverage; add matching Smoke - JSON-RPC list_commands workflow step. Made-with: Cursor
This commit is contained in:
@@ -2,19 +2,27 @@ name: Smoke tests
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
smoke:
|
||||
name: Build and smoke test
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TEST_DB: ./mudserver.db.test
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust
|
||||
- name: Install needed tools
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
run: |
|
||||
set -e
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends openssh-client netcat-openbsd ca-certificates curl
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Build
|
||||
run: cargo build
|
||||
@@ -22,5 +30,143 @@ jobs:
|
||||
- name: Validate world data
|
||||
run: ./target/debug/mudtool validate -w ./world
|
||||
|
||||
- name: Run smoke tests
|
||||
run: ./run-tests.sh
|
||||
- name: Reset smoke database
|
||||
run: rm -f "$TEST_DB"
|
||||
|
||||
- name: Smoke - new player and basics
|
||||
run: |
|
||||
set -euo pipefail
|
||||
RUST_LOG=info ./target/debug/mudserver -d "$TEST_DB" &
|
||||
MUD_PID=$!
|
||||
trap 'kill $MUD_PID 2>/dev/null || true' EXIT
|
||||
bash scripts/ci/wait-for-tcp.sh 127.0.0.1 2222
|
||||
set +e
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost <<'EOF'
|
||||
1
|
||||
1
|
||||
look
|
||||
stats
|
||||
go south
|
||||
go down
|
||||
go north
|
||||
talk barkeep
|
||||
go south
|
||||
go south
|
||||
examine thief
|
||||
attack thief
|
||||
flee
|
||||
quit
|
||||
EOF
|
||||
r=$?
|
||||
set -e
|
||||
[[ $r -eq 0 || $r -eq 255 ]]
|
||||
|
||||
- name: Smoke - persistence (reconnect)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
RUST_LOG=info ./target/debug/mudserver -d "$TEST_DB" &
|
||||
MUD_PID=$!
|
||||
trap 'kill $MUD_PID 2>/dev/null || true' EXIT
|
||||
bash scripts/ci/wait-for-tcp.sh 127.0.0.1 2222
|
||||
set +e
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost <<'EOF'
|
||||
look
|
||||
stats
|
||||
quit
|
||||
EOF
|
||||
r=$?
|
||||
set -e
|
||||
[[ $r -eq 0 || $r -eq 255 ]]
|
||||
|
||||
- name: Smoke - mudtool admin
|
||||
run: |
|
||||
set -euo pipefail
|
||||
./target/debug/mudtool -d "$TEST_DB" players list
|
||||
./target/debug/mudtool -d "$TEST_DB" players set-admin smoketest true
|
||||
./target/debug/mudtool -d "$TEST_DB" players show smoketest
|
||||
./target/debug/mudtool -d "$TEST_DB" settings set registration_open false
|
||||
./target/debug/mudtool -d "$TEST_DB" settings list
|
||||
|
||||
- name: Smoke - in-game admin
|
||||
run: |
|
||||
set -euo pipefail
|
||||
RUST_LOG=info ./target/debug/mudserver -d "$TEST_DB" &
|
||||
MUD_PID=$!
|
||||
trap 'kill $MUD_PID 2>/dev/null || true' EXIT
|
||||
bash scripts/ci/wait-for-tcp.sh 127.0.0.1 2222
|
||||
set +e
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost <<'EOF'
|
||||
admin help
|
||||
admin list
|
||||
admin registration on
|
||||
admin info smoketest
|
||||
quit
|
||||
EOF
|
||||
r=$?
|
||||
set -e
|
||||
[[ $r -eq 0 || $r -eq 255 ]]
|
||||
|
||||
- name: Smoke - registration gate
|
||||
run: |
|
||||
set -euo pipefail
|
||||
./target/debug/mudtool -d "$TEST_DB" settings set registration_open false
|
||||
RUST_LOG=info ./target/debug/mudserver -d "$TEST_DB" &
|
||||
MUD_PID=$!
|
||||
trap 'kill $MUD_PID 2>/dev/null || true' EXIT
|
||||
bash scripts/ci/wait-for-tcp.sh 127.0.0.1 2222
|
||||
set +e
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 newplayer@localhost <<'EOF'
|
||||
quit
|
||||
EOF
|
||||
r=$?
|
||||
set -e
|
||||
[[ $r -eq 0 || $r -eq 255 ]]
|
||||
|
||||
- name: Smoke - tick-based combat
|
||||
run: |
|
||||
set -euo pipefail
|
||||
./target/debug/mudtool -d "$TEST_DB" settings set registration_open true
|
||||
./target/debug/mudtool -d "$TEST_DB" players delete smoketest
|
||||
RUST_LOG=info ./target/debug/mudserver -d "$TEST_DB" &
|
||||
MUD_PID=$!
|
||||
trap 'kill $MUD_PID 2>/dev/null || true' EXIT
|
||||
bash scripts/ci/wait-for-tcp.sh 127.0.0.1 2222
|
||||
set +e
|
||||
(
|
||||
echo "1"
|
||||
echo "1"
|
||||
echo "go south"
|
||||
echo "go down"
|
||||
echo "go south"
|
||||
echo "attack thief"
|
||||
sleep 8
|
||||
echo "stats"
|
||||
echo "quit"
|
||||
) | ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost
|
||||
r=$?
|
||||
set -e
|
||||
[[ $r -eq 0 || $r -eq 255 ]]
|
||||
./target/debug/mudtool -d "$TEST_DB" settings set registration_open true
|
||||
./target/debug/mudtool -d "$TEST_DB" players delete smoketest
|
||||
|
||||
- name: Smoke - JSON-RPC list_commands
|
||||
run: |
|
||||
set -euo pipefail
|
||||
RUST_LOG=info ./target/debug/mudserver -d "$TEST_DB" &
|
||||
MUD_PID=$!
|
||||
trap 'kill $MUD_PID 2>/dev/null || true' EXIT
|
||||
bash scripts/ci/wait-for-tcp.sh 127.0.0.1 2222
|
||||
set +e
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 rpctest@localhost <<'EOF'
|
||||
1
|
||||
1
|
||||
quit
|
||||
EOF
|
||||
r=$?
|
||||
set -e
|
||||
[[ $r -eq 0 || $r -eq 255 ]]
|
||||
echo '{"_jsonrpc": "2.0", "method": "login", "params": {"username": "rpctest"}, "id": 1}' | nc -w 2 localhost 2223 > rpc_resp.json
|
||||
echo '{"_jsonrpc": "2.0", "method": "list_commands", "params": {}, "id": 2}' | nc -w 2 localhost 2223 >> rpc_resp.json
|
||||
grep -q '"shop"' rpc_resp.json
|
||||
rm rpc_resp.json
|
||||
./target/debug/mudtool -d "$TEST_DB" players delete rpctest
|
||||
|
||||
Reference in New Issue
Block a user