Merge remote-tracking branch 'upstream/main' into fix/piston-entity-push

This commit is contained in:
levzzz
2026-10-27 02:22:04 +05:00
25 changed files with 1086 additions and 93 deletions
+39 -1
View File
@@ -14,6 +14,8 @@ address. The script then checks, from both sides, what a guest's game used to ge
closes on both when the guest closes it; the host keeps playing with its mouse look (#687);
- crafting: the guest crafts planks in the inventory's 2x2 grid and opens a crafting table, which
leaves the host's screen and mouse look alone;
- spawned: the host and a guest new to the world join on different spots (PlayerSpawnFinder), and the
guest opens a crafting table, a chest, a furnace and a stonecutter where it joined;
- sign: a sign the guest places doesn't open a sign editor on the host;
- damage: a guest in survival takes fall damage;
- mobs: with the host in creative, a zombie and a skeleton go for the guest and hurt them;
@@ -292,7 +294,7 @@ 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',
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'spawned', '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',
@@ -554,6 +556,39 @@ def check_crafting(host, guest, out):
return {'planks': planks, 'table': counts}
def check_spawned(host, guest, out):
"""Players new to a world don't share one spot: ServerPlayer.adjustSpawnLocation spreads them over the
respawn radius (PlayerSpawnFinder). Two players standing in each other target each other, so a guest
left in the host could open nothing it clicked. At its own spot, the guest opens a crafting table, a
chest, a furnace and a stonecutter."""
joined = {'host': [round(v, 2) for v in host.joined_at], 'guest': [round(v, 2) for v in guest.joined_at]}
apart = abs(joined['host'][0] - joined['guest'][0]) + abs(joined['host'][2] - joined['guest'][2]) >= 0.6
guest('command', command='gamemode survival')
for game in (host, guest):
x, y, z = game.joined_at
game('command', command=f'tp @s {x} {y} {z}')
guest.wait(20)
x, y, z = (int(v // 1) for v in pos_of(guest))
at = (x, y, z + 2)
grab(host)
opened = {}
for block in ('crafting_table', 'chest', 'furnace', 'stonecutter'):
guest('command', command=f'setblock {at[0]} {at[1]} {at[2]} minecraft:{block}')
guest.wait(10)
guest.raw('interact', *at)
guest.wait(10)
opened[block] = guest('state').get('screen')
guest.shot(out, f'spawned-{block}')
back_to_game(guest)
guest('command', command=f'setblock {at[0]} {at[1]} {at[2]} minecraft:air')
host_unaffected(host, "the guest's stations")
face_each_other(host, guest)
assert apart, f'the host and the guest joined on one spot: {joined}'
want = {'crafting_table': 'inventory', 'chest': 'container', 'furnace': 'container', 'stonecutter': 'station'}
assert opened == want, f'where it joined, the guest opened {opened}'
return {'joined': joined, 'opened': opened}
def check_sign(host, guest, out):
x, y, z = (int(v // 1) for v in pos_of(guest))
spot = (x + 2, y, z)
@@ -4722,6 +4757,7 @@ def check_worn(host, guest, out):
CHECK_FNS = {'tab': check_tab, 'self': check_self, 'armour': check_armour,
'nametags': check_nametags, 'chest': check_chest, 'crafting': check_crafting,
'spawned': check_spawned,
'sign': check_sign, 'damage': check_damage, 'mobs': check_mobs,
'hazards': check_hazards, 'pvp': check_pvp, 'respawn': check_respawn,
'containers': check_containers, 'feedback': check_feedback, 'titles': check_titles,
@@ -4780,6 +4816,8 @@ def run(ctl, out, resources, checks):
guest.raw('connect', f'127.0.0.1:{port}', GUEST_NAME)
guest.raw('wait-for', 'loaded', '--timeout', 300)
guest.wait(40)
# Where each joined, before anything moves them (check_spawned).
host.joined_at, guest.joined_at = pos_of(host), pos_of(guest)
face_each_other(host, guest)
host.shot(out, 'joined')
guest.shot(out, 'joined')
-1
View File
@@ -44,7 +44,6 @@
"lan_integration": "the whole lan_e2e suite: ~40 min a run on a loaded runner, and single checks flake under load; run it by name, or tools/lan_e2e.py"
},
"known_flaky": {
"dedicated_server": "its Java client moves to the next step on a 1.5 s timer, not on the server's reply: under load a respawn's add_entity/update_attributes or entity_event 19 lands in the wrong step (failed, then passed at the same head, 10-26)",
"remote_fireball": "samples the fireball on the wall clock, so a slow host sees it in too few samples (desktop runner, 3 times on 10-26)",
"world_reopen": "counted 4 minecarts instead of 3 once on a loaded Mac mini runner, then passed at the same head (10-26)"
}
+37 -24
View File
@@ -7,12 +7,13 @@
python3 tools/pr_ready.py --quick # without running the vanilla harnesses
From the files the branch changes since its merge base with --base (committed or not) it decides what to run:
rustfmt, clippy with warnings denied and the tests of the touched crates; the launcher (its own workspace) the
same way when it, horizon-prepare or horizon-theme changed; crates/horizon-theme/tokens.css against horizon-theme;
Cargo.lock changing only with a Cargo.toml; the Python tests and the public-tree check; and the vanilla
harnesses the changes can affect, picked as CI's parity job picks them (tools/parity.py --changed). Harnesses run
where the vanilla data is (a prepared .local/ here, or the Mac mini); elsewhere they are listed for CI.
Clippy checks all targets of touched crates and their transitive workspace dependents, including examples.
rustfmt, and clippy with warnings denied exactly as CI's verify job runs it (the whole workspace with the game's code
mods, plus the server build when horizon-client is affected); the tests of the touched crates, with the features
CI's workspace-wide run gives them; the launcher (its own workspace) the same way when CI's launcher job would run
(tools/ci/rust_changes.py --launcher); crates/horizon-theme/tokens.css against horizon-theme; Cargo.lock changing
only with a Cargo.toml; the Python tests (always, as in CI) and the public-tree check; and the vanilla harnesses the
changes can affect, picked as CI's parity job picks them (tools/parity.py --changed). Harnesses run where the
vanilla data is (a prepared .local/ here, or the Mac mini); elsewhere they are listed for CI.
Tests select library, binary and integration targets explicitly, followed by doc tests, so unrelated example
executables are not built and linked again.
@@ -43,6 +44,7 @@ if "PARITY_SHARED" not in os.environ and not (ROOT / ".local" / "minecraft").exi
# A fleet worktree without vanilla data still knows each harness's dependencies.
os.environ["PARITY_SHARED"] = str(FLEET_SHARED)
from tools import parity, release_train # noqa: E402
from tools.ci import rust_changes # noqa: E402
RBUILD = Path.home() / "fleet" / "rbuild"
LINE_LIMIT = 500
@@ -82,9 +84,8 @@ def workspace_rust(path):
def launcher_rust(path):
"""Whether a change to path is built into the launcher (its own workspace)."""
return not is_doc(path) and any(path.startswith(p) for p in release_train.LAUNCHER_PATHS) and \
path != "launcher/links.json" and not path.startswith("launcher/docs/")
"""Whether a change to path is built into the launcher (its own workspace): CI's launcher job's own rule."""
return rust_changes.needs_launcher([path])
def touched_crates(paths, packages):
@@ -268,14 +269,25 @@ def parity_summary(output):
return text
# CI's verify job (.github/workflows/ci.yml): clippy over the whole workspace with the game's code mods, and over the
# server build (the game without sound or controllers); tests with code mods and mod packaging.
CI_CLIPPY = "cargo clippy --workspace --all-targets --locked --features horizon-client/mods -- -D warnings"
CI_CLIPPY_SERVER = "cargo clippy -p horizon-client --all-targets --locked --no-default-features -- -D warnings"
CI_TEST_FEATURES = "horizon-client/mods,horizon-mods/pack"
def mod_features(crates):
"""Code mods are off by default (docs/mods.md): on wherever horizon-mods is checked, as in CI."""
if crates is not None and "horizon-mods" not in crates:
return ""
features = ["horizon-mods/runtime", "horizon-mods/pack"]
if crates is None or "horizon-client" in crates:
"""The features CI's workspace-wide test run gives these crates (code mods are off by default: docs/mods.md).
Cargo unifies features over the packages it builds, so a crate tested alone needs the ones the workspace would
have turned on for it: horizon-client's code mods, and horizon-mods' runtime, packaging and index."""
if crates is None:
return f" --features {CI_TEST_FEATURES}"
features = []
if "horizon-mods" in crates:
features += ["horizon-mods/runtime", "horizon-mods/pack", "horizon-mods/index"]
if "horizon-client" in crates:
features.append("horizon-client/mods")
return f" --features {','.join(features)}"
return f" --features {','.join(features)}" if features else ""
def plan(args, base, changed, crates_of, libraries, dependencies):
@@ -283,16 +295,18 @@ def plan(args, base, changed, crates_of, libraries, dependencies):
rust = any(workspace_rust(path) for path in changed)
launcher = any(launcher_rust(path) for path in changed)
# The Python tests also hold ROADMAP.md to roadmap/roadmap.toml (tests/test_roadmap.py).
python = any(path.endswith(".py") or path.startswith(("tests/", "tools/", "roadmap/")) or path == "ROADMAP.md"
for path in changed)
crates = touched_crates(changed, crates_of) if rust else []
# An unrecognised Rust path must not silently skip validation.
if rust and crates == []:
crates = None
selection = "--workspace" if crates is None else " ".join(f"-p {shlex.quote(c)}" for c in crates)
# CI's own clippy commands: a crate checked alone gets other features than in CI's workspace-wide run, and an
# unused import behind a feature passed here and failed in CI (#1895). Warm, the workspace run costs about what
# the touched crates and their dependents did (14-32 s against 14-17 s on the Mac mini, 2026-10-26).
clippy_crates = dependent_crates(crates, dependencies)
clippy_selection = "--workspace" if clippy_crates is None else " ".join(
f"-p {shlex.quote(c)}" for c in clippy_crates)
clippy = CI_CLIPPY
if clippy_crates is None or "horizon-client" in clippy_crates:
clippy += f" && {CI_CLIPPY_SERVER}"
test_skip = None if crates is None or crates else "no crate touched"
doc_crates = sorted(libraries if crates is None else libraries.intersection(crates))
doc_selection = "--workspace" if crates is None else " ".join(f"-p {shlex.quote(c)}" for c in doc_crates)
@@ -300,11 +314,10 @@ def plan(args, base, changed, crates_of, libraries, dependencies):
steps = [
Step("Cargo.lock", where="git"),
Step("Public tree", "python3 tools/check_public_tree.py", where="here"),
Step("Python tests", "python3 -m unittest discover -s tests", where="here",
skip=None if python else "no Python change", summary=unittest_passed),
# Always, as in CI: some read the crates, the roadmap or the workflows.
Step("Python tests", "python3 -m unittest discover -s tests", where="here", summary=unittest_passed),
Step("rustfmt", "cargo fmt --all -- --check", skip=None if rust else no_rust),
Step("clippy", f"cargo clippy {clippy_selection}{mod_features(clippy_crates)} --all-targets --locked -- -D warnings",
skip=None if rust else no_rust),
Step("clippy", clippy, skip=None if rust else no_rust),
Step("tests" + (": workspace" if crates is None else f": {', '.join(crates)}" if crates else ""),
f"cargo test --locked {selection}{mod_features(crates)} --tests",
skip=test_skip, summary=tests_passed),
@@ -404,7 +417,7 @@ def run_windows(steps, verbose):
elif step.name == "rustfmt":
command = ["cargo", "fmt", "--all", "--", "--check"]
elif step.name == "clippy":
command = ["cargo", "clippy", "--workspace", "--all-targets", "--locked", "--", "-D", "warnings"]
command = shlex.split(CI_CLIPPY) # the server build's clippy runs in CI (Linux)
elif step.name.startswith("tests"):
command = shlex.split(step.command)
elif step.name == "tokens.css up to date":
+104
View File
@@ -0,0 +1,104 @@
#!/usr/bin/env bash
# Run a command on a Linux build host (default playhorizon) at a worktree's commit, and get its output back.
#
# tools/remote.sh [--host H] [--name N] [--cpus LIST] [--jobs J] <worktree> <command...>
# tools/remote.sh .claude/worktrees/my-fix cargo test -p horizon-world --lib
# tools/remote.sh . python3 tools/parity.py food light
# tools/remote.sh --list # checkouts on the host, their size and last use
# tools/remote.sh --gc [DAYS] # remove checkouts unused for DAYS (default 2)
#
# The host fetches the commit from GitHub itself: commit and push first (uncommitted changes are not sent, and
# nothing else leaves this machine: no files, no credentials, no environment). Each name (default: the worktree's
# folder) keeps one checkout there, ~/remote-work/<name>, with its own target/: the next run checks out the new
# commit over it, so only what changed rebuilds (sccache shares the registry crates between names). One run per
# name at a time. The command runs in bash at the checkout's root, niced in the host's CI slice, with the host's
# toolchains, a virtual screen and scratch homes for the game and launcher. .local/ links to the host's vanilla
# data; a command that runs harnesses (it names parity, lan_e2e or horizon-prepare) also gets .local/horizon-client,
# prepared as CI prepares it (tools/ci/vanilla-data.sh). Output streams back and is kept in ~/remote-work/<name>.logs/.
# The exit status is the command's.
#
# The host is lent by a partner who keeps hypervisor access: never send secrets, tokens or credentials there,
# and never treat a result from it as a CI result.
set -euo pipefail
# CPUs 0-3 stay free for benchmarks (perf-world-entry measures on playhorizon pinned to them); --cpus all for every one.
host=playhorizon name="" jobs="" cpus=4-7
usage() { sed -n '2,8s/^# \{0,1\}//p' "$0" >&2; exit 2; }
while [ $# -gt 0 ]; do
case $1 in
--host) host=$2; shift 2;;
--name) name=$2; shift 2;;
--jobs) jobs=$2; shift 2;;
--cpus) cpus=$2; shift 2;;
--list) exec ssh "ludovic@$host" 'cd ~/remote-work 2>/dev/null && for d in */; do d=${d%/};
printf "%-32s %8s last used %s\n" "$d" "$(du -sh "$d" 2>/dev/null | cut -f1)" "$(stat -c %y "$d.logs" 2>/dev/null | cut -c1-16)"; done';;
--gc) days=${2:-2}; exec ssh "ludovic@$host" "cd ~/remote-work 2>/dev/null || exit 0
find . -maxdepth 1 -name '*.logs' -mtime +$days | while read -r logs; do d=\${logs%.logs};
flock -n \"\$d.lock\" rm -rf \"\$d\" \"\$logs\" \"\$d.lock\" && echo \"removed \${d#./}\"; done";;
-h|--help) usage;;
*) break;;
esac
done
[ $# -ge 2 ] || usage
tree=$(cd "$1" && git rev-parse --show-toplevel); shift
sha=$(git -C "$tree" rev-parse HEAD)
name=${name:-$(basename "$tree")}
[[ $name =~ ^[A-Za-z0-9._-]+$ ]] || { echo "remote.sh: name '$name' must be letters, digits, . _ -" >&2; exit 2; }
if ! git -C "$tree" diff --quiet HEAD -- 2>/dev/null; then
echo "remote.sh: uncommitted changes in $tree are not sent: the host runs ${sha:0:9}" >&2
fi
if [ -z "$(git -C "$tree" branch -r --contains "$sha" 2>/dev/null)" ]; then
git -C "$tree" fetch -q origin 2>/dev/null || true
[ -n "$(git -C "$tree" branch -r --contains "$sha" 2>/dev/null)" ] ||
{ echo "remote.sh: ${sha:0:9} is not on GitHub yet: push it first (the host fetches from GitHub)" >&2; exit 2; }
fi
command=$(printf '%q ' "$@")
# The host side reads its script and these four values on stdin (nothing is re-split by a remote shell); its
# own environment comes from the runner's files there.
{
printf 'name=%q sha=%q jobs=%q cpus=%q command=%q\n' "$name" "$sha" "$jobs" "$cpus" "$command"
cat <<'REMOTE'
set -euo pipefail
if [ "$cpus" = all ]; then pin=(); jobs=${jobs:-$(nproc)}; else pin=(taskset -c "$cpus"); jobs=${jobs:-$(taskset -c "$cpus" nproc)}; fi
runner=~/.actions-runners/horizon
if [ -e "$runner/paused" ]; then echo "remote.sh: this host is paused ($runner/paused)" >&2; exit 75; fi
set -a; . "$runner/.env"; set +a
export PATH="$(cat "$runner/.path")" DISPLAY=":$(cat "$runner/display")" RUSTC_WRAPPER="$(command -v sccache || true)"
export CARGO_BUILD_JOBS=$jobs FLEET_LOAD_JOBS=$jobs PARITY_LOCAL_JOBS=$(( jobs > 1 ? jobs / 2 : 1 ))
unset WAYLAND_DISPLAY
mkdir -p ~/remote-work && cd ~/remote-work
exec 9> "$name.lock"
flock -n 9 || { echo "remote.sh: $name is busy with another run" >&2; exit 75; }
if [ ! -d "$name/.git" ]; then
git clone -q --filter=blob:none --no-checkout https://github.com/ludovic111/horizon "$name" 9>&-
fi
cd "$name"
# The lock's descriptor stays out of everything started here (9>&-): a daemon one of them starts (sccache's server,
# from the preparer's build or the command's) would hold the lock after the run.
git fetch -q --no-tags origin "$sha" 9>&-
git checkout -q --force --detach "$sha"
git clean -qfd -e /target -e /.local
# The host's vanilla data, linked as CI's runner links it; for harnesses also .local/horizon-client, prepared by
# this commit's own preparer (once per preparer version, kept beside the data and shared by every name).
if [[ $command =~ parity|lan_e2e|horizon-prepare ]]; then
RUNNER_WORKSPACE=$(dirname "$HORIZON_SHARED_SOURCE") RUNNER_TEMP=$(mktemp -d) bash tools/ci/vanilla-data.sh >&2 9>&-
else
mkdir -p .local
for d in minecraft tools datagen; do
if [ -e "$HORIZON_SHARED_SOURCE/$d" ]; then ln -sfn "$HORIZON_SHARED_SOURCE/$d" ".local/$d"; fi
done
fi
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
export HORIZON_HOME=$scratch/game HORIZON_LAUNCHER_HOME=$scratch/launcher XDG_DATA_HOME=$scratch/data \
XDG_CONFIG_HOME=$scratch/config HORIZON_NO_AUDIO=1 HORIZON_LAUNCHER_NO_SELF_UPDATE=1 HORIZON_TELEMETRY_URL=off
mkdir -p "$HORIZON_HOME" "$HORIZON_LAUNCHER_HOME" "$XDG_DATA_HOME" "$XDG_CONFIG_HOME" ../"$name.logs"
log=../"$name.logs/$(date -u +%Y%m%dT%H%M%SZ)-${sha:0:9}.log"
echo "remote.sh: $(hostname) at ${sha:0:9} in ~/remote-work/$name, CPUs $cpus, -j $jobs; log ~/remote-work/${log#../}" >&2
status=0
systemd-run --user --scope --quiet --slice=horizon-ci.slice --unit="remote-$name-$$" \
"${pin[@]}" nice -n 10 bash -c "$command" 2>&1 < /dev/null 9>&- | tee "$log" || status=${PIPESTATUS[0]}
exit "$status"
REMOTE
} | ssh -o BatchMode=yes "ludovic@$host" bash -s