Merge main into fix/1482-evoker-fangs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Render regression: bundle component tooltips in anvil and brewing screens.
|
||||
|
||||
Requires prepared 26.3 resources, a built horizon-client/horizon-ctl and Pillow.
|
||||
Runs an isolated offscreen game; never opens existing player data. A name-only
|
||||
bundle tooltip is narrower than the component's 96 GUI-pixel minimum, so its
|
||||
purple frame cannot pass the image assertion. Screenshots are kept as evidence.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
from PIL import Image
|
||||
import lab
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def longest_tooltip_border(image):
|
||||
"""Longest horizontal purple tooltip-frame run (physical pixels)."""
|
||||
rgb = image.convert("RGB")
|
||||
longest = 0
|
||||
pixels = rgb.load()
|
||||
for y in range(rgb.height):
|
||||
run = 0
|
||||
for x in range(rgb.width):
|
||||
r, g, b = pixels[x, y]
|
||||
if g < 25 and r < 100 and b >= r + 15:
|
||||
run += 1
|
||||
longest = max(longest, run)
|
||||
else:
|
||||
run = 0
|
||||
return longest
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--game", type=Path, default=ROOT / "target/fast/horizon-client")
|
||||
parser.add_argument("--ctl", type=Path, default=ROOT / "target/fast/horizon-ctl")
|
||||
parser.add_argument("--resources", type=Path, default=ROOT / ".local/horizon-client/26.3")
|
||||
parser.add_argument("--output", type=Path)
|
||||
parser.add_argument("--in-frame", action="store_true")
|
||||
args = parser.parse_args()
|
||||
output = args.output or Path(tempfile.mkdtemp(prefix="bundle-tooltip-"))
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
output = output.resolve()
|
||||
homes = {}
|
||||
for key in ("HORIZON_HOME", "HORIZON_LAUNCHER_HOME", "XDG_DATA_HOME", "XDG_CONFIG_HOME"):
|
||||
directory = output / key
|
||||
directory.mkdir(exist_ok=True)
|
||||
homes[key] = directory
|
||||
env = lab.game_env(**homes)
|
||||
socket = output / "ctl.sock"
|
||||
|
||||
def ctl(*commands, timeout=45):
|
||||
result = subprocess.run(
|
||||
[str(args.ctl.resolve()), "--socket", str(socket), *map(str, commands)],
|
||||
env=env, cwd=output, capture_output=True, text=True, timeout=timeout,
|
||||
)
|
||||
data = json.loads(result.stdout)
|
||||
if result.returncode or data.get("error"):
|
||||
raise RuntimeError(f"{commands}: {data}; {result.stderr}")
|
||||
return data
|
||||
|
||||
results = []
|
||||
try:
|
||||
ctl("launch", "--game", args.game.resolve(), "--world", output / "world",
|
||||
"--creative", "--offscreen", "--wait", "--resources", args.resources.resolve(),
|
||||
*(["--in-frame"] if args.in_frame else []), timeout=120)
|
||||
state = ctl("state")
|
||||
px, _, pz = state["player"]["block_pos"]
|
||||
x, z = (px // 16) * 16 + 8, (pz // 16) * 16 + 8
|
||||
ctl("command", f"fill {x-3} 99 {z-3} {x+3} 99 {z+3} minecraft:stone")
|
||||
ctl("command", f"fill {x-3} 100 {z-3} {x+3} 105 {z+3} minecraft:air")
|
||||
ctl("tp", x + 0.5, 100, z + 0.5)
|
||||
ctl("command", 'item replace entity @s hotbar.0 with minecraft:bundle['
|
||||
'minecraft:bundle_contents=[{id:"minecraft:stone",count:32}]]')
|
||||
for station in ("anvil", "brewing_stand"):
|
||||
ctl("command", f"setblock {x} 100 {z+2} minecraft:{station}")
|
||||
ctl("wait", 5)
|
||||
ctl("look-at-block", x, 100, z+2, "north")
|
||||
ctl("interact", x, 100, z+2, "north")
|
||||
time.sleep(0.3)
|
||||
ui = ctl("ui")
|
||||
slot = next(w for w in ui["widgets"] if w["id"] == "slot-0")
|
||||
assert slot["stack"]["item"] == "minecraft:bundle", slot
|
||||
sx, sy, sw, sh = slot["bounds"]
|
||||
ctl("scroll-at", sx + sw / 2, sy + sh / 2, 0)
|
||||
screenshot = output / f"{station}.png"
|
||||
ctl("screenshot", screenshot)
|
||||
with Image.open(screenshot) as image:
|
||||
scale = image.width / ui["gui_size"][0]
|
||||
longest = longest_tooltip_border(image)
|
||||
# The component reserves 96 GUI pixels; allow its border/integer rounding.
|
||||
required = int(90 * scale)
|
||||
results.append({"station": station, "border_pixels": longest,
|
||||
"required_pixels": required, "pass": longest >= required,
|
||||
"screenshot": str(screenshot)})
|
||||
ctl("close")
|
||||
finally:
|
||||
try:
|
||||
ctl("quit")
|
||||
except (RuntimeError, subprocess.TimeoutExpired, json.JSONDecodeError):
|
||||
pass
|
||||
report = {"mode": "in-frame" if args.in_frame else "server-thread", "results": results}
|
||||
(output / "results.json").write_text(json.dumps(report, indent=2) + "\n")
|
||||
print(json.dumps(report, indent=2))
|
||||
assert len(results) == 2 and all(r["pass"] for r in results), "Missing bundle component tooltip"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+79
-36
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# A Horizon CI runner (labels self-hosted, Linux, X64, horizon-game and the host's name) on a Linux machine of the
|
||||
# maintainer's (NixOS: ludodesktop, ludothinkpad), as a systemd user service of the account that holds his
|
||||
# Minecraft files, like the Mac mini's runners (docs/release-flow.md). Run it on that machine, as that user:
|
||||
# maintainer's (NixOS: ludodesktop, ludothinkpad; Ubuntu: playhorizon, a partner's server), as a systemd user service
|
||||
# of the account that holds his Minecraft files, like the Mac mini's runners (docs/release-flow.md). Run it on that
|
||||
# machine, as that user:
|
||||
#
|
||||
# bash tools/ci/linux-runner.sh install # register (gh login), install, start; again to update the scripts
|
||||
# bash tools/ci/linux-runner.sh status # the services, the runner's state, the pause watcher's last lines
|
||||
@@ -12,10 +13,16 @@
|
||||
# never runs as the service). horizon-runner-pause.service (runner_pause.py) starts the runner only while nobody
|
||||
# uses the machine (screen locked or untouched for 15 min, no game), and stops it otherwise. The runner runs nice,
|
||||
# in horizon-ci.slice (low CPU and I/O weight, memory capped), on its own virtual screen: vscreen (a headless sway)
|
||||
# where it is installed, else Xvfb from nixpkgs with Mesa's Vulkan drivers.
|
||||
# where it is installed, else Xvfb with Mesa's Vulkan drivers (from nixpkgs on NixOS, from the system elsewhere).
|
||||
# HORIZON_SHARED_SOURCE: the imported vanilla data (default ~/horizon-local/shared-local, else
|
||||
# ~/code/horizon/.local); RUNNER_JOBS: cargo jobs and harnesses at once (default a third of the threads, at most 8:
|
||||
# ludodesktop froze under ~7 cold cargo builds on 2026-10-14, and it is the maintainer's own machine).
|
||||
# RUNNER_CPUS and RUNNER_MEMORY (GB): the slice's CPU quota and memory cap (default half the threads, two thirds of
|
||||
# the memory), for a machine that does nothing else. RUNNER_TOKEN: the registration (or, for uninstall, removal)
|
||||
# token, made with gh on another machine, where gh must not be logged in (a machine someone else also runs):
|
||||
# RUNNER_TOKEN=$(gh api -X POST repos/ludovic111/horizon/actions/runners/registration-token --jq .token)
|
||||
# Without Nix (Debian, Ubuntu), the packages come from apt (the list in system_packages) and python3.13 from the
|
||||
# PATH (uv python install 3.13, linked into ~/.local/bin).
|
||||
set -euo pipefail
|
||||
repo=ludovic111/horizon
|
||||
dir=$HOME/.actions-runners/horizon
|
||||
@@ -27,9 +34,16 @@ here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# Nix packages the jobs need, kept alive by GC roots in $dir/nix. nix-build prints the store path; the root's name
|
||||
# gets the output's suffix (alsa-dev-dev for alsa-lib.dev), so it is not read back from the link.
|
||||
nix_out() { nix-build '<nixpkgs>' -A "$1" -o "$dir/nix/$2" | tail -1; }
|
||||
nixos() { [ -d /run/current-system/sw ]; }
|
||||
system_packages="build-essential pkg-config cmake libasound2-dev libudev-dev sccache mesa-vulkan-drivers libvulkan1 xvfb
|
||||
libx11-6 libxcursor1 libxrandr2 libxi6 libxinerama1 libxkbcommon0 libxkbcommon-x11-0 libgl1 libegl1 rsync git curl"
|
||||
|
||||
# The runner is a .NET program: on NixOS its native libraries (libstdc++, ICU, OpenSSL) come from nix-ld.
|
||||
export LD_LIBRARY_PATH=/run/current-system/sw/share/nix-ld/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||
if nixos; then export LD_LIBRARY_PATH=/run/current-system/sw/share/nix-ld/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}; fi
|
||||
|
||||
token() {
|
||||
if [ -n "${RUNNER_TOKEN:-}" ]; then echo "$RUNNER_TOKEN"; else gh api -X POST "repos/$repo/actions/runners/$1" --jq .token; fi
|
||||
}
|
||||
# NixOS has no /bin/bash: the runner's scripts (again after each of its self-updates) get a portable one.
|
||||
fix_shebangs() { sed -i '1s|^#!/bin/bash|#!/usr/bin/env bash|' "$dir"/*.sh "$dir"/bin/*.sh; }
|
||||
|
||||
@@ -77,32 +91,59 @@ install() {
|
||||
fi
|
||||
tar xzf "$cache" -C "$dir"
|
||||
fix_shebangs
|
||||
gh api -X POST "repos/$repo/actions/runners/registration-token" --jq .token |
|
||||
token registration-token |
|
||||
(cd "$dir" && bash ./config.sh --unattended --replace --url "https://github.com/$repo" --token "$(cat)" \
|
||||
--name "$name" --labels "${RUNNER_LABELS:-horizon-game,$(hostname)}" --work _work > /dev/null)
|
||||
fi
|
||||
|
||||
# Libraries for building (pkg-config) and running (dlopen) the game, the JDK pinned by research-lock.json, sccache.
|
||||
local alsa udev java
|
||||
alsa=$(nix_out alsa-lib.dev alsa-dev)
|
||||
udev=$(nix_out systemd.dev systemd-dev)
|
||||
java=$(nix_out "jdk$(sed -n 's/.*"java_major": *\([0-9]*\).*/\1/p' "$here/../../research-lock.json" | head -1)_headless" jdk)/lib/openjdk
|
||||
nix_out sccache sccache > /dev/null # on the PATH below: runner-env.sh hands it to cargo
|
||||
local libs=/run/opengl-driver/lib:/run/current-system/sw/share/nix-ld/lib
|
||||
if ! command -v vscreen > /dev/null; then
|
||||
local mesa x
|
||||
mesa=$(nix_out mesa mesa)
|
||||
x=$(nix_out xvfb-run xvfb-run)
|
||||
for lib in libx11 libxcursor libxrandr libxi libxext libxinerama libxrender libxxf86vm libxcb libxkbcommon \
|
||||
vulkan-loader libGL; do
|
||||
libs=$libs:$(nix_out "$lib" "$lib")/lib
|
||||
done
|
||||
libs=$mesa/lib:$libs
|
||||
echo "VK_DRIVER_FILES=$mesa/share/vulkan/icd.d/intel_icd.x86_64.json:$mesa/share/vulkan/icd.d/lvp_icd.x86_64.json" \
|
||||
> "$dir/.env.display"
|
||||
echo "$x/bin" > "$dir/.path.display"
|
||||
local major java platform_env path
|
||||
major=$(sed -n 's/.*"java_major": *\([0-9]*\).*/\1/p' "$here/../../research-lock.json" | head -1)
|
||||
if nixos; then
|
||||
local alsa udev libs=/run/opengl-driver/lib:/run/current-system/sw/share/nix-ld/lib display_path=""
|
||||
alsa=$(nix_out alsa-lib.dev alsa-dev)
|
||||
udev=$(nix_out systemd.dev systemd-dev)
|
||||
java=$(nix_out "jdk${major}_headless" jdk)/lib/openjdk
|
||||
nix_out sccache sccache > /dev/null # on the PATH below: runner-env.sh hands it to cargo
|
||||
platform_env="PKG_CONFIG_PATH=$alsa/lib/pkgconfig:$udev/lib/pkgconfig
|
||||
C_INCLUDE_PATH=$udev/include
|
||||
NIX_LD=/run/current-system/sw/share/nix-ld/lib/ld.so
|
||||
NIX_LD_LIBRARY_PATH=/run/current-system/sw/share/nix-ld/lib"
|
||||
if ! command -v vscreen > /dev/null; then
|
||||
local mesa x
|
||||
mesa=$(nix_out mesa mesa)
|
||||
x=$(nix_out xvfb-run xvfb-run)
|
||||
for lib in libx11 libxcursor libxrandr libxi libxext libxinerama libxrender libxxf86vm libxcb libxkbcommon \
|
||||
vulkan-loader libGL; do
|
||||
libs=$libs:$(nix_out "$lib" "$lib")/lib
|
||||
done
|
||||
libs=$mesa/lib:$libs
|
||||
platform_env="$platform_env
|
||||
VK_DRIVER_FILES=$mesa/share/vulkan/icd.d/intel_icd.x86_64.json:$mesa/share/vulkan/icd.d/lvp_icd.x86_64.json"
|
||||
display_path=$x/bin:
|
||||
fi
|
||||
platform_env="$platform_env
|
||||
LD_LIBRARY_PATH=$libs"
|
||||
path="$dir/cargo/bin:$display_path$dir/nix/sccache/bin:$java/bin:$HOME/.local/bin:/run/wrappers/bin:/etc/profiles/per-user/$USER/bin:/run/current-system/sw/bin"
|
||||
else
|
||||
# apt's packages (installed here when sudo needs no password), its JDK, and Mesa's software Vulkan (lavapipe):
|
||||
# a server has no GPU.
|
||||
local missing
|
||||
missing=$(dpkg-query -W -f='${Package} ${Status}\n' $system_packages "openjdk-$major-jdk-headless" 2>&1 |
|
||||
awk '/^dpkg-query: no packages found matching/ {print $NF; next} !/ installed$/ {print $1}' | tr '\n' ' ')
|
||||
if [ -n "${missing// /}" ]; then
|
||||
sudo -n env DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $missing > /dev/null ||
|
||||
{ echo "Install first: sudo apt-get install $missing"; exit 1; }
|
||||
fi
|
||||
command -v python3.13 > /dev/null || [ -x "$HOME/.local/bin/python3.13" ] ||
|
||||
{ echo "No python3.13: uv python install 3.13, then link it into ~/.local/bin"; exit 1; }
|
||||
java=$(ls -d /usr/lib/jvm/java-"$major"-openjdk-* | head -1)
|
||||
platform_env=""
|
||||
command -v vscreen > /dev/null || platform_env="VK_DRIVER_FILES=$(ls /usr/share/vulkan/icd.d/lvp_icd*.json | head -1)"
|
||||
path="$dir/cargo/bin:$java/bin:$HOME/.local/bin:/usr/local/bin:/usr/bin:/bin"
|
||||
fi
|
||||
cat > "$dir/.env" <<EOF
|
||||
{
|
||||
cat <<EOF
|
||||
LANG=C.UTF-8
|
||||
RUSTUP_HOME=$dir/rustup
|
||||
CARGO_HOME=$dir/cargo
|
||||
@@ -115,25 +156,26 @@ HORIZON_NO_AUDIO=1
|
||||
HORIZON_NO_HEARTBEAT=1
|
||||
HORIZON_TELEMETRY_URL=off
|
||||
HORIZON_LAUNCHER_NO_SELF_UPDATE=1
|
||||
PKG_CONFIG_PATH=$alsa/lib/pkgconfig:$udev/lib/pkgconfig
|
||||
C_INCLUDE_PATH=$udev/include
|
||||
LD_LIBRARY_PATH=$libs
|
||||
NIX_LD=/run/current-system/sw/share/nix-ld/lib/ld.so
|
||||
NIX_LD_LIBRARY_PATH=/run/current-system/sw/share/nix-ld/lib
|
||||
EOF
|
||||
if [ -f "$dir/.env.display" ]; then cat "$dir/.env.display" >> "$dir/.env"; else echo "VSCREEN=ci-horizon" >> "$dir/.env"; fi
|
||||
echo "$dir/cargo/bin:$(cat "$dir/.path.display" 2>/dev/null || true)${dir}/nix/sccache/bin:$java/bin:$HOME/.local/bin:/run/wrappers/bin:/etc/profiles/per-user/$USER/bin:/run/current-system/sw/bin" \
|
||||
| sed 's/::/:/g' > "$dir/.path"
|
||||
[ -n "$platform_env" ] && echo "$platform_env"
|
||||
command -v vscreen > /dev/null && echo "VSCREEN=ci-horizon"
|
||||
true
|
||||
} > "$dir/.env"
|
||||
echo "$path" > "$dir/.path"
|
||||
rm -f "$dir/.env.display" "$dir/.path.display" # written by older versions of this script
|
||||
|
||||
local memory cpus
|
||||
memory=${RUNNER_MEMORY:-$(( $(awk '/MemTotal/ {print int($2 / 1048576)}' /proc/meminfo) * 2 / 3 ))}
|
||||
cpus=${RUNNER_CPUS:-$(( threads / 2 > 1 ? threads / 2 : 1 ))}
|
||||
cat > "$units/horizon-ci.slice" <<EOF
|
||||
[Unit]
|
||||
Description=Horizon CI: the runner's jobs and parity workers sent from other machines
|
||||
[Slice]
|
||||
CPUWeight=20
|
||||
IOWeight=20
|
||||
CPUQuota=$(( threads * 50 ))%
|
||||
MemoryHigh=$(( $(awk '/MemTotal/ {print int($2 / 1048576)}' /proc/meminfo) / 2 ))G
|
||||
MemoryMax=$(( $(awk '/MemTotal/ {print int($2 / 1048576)}' /proc/meminfo) * 2 / 3 ))G
|
||||
CPUQuota=$(( cpus * 100 ))%
|
||||
MemoryHigh=$(( memory * 3 / 4 ))G
|
||||
MemoryMax=${memory}G
|
||||
EOF
|
||||
cat > "$units/horizon-runner.service" <<EOF
|
||||
[Unit]
|
||||
@@ -156,6 +198,7 @@ EOF
|
||||
Description=Runs the Horizon CI runner only while nobody uses the machine or plays on it
|
||||
[Service]
|
||||
ExecStart=$(command -v python3) $dir/runner_pause.py
|
||||
Environment=NORMAL_CPUS=$cpus
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
[Install]
|
||||
@@ -201,7 +244,7 @@ status() {
|
||||
|
||||
uninstall() {
|
||||
systemctl --user disable --now horizon-runner-pause.service horizon-runner.service 2>/dev/null || true
|
||||
gh api -X POST "repos/$repo/actions/runners/remove-token" --jq .token |
|
||||
token remove-token |
|
||||
(cd "$dir" && bash ./config.sh remove --token "$(cat)")
|
||||
rm -f "$units/horizon-runner.service" "$units/horizon-runner-pause.service" "$units/horizon-ci.slice"
|
||||
systemctl --user daemon-reload
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# The tools the vanilla harnesses need, on a self-hosted runner (label horizon-game): the Mac mini's, whose service
|
||||
# starts with a bare PATH, and the Linux ones (tools/ci/linux-runner.sh, NixOS). Python 3.13 and the JDK pinned by
|
||||
# starts with a bare PATH, and the Linux ones (tools/ci/linux-runner.sh: NixOS, Ubuntu). Python 3.13 and the JDK pinned by
|
||||
# research-lock.json come from the machine, never from a download. Writes them to $GITHUB_PATH and $GITHUB_ENV for
|
||||
# the next steps.
|
||||
set -euo pipefail
|
||||
|
||||
+105
-2
@@ -290,7 +290,15 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
GUEST_NAME = 'Guest'
|
||||
# Match normal single player; --in-frame is the comparison path.
|
||||
SERVER_THREAD = True
|
||||
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'arrows', 'kills', 'hurt', 'looks', 'leads', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'styles', 'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing', 'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'thrown', 'sparks', 'hud', 'sidebar', 'border', 'particles', 'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth', 'doors', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'hands', 'lightning', 'riding', 'mounts', 'worldspawn', 'beds', 'shield', 'deathmining', 'contacts', 'absorption', 'breath', 'lava', 'levels', 'drops', 'underwater']
|
||||
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp',
|
||||
'arrows', 'kills', 'hurt', 'looks', 'leads', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'styles',
|
||||
'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing',
|
||||
'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push',
|
||||
'eat', 'eating', 'xp', 'objects', 'projectiles', 'thrown', 'sparks', 'hud', 'sidebar', 'border', 'particles',
|
||||
'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects',
|
||||
'portals', 'distance', 'growth', 'doors', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'hands',
|
||||
'lightning', 'riding', 'mounts', 'worldspawn', 'beds', 'shield', 'deathmining', 'contacts', 'absorption',
|
||||
'breath', 'lava', 'levels', 'drops', 'underwater', 'fireworks']
|
||||
|
||||
|
||||
class Game:
|
||||
@@ -2898,6 +2906,55 @@ def sparked(player, other, kinds, act, ticks=20):
|
||||
return seen
|
||||
|
||||
|
||||
def check_fireworks(host, guest, out):
|
||||
"""Event 17 must arrive before removal, with the item's colored, trailing explosion (#1478).
|
||||
|
||||
FireworkRocketEntity.explode / handleEntityEvent; run with and without --server-thread.
|
||||
The flash proves a configured explosion reached both clients; red pixels in later screenshots
|
||||
check that its sparks keep rendering after the tracked rocket disappears.
|
||||
"""
|
||||
x, y, z = (int(v // 1) for v in pos_of(host))
|
||||
at = (x, y - 1, z + 3)
|
||||
host('command', command=f'fill {x - 5} {y - 1} {z - 2} {x + 5} {y - 1} {z + 8} minecraft:stone')
|
||||
host('command', command=f'fill {x - 5} {y} {z - 2} {x + 5} {y + 4} {z + 8} minecraft:air')
|
||||
host('command', command=f'fill {x - 2} {y + 2} {z + 1} {x + 2} {y + 2} {z + 5} minecraft:stone')
|
||||
for game, dx in ((host, -2), (guest, 2)):
|
||||
game('command', command='gamemode creative')
|
||||
game('command', command=f'tp @s {x + dx + 0.5} {y} {z + 0.5}')
|
||||
game.raw('look-at', x + 0.5, y + 1.5, z + 3.5)
|
||||
|
||||
def red(path):
|
||||
rows, bpp = png_rows(path)
|
||||
# Exclude the hotbar and chat at the bottom of the view.
|
||||
return sum(row[i] > 80 and row[i] > 2 * row[i + 1] and row[i] > 2 * row[i + 2]
|
||||
for row in rows[:len(rows) * 3 // 4] for i in range(0, len(row), bpp))
|
||||
|
||||
baseline = {g.name: red(g.shot(out, 'fireworks-before')) for g in (host, guest)}
|
||||
before = {g.name: made(g, 'flash') for g in (host, guest)}
|
||||
host('command', command='item replace entity @s weapon.mainhand with minecraft:firework_rocket'
|
||||
'[fireworks={flight_duration:0,explosions:[{shape:"large_ball",colors:[I;16711680],has_trail:true}]}]')
|
||||
host.raw('interact', *at)
|
||||
# The held item's red texture must not count as a burst or a later spark.
|
||||
host('command', command='item replace entity @s weapon.mainhand with minecraft:air')
|
||||
for _ in range(30):
|
||||
host.wait(2)
|
||||
if all(made(g, 'flash') > before[g.name] for g in (host, guest)):
|
||||
break
|
||||
flashes = {g.name: made(g, 'flash') - before[g.name] for g in (host, guest)}
|
||||
assert all(n == 1 for n in flashes.values()), f'configured burst missing or duplicated: {flashes}'
|
||||
# Capture both views before decoding PNGs: decoding must not consume the sparks' lifetime.
|
||||
burst_shots = {g.name: g.shot(out, 'fireworks-burst') for g in (host, guest)}
|
||||
host.wait(16)
|
||||
trail_shots = {g.name: g.shot(out, 'fireworks-trail-fade') for g in (host, guest)}
|
||||
burst = {name: red(path) - baseline[name] for name, path in burst_shots.items()}
|
||||
trails = {name: red(path) - baseline[name] for name, path in trail_shots.items()}
|
||||
rockets = {g.name: g('status')['rockets'] for g in (host, guest)}
|
||||
assert not any(rockets.values()), f'exploded rocket remains: {rockets}'
|
||||
assert all(n > 20 for n in burst.values()), f'no red burst: {burst}'
|
||||
assert all(n > 20 for n in trails.values()), f'no later red trail/fade: {trails}'
|
||||
return {'flashes': flashes, 'red_burst': burst, 'red_trail_fade': trails, 'rockets': rockets}
|
||||
|
||||
|
||||
def check_sparks(host, guest, out):
|
||||
spots = apart(host, guest)
|
||||
result = {}
|
||||
@@ -4631,7 +4688,7 @@ CHECK_FNS = {'tab': check_tab, 'self': check_self, 'armour': check_armour,
|
||||
'hud': check_hud,
|
||||
'sidebar': check_sidebar,
|
||||
'border': check_border,
|
||||
'particles': check_particles}
|
||||
'particles': check_particles, 'fireworks': check_fireworks}
|
||||
|
||||
|
||||
def run(ctl, out, resources, checks):
|
||||
@@ -7039,5 +7096,51 @@ CHECKS += ['sonic']
|
||||
CHECK_FNS['sonic'] = check_sonic
|
||||
|
||||
|
||||
def check_cushions(host, guest, out):
|
||||
"""#1935: place a colored cushion, consume it, track it, sit, dismount and break it."""
|
||||
seen = {}
|
||||
for label, player, color in (('host', host, 'red'), ('guest', guest, 'blue')):
|
||||
x, y, z = (int(v // 1) for v in pos_of(player))
|
||||
at = (x + 0.5, y, z + 2.5)
|
||||
host('command', command=f'fill {x - 1} {y} {z + 1} {x + 1} {y + 3} {z + 3} minecraft:air')
|
||||
host('command', command=f'setblock {x} {y - 1} {z + 2} minecraft:stone')
|
||||
player('command', command='gamemode survival')
|
||||
player('command', command=f'item replace entity @s weapon.mainhand with minecraft:{color}_cushion')
|
||||
player.wait(10)
|
||||
player.raw('look-at', *at)
|
||||
player.raw('mouse', 'right', 'click')
|
||||
player.wait(15)
|
||||
def cushions(game):
|
||||
return [o for o in game('status')['objects'] if o['kind'] == 'minecraft:cushion'
|
||||
and abs(o['position'][0] - at[0]) < .1 and abs(o['position'][2] - at[2]) < .1]
|
||||
server, client = cushions(host), cushions(player)
|
||||
seen[label] = {'server': server, 'client': client,
|
||||
'remaining': player('inventory')['counts'].get(f'minecraft:{color}_cushion', 0)}
|
||||
assert len(server) == len(client) == 1, seen
|
||||
assert server[0]['color'] == client[0]['color'] == color, seen
|
||||
assert seen[label]['remaining'] == 0, seen
|
||||
player.shot(out, 'cushion-placed')
|
||||
player.raw('look-at', at[0], at[1] + .125, at[2])
|
||||
player.raw('mouse', 'right', 'click')
|
||||
player.wait(10)
|
||||
seen[label]['riding'] = player('status').get('riding')
|
||||
assert seen[label]['riding'] == server[0]['id'], seen
|
||||
player.raw('key', 'shift', 'down')
|
||||
player.wait(5)
|
||||
player.raw('key', 'shift', 'up')
|
||||
player.wait(5)
|
||||
assert player('status').get('riding') is None, seen
|
||||
player('command', command='gamemode creative')
|
||||
player.raw('look-at', at[0], at[1] + .125, at[2])
|
||||
player.raw('mouse', 'left', 'click')
|
||||
player.wait(10)
|
||||
assert not cushions(host) and not cushions(player), seen
|
||||
return seen
|
||||
|
||||
|
||||
CHECKS += ['cushions']
|
||||
CHECK_FNS['cushions'] = check_cushions
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -20,6 +20,16 @@
|
||||
"nice": 19,
|
||||
"note": "ludodesktop, the maintainer's own machine: only while nobody uses it (tools/ci/runner_pause.py: screen locked or untouched for 15 min, no game; a paused desktop refuses workers and stops the running ones, whose harnesses then run here); 8 jobs at most, in the CI runner's environment and slice"
|
||||
},
|
||||
"playhorizon": {
|
||||
"ssh": "ludovic@playhorizon",
|
||||
"root": ".actions-runners/horizon/parity-host",
|
||||
"shell": "systemd-run --user --scope --quiet --slice=horizon-ci.slice --unit=horizon-parity-worker-$$ bash -c",
|
||||
"setup": "test ! -e ~/.actions-runners/horizon/paused && set -a && . ~/.actions-runners/horizon/.env && set +a && export PATH=$(cat ~/.actions-runners/horizon/.path) && unset WAYLAND_DISPLAY && export DISPLAY=:$(cat ~/.actions-runners/horizon/display)",
|
||||
"python": "python3.13",
|
||||
"jobs": 6,
|
||||
"nice": 10,
|
||||
"note": "a partner's server (Ubuntu, 8 EPYC threads, 30 GB, Detroit; tailnet only), used by nothing else: 6 jobs, in the CI runner's environment, slice and Xvfb screen (tools/ci/linux-runner.sh); the light Linux checks that used to go to the ThinkPad go here"
|
||||
},
|
||||
"thinkpad": {
|
||||
"ssh": "thinkpad",
|
||||
"root": "code/horizon-parity",
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Mods' quiet commands on Horizon's dedicated server, end to end (horizon_protocol::quiet).
|
||||
|
||||
Horizon's dedicated server (a flat world) and Horizon's headless client (`HORIZON_NET_REPORT`, the net
|
||||
harness), which joins, then sends a batch of quiet commands as a mod would (`HORIZON_NET_QUIET`):
|
||||
|
||||
- as a player who isn't an operator: `setblock` is refused (the block stays air), as it would be typed;
|
||||
- as an operator: `setblock` runs, a `fill` that changes nothing fails, and `say` is refused (a chat
|
||||
message needs the player's signature);
|
||||
- either way the player's chat gets nothing of them, and the server logs one line per batch: the player,
|
||||
the mod, how many ran and how many failed.
|
||||
|
||||
python3 tools/quiet_commands_e2e.py --bin-dir target/fast
|
||||
|
||||
The client runs with fresh HORIZON_HOME, launcher and XDG folders and without audio; the logs go to --out.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import lab # noqa: E402
|
||||
from integration_env import run_game # noqa: E402
|
||||
from test_dedicated_server_parity import Server # noqa: E402
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
PLAYER = 'Tester'
|
||||
PROPERTIES = {
|
||||
'online-mode': 'false',
|
||||
'white-list': 'false',
|
||||
'level-type': 'minecraft\\:flat',
|
||||
'generate-structures': 'false',
|
||||
'spawn-protection': '0',
|
||||
'view-distance': '3',
|
||||
'simulation-distance': '3',
|
||||
'pause-when-empty-seconds': '-1',
|
||||
}
|
||||
BLOCK = '2 -55 2'
|
||||
# What a player would see of these commands, were they typed.
|
||||
FEEDBACK = ['Changed the block', 'No blocks were filled', 'Unknown or incomplete command', 'hi from a mod',
|
||||
'Could not set the block']
|
||||
|
||||
|
||||
def join(binary, port, out, label, lines):
|
||||
"""The headless client joins, sends `lines` as one quiet batch and leaves: its report."""
|
||||
home = Path(tempfile.mkdtemp(prefix=f'quiet-{label}-'))
|
||||
report = out / f'{label}-report.json'
|
||||
# run_game gives the game fresh home, launcher and XDG folders.
|
||||
env = dict(HORIZON_NET_REPORT=str(report), HORIZON_NET_QUIET=';'.join(lines))
|
||||
with (out / f'{label}-client.log').open('w') as log:
|
||||
run_game([str(binary), '--resources', str(lab.RESOURCES), '--render-distance', '2',
|
||||
'--server', f'127.0.0.1:{port}', '--name', PLAYER],
|
||||
cwd=home, env=dict(os.environ, **env), stdout=log, stderr=subprocess.STDOUT, timeout=300,
|
||||
check=True)
|
||||
shutil.rmtree(home, ignore_errors=True)
|
||||
return json.loads(report.read_text())
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument('--bin-dir', help='a prebuilt horizon-client (default: build it with the fast profile)')
|
||||
parser.add_argument('--out', default=str(ROOT / '.local/quiet-commands-e2e'), help='logs go here')
|
||||
args = parser.parse_args()
|
||||
out = Path(args.out)
|
||||
shutil.rmtree(out, ignore_errors=True)
|
||||
out.mkdir(parents=True)
|
||||
if args.bin_dir:
|
||||
binary = Path(args.bin_dir) / 'horizon-client'
|
||||
else:
|
||||
subprocess.run(['cargo', 'build', '--profile', 'fast', '-p', 'horizon-client', '--bin', 'horizon-client'],
|
||||
cwd=ROOT, check=True)
|
||||
binary = Path(lab.cargo_target()) / 'fast' / 'horizon-client'
|
||||
port = lab.free_port()
|
||||
directory = out / 'server'
|
||||
directory.mkdir()
|
||||
props = dict(PROPERTIES, **{'server-port': str(port)})
|
||||
(directory / 'server.properties').write_text(''.join(f'{k}={v}\n' for k, v in props.items()),
|
||||
encoding='iso-8859-1')
|
||||
(directory / 'eula.txt').write_text('eula=true\n')
|
||||
server = Server([binary, '--resources', lab.RESOURCES, '--dedicated', '--nogui'], directory, 'server')
|
||||
failures = []
|
||||
|
||||
def check(what, ok, detail=''):
|
||||
print(('PASS ' if ok else 'FAIL ') + what + ('' if ok else f': {detail}'))
|
||||
if not ok:
|
||||
failures.append(what)
|
||||
|
||||
def test_block(want):
|
||||
"""The console's `execute if block`: 'Test passed' when the block is `want`."""
|
||||
before = len(server.lines)
|
||||
server.console(f'execute if block {BLOCK} {want}')
|
||||
deadline = time.time() + 30
|
||||
while time.time() < deadline:
|
||||
answer = [l for l in server.lines[before:] if 'Test passed' in l or 'Test failed' in l]
|
||||
if answer:
|
||||
return 'Test passed' in answer[0]
|
||||
time.sleep(0.2)
|
||||
raise AssertionError('the console never answered execute if block')
|
||||
|
||||
try:
|
||||
server.wait_for(r'Done \(')
|
||||
# Not an operator: the setblock is refused, as typed.
|
||||
got = join(binary, port, out, 'not-op', [f'setblock {BLOCK} minecraft:gold_block'])
|
||||
server.wait_for(rf'{PLAYER} ran 1 quiet command\(s\) from mod net_harness: 1 failed', timeout=30)
|
||||
check('not an operator: connected throughout', got['error'] is None, got['error'])
|
||||
check("not an operator: a quiet setblock is refused", not test_block('minecraft:gold_block'))
|
||||
heard = [c for c in got['chat'] if any(f in c for f in FEEDBACK)]
|
||||
check('not an operator: nothing in the chat', not heard, heard)
|
||||
server.wait_for(rf'{PLAYER} left the game', timeout=60)
|
||||
# An operator: it runs, quietly.
|
||||
server.console(f'op {PLAYER}')
|
||||
server.wait_for(rf'Made {PLAYER} a server operator', timeout=30)
|
||||
got = join(binary, port, out, 'op', [f'setblock {BLOCK} minecraft:gold_block',
|
||||
f'fill {BLOCK} {BLOCK} minecraft:gold_block', 'say hi from a mod'])
|
||||
server.wait_for(rf'{PLAYER} ran 3 quiet command\(s\) from mod net_harness: 2 failed', timeout=30)
|
||||
check('operator: connected throughout', got['error'] is None, got['error'])
|
||||
check('operator: the quiet setblock ran', test_block('minecraft:gold_block'))
|
||||
heard = [c for c in got['chat'] if any(f in c for f in FEEDBACK)]
|
||||
check('operator: nothing in the chat (no feedback, no failure, no say)', not heard, heard)
|
||||
said = [l for l in server.lines if 'hi from a mod' in l]
|
||||
check('operator: say is refused', not said, said)
|
||||
finally:
|
||||
server.stop()
|
||||
print(f'logs: {out}')
|
||||
sys.exit(1 if failures else 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compare cushion support, burial and coverage against vanilla's real checks."""
|
||||
import json
|
||||
import random
|
||||
|
||||
try:
|
||||
from . import lab, oracle_harness as harness
|
||||
except ImportError:
|
||||
import lab, oracle_harness as harness
|
||||
|
||||
|
||||
def make_input(build):
|
||||
full = [[0, 0, 0, 1, 1, 1]]
|
||||
shapes = [[], full, [[0, 0, 0, 1, .5, 1]], [[0, .5, 0, 1, 1, 1]],
|
||||
[[.375, 0, .375, .625, 1.5, .625]], [[0, 0, 0, .5, 1, 1]],
|
||||
[[0, 0, 0, .5, 1, 1], [.5, 0, 0, 1, 1, 1]]]
|
||||
rows = []
|
||||
for x, z in ((0, 0), (-2, -3), (17, 31)):
|
||||
for y in (0, .125, .5, .875, 1, 1.00000001, 1.015625, 1.125):
|
||||
for outline in shapes:
|
||||
for collision in shapes:
|
||||
for suffocating in (False, True):
|
||||
rows.append(dict(pos=[x + .5, y, z + .5],
|
||||
cells=[[x, 0, z, outline, collision, suffocating]]))
|
||||
rng = random.Random(1935)
|
||||
for _ in range(500):
|
||||
cells = []
|
||||
for y in (-1, 0, 1):
|
||||
for x in (-1, 0, 1):
|
||||
for z in (-1, 0, 1):
|
||||
if rng.random() < .3:
|
||||
cells.append([x, y, z, rng.choice(shapes), rng.choice(shapes), bool(rng.randrange(2))])
|
||||
rows.append(dict(pos=[rng.choice((0, .5, 1)), rng.choice((0, .5, 1, 1.125)), rng.choice((0, .5, 1))], cells=cells))
|
||||
path = build / 'inputs.jsonl'
|
||||
path.write_text(''.join(json.dumps(row) + '\n' for row in rows))
|
||||
return path, len(rows)
|
||||
|
||||
|
||||
def main():
|
||||
harness.differential(
|
||||
'rust-cushion-placement-parity', 'VanillaCushionPlacementOracle',
|
||||
'cushion_placement_probe', make_input,
|
||||
'Actual Cushion.canBePlacedAt and wouldSurviveAt, with controlled outline, collision '
|
||||
'and suffocation queries. Includes partial supports, burial, complete coverage, '
|
||||
'overhanging outlines, negative coordinates and boundary heights. Item use, '
|
||||
'entity tracking, interaction and persistence are checked separately.',
|
||||
sources=[lab.ROOT / 'crates/horizon-client/src/cushion.rs'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -519,7 +519,9 @@ def main():
|
||||
# The oracle's server world: cleared before each run, never left in /tmp.
|
||||
world = build / 'world'
|
||||
shutil.rmtree(world, ignore_errors=True)
|
||||
oracle_harness.run_logged(['java', '-Xmx3g', '-Djava.awt.headless=true', '-cp', str(classes) + os.pathsep + dependencies,
|
||||
# Each scenario forces 9x9 chunks 512 blocks past the last one, so a run generates ~80 chunks per scenario;
|
||||
# 3g ran out of heap in PoiManager.tick on a busy runner (#2160's CI, 143 scenarios).
|
||||
oracle_harness.run_logged(['java', '-Xmx4g', '-Djava.awt.headless=true', '-cp', str(classes) + os.pathsep + dependencies,
|
||||
'dev.horizonlab.parity.VanillaMobAiOracle', inputs, build / 'vanilla.txt', world],
|
||||
build, 'vanilla', timeout=3600)
|
||||
if not args.java_only:
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
"""FireworkRocketEntity event 17 renders the configured burst before tracked removal.
|
||||
|
||||
Exercise both hosting paths and subsequent trail/fade frames through real clients.
|
||||
"""
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
import lab
|
||||
import lan_e2e as lan
|
||||
|
||||
|
||||
def main():
|
||||
subprocess.run(['cargo', 'build', '--locked', '--profile', 'fast', '-p', 'horizon-client',
|
||||
'--bin', 'horizon-client', '--bin', 'horizon-ctl'], cwd=lab.ROOT, check=True)
|
||||
metadata = json.loads(subprocess.check_output(
|
||||
['cargo', 'metadata', '--format-version', '1', '--no-deps'], cwd=lab.ROOT, text=True))
|
||||
ctl = lab.ROOT / metadata['target_directory'] / 'fast' / 'horizon-ctl'
|
||||
# CI supplies the display; each game still gets fresh scratch homes.
|
||||
lan.game_env = lambda _screen, home: lab.game_env(
|
||||
HORIZON_HOME=home, HORIZON_TELEMETRY_URL='off')
|
||||
reports = {}
|
||||
for threaded in (True, False):
|
||||
lan.SERVER_THREAD = threaded
|
||||
mode = 'server-thread' if threaded else 'in-frame'
|
||||
out = lab.LOCAL / 'remote-fireworks-parity' / mode
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
reports[mode] = lan.run(ctl, out, lab.RESOURCES.resolve(), ['fireworks'])
|
||||
lab.write_json(lab.LOCAL / 'remote-fireworks-parity' / 'report.json', reports)
|
||||
assert all(r['pass'] for mode in reports.values() for r in mode.values()), reports
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user