R1: Linux export pipeline (make dist, make dist-check)

make dist (tools/dist.sh) checks the official export templates against
tools/engine.sha512, installs only the Linux x86_64 ones into the
repo-local engine data, exports the "Linux" preset, checks the binary is
the verified release template, and packs
build/dist/tidewall-<version>-linux-x86_64.tar.gz with a .sha256:
tidewall.x86_64, tidewall.pck, a tidewall-server launcher that runs the
same game headless with clean SIGTERM handling, an example server.cfg,
README, VERSION, licences and asset provenance.

BuildInfo gives the version (application/config/version, now 0.9.0) and
the commit (build_commit.txt written by make dist, or .git in a
checkout). The main menu shows "Version 0.9.0 (commit)" and the server's
start log line carries version and commit.

make dist-check (tools/dist_check.sh) unpacks the package outside the
repo with HOME and XDG dirs in a temp dir and runs smoke against it
(new SMOKE_DIST mode), a whole bot match, and the exported game joining
the exported server over loopback.

A release template crashes on a call on null (exit 139) and ignores
invalid calls, so in package mode smoke's fault check expects only a
non-zero exit.

Closes #60

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 23:51:36 -05:00
co-authored by Claude Opus 5.5
parent 9ce0865c9b
commit 4439d9a84f
18 changed files with 533 additions and 9 deletions
+3
View File
@@ -11,3 +11,6 @@ build/
captures/ captures/
*.log *.log
__pycache__/ __pycache__/
# Written by make dist while exporting
build_commit.txt
+2
View File
@@ -47,6 +47,8 @@ continuity.
| `make style-captures` | Renders a hamlet and a dock with and without the woodcut print pass (`captures/style_*.png`). Needs Docker. | | `make style-captures` | Renders a hamlet and a dock with and without the woodcut print pass (`captures/style_*.png`). Needs Docker. |
| `make soak` | The 24-client network soak (N8): a real server and 24 headless `SoakPlayer` clients in three processes, each behind a `UdpRelay` adding 60 ms, +/-20 ms jitter and 2% loss each way, for two whole matches in real time (about 30 min, under `nice`). Fails on a world-hash mismatch, errors, unreadable packets, a client that didn't play every match, memory growth between matches, or a p99 tick over budget. `SOAK_MATCHES`, `SOAK_CLIENTS`, `SOAK_PROCS`, `SOAK_LATENCY`, `SOAK_JITTER`, `SOAK_LOSS` scale it. Results in `build/soak/report.txt`. | | `make soak` | The 24-client network soak (N8): a real server and 24 headless `SoakPlayer` clients in three processes, each behind a `UdpRelay` adding 60 ms, +/-20 ms jitter and 2% loss each way, for two whole matches in real time (about 30 min, under `nice`). Fails on a world-hash mismatch, errors, unreadable packets, a client that didn't play every match, memory growth between matches, or a p99 tick over budget. `SOAK_MATCHES`, `SOAK_CLIENTS`, `SOAK_PROCS`, `SOAK_LATENCY`, `SOAK_JITTER`, `SOAK_LOSS` scale it. Results in `build/soak/report.txt`. |
| `make bench` | H1: the server's p50/p99/max tick with 24 bots on three seeds, and the client's draw calls, triangles, objects and memory at six moments of a match (about 3 min, needs Docker). Fails on anything over the budgets in docs/ARCHITECTURE.md. Report in `build/bench/report.txt`. `BENCH_SEEDS`, `BENCH_TICKS`, `BENCH_CLIENT=0` scale it. | | `make bench` | H1: the server's p50/p99/max tick with 24 bots on three seeds, and the client's draw calls, triangles, objects and memory at six moments of a match (about 3 min, needs Docker). Fails on anything over the budgets in docs/ARCHITECTURE.md. Report in `build/bench/report.txt`. `BENCH_SEEDS`, `BENCH_TICKS`, `BENCH_CLIENT=0` scale it. |
| `make dist` | R1: exports the game with the official Godot templates (checked against `tools/engine.sha512`, installed into `.godot-home/`) to `build/dist/tidewall-<version>-linux-x86_64.tar.gz` with a `.sha256`. One binary and one pack: `tidewall.x86_64` is the game, `tidewall-server` runs it headless as the server. The version is `application/config/version` in project.godot; the commit goes in as `build_commit.txt` (`BuildInfo`). |
| `make dist-check` | R1: builds the package, unpacks it outside the repo with HOME and XDG dirs in a temp dir, and runs `SMOKE_DIST=<dir> tools/smoke.sh`, a whole bot match, and the exported game joining the exported server (about 2 min). |
| `make soak-selfcheck` | About a minute: tampers with one client's world and checks the soak's comparison catches it and only it. | | `make soak-selfcheck` | About a minute: tampers with one client's world and checks the soak's comparison catches it and only it. |
| `make server-package-check` | Builds the server image with `packaging/docker/compose.yaml`, waits for it to be healthy, checks it is non-root and read-only, joins it with a headless client and stops it with SIGTERM (N7, about 1.5 min). Needs Docker. See `packaging/README.md`. | | `make server-package-check` | Builds the server image with `packaging/docker/compose.yaml`, waits for it to be healthy, checks it is non-root and read-only, joins it with a headless client and stops it with SIGTERM (N7, about 1.5 min). Needs Docker. See `packaging/README.md`. |
| `make models` | Rebuilds every item model (`assets/models/items/*.obj`, with grip data in `.json`) and icon (`assets/icons/items/*.png`) from `tools/models/items.py` in headless Blender on the CPU. Materials are named after `Palette` colours; `ItemModels` paints them. | | `make models` | Rebuilds every item model (`assets/models/items/*.obj`, with grip data in `.json`) and icon (`assets/icons/items/*.png`) from `tools/models/items.py` in headless Blender on the CPU. Materials are named after `Palette` colours; `ItemModels` paints them. |
+11 -1
View File
@@ -1,7 +1,7 @@
# Tidewall build entry points. Everything runs headless with the repo-local engine. # Tidewall build entry points. Everything runs headless with the repo-local engine.
GODOT := tools/godot.sh GODOT := tools/godot.sh
.PHONY: bench build-captures poi-captures art figure figure-captures sea-captures models item-captures audio audio-check check import parse test test-selfcheck smoke capture-test terrain-capture binaries verify-engine bot-matches match match-captures client-check client-captures hud-captures style-captures menu-captures chart-captures discovery-check fuzz soak soak-selfcheck server-package-check .PHONY: bench dist dist-check build-captures poi-captures art figure figure-captures sea-captures models item-captures audio audio-check check import parse test test-selfcheck smoke capture-test terrain-capture binaries verify-engine bot-matches match match-captures client-check client-captures hud-captures style-captures menu-captures chart-captures discovery-check fuzz soak soak-selfcheck server-package-check
## A8: regenerates every sound in assets/audio/ from tools/audio/ (about 6 s). ## A8: regenerates every sound in assets/audio/ from tools/audio/ (about 6 s).
audio: import audio: import
@@ -46,6 +46,16 @@ item-captures: import
bench: import bench: import
@tools/bench.sh @tools/bench.sh
## R1: exports the game with the official templates into
## build/dist/tidewall-<version>-linux-x86_64.tar.gz (about 20 s).
dist: import
@tools/dist.sh
## R1: builds the package, unpacks it outside the repo, and runs smoke, a whole bot match
## and its game playing on its server there (about 2 minutes).
dist-check: import
@tools/dist_check.sh
## Everything that must pass before a push. ## Everything that must pass before a push.
check: verify-engine binaries parse test test-selfcheck smoke check: verify-engine binaries parse test test-selfcheck smoke
+49
View File
@@ -1089,3 +1089,52 @@ high-priority issues, and A3, A7, A12 and A13 deferred.
- v0.9 has started. About 59 hours remain to Monday 08:00. - v0.9 has started. About 59 hours remain to Monday 08:00.
**Next run:** H13 (the soak hash mismatch, the last v0.9 bug), then R1 (Linux export), which matters most for Monday. R1 depends on H1, so H1 (performance pass) should come before R1 or alongside it. **Next run:** H13 (the soak hash mismatch, the last v0.9 bug), then R1 (Linux export), which matters most for Monday. R1 depends on H1, so H1 (performance pass) should come before R1 or alongside it.
## 2026-11-14 (night): H1 and R1 done, H13 still open
**Start of run (23:03 ET Friday):** the lock was free and acquired fresh. The pull was a no-op and the tree was clean. The Agents category had nothing addressed to this task.
**H13 (#80), still open:** I took the issue's two leads further by reading the code, but couldn't settle it without a recurrence.
- `StructureSet.write_state` hashes `_next_id`, and a provisional piece pushes the client's `_next_id` to 2^30. `NetWorld.world_hash` builds its own buffer without `_next_id`, so that difference isn't in the hash. Ruled out.
- `grounded` only depends on terrain and fixed solids, never on neighbouring pieces, so a provisional neighbour can't change a server piece's flag. Ruled out.
- Still open: `ClientWorld.tick` only ever rises. I found no path where it passes the snapshot's tick while `replica.seq == world_seq`.
- The diagnostics from 0ddcb48 will name the differing part the next time a soak hits it.
**H1 (#54), closed: `make bench`.**
- `tools/bench.sh` and `tools/bench_report.gd`:
- the server with 24 bots, unthrottled, 12,000 ticks on seeds 2, 7 and 20261109;
- six client frames in the capture container, each reporting draw calls, shadow draws, primitives, objects, nodes, video and static memory. `tools/capture.gd` now adds a `render` field to every capture report.
- Budgets added to ARCHITECTURE: p99 tick 12 ms; 2,000 draw calls and 2,000,000 primitives per frame across all passes; 1 GiB video and 512 MiB static memory.
- **Before:** barge 2,197 draws (over budget), landed 612, built 613, final 815. **After:** barge 1,207, landed 430, built 457, final 685, with the same primitives. The fix: each figure part had one surface per colour, about 43 per figure, drawn again for shadows. `FigureRig` now merges each part into one surface per finish (coat, gilt, plain), with the colours as vertex colours (`vertex_color_is_srgb`). The figure close-up and the barge capture were opened and look the same.
- Server p50 is 0.53–0.66 ms and p99 1.9–2.1 ms. The max includes one tick of about 1.7 s per match, which is a bench artifact: unthrottled, the 15 s results screen passes in about 0.3 s, so the main thread waits for the worker building the next island. At 30 Hz the worker has 15 s.
- Real GPU frame rates are not measured (R6).
**R1 (#60): Linux export.**
- `make dist` (`tools/dist.sh`):
- checks the export templates' SHA-512 against `tools/engine.sha512`, and installs only `linux_release.x86_64`, `linux_debug.x86_64` and `version.txt` into `.godot-home/` (not Eric's home);
- exports the `Linux` preset (`export_presets.cfg`, which leaves out test/, tools/, captures/, build/, docs/ and packaging/);
- checks the exported binary is byte-identical to the verified template;
- packs `build/dist/tidewall-0.9.0-linux-x86_64.tar.gz` (29 MB) with a `.sha256`, using sorted names, owner 0 and the commit's mtime.
- Package contents:
- `tidewall.x86_64` (73.5 MB, the official release template);
- `tidewall.pck` (2.7 MB: scripts, scenes, and the imported audio, models and icons);
- `tidewall-server` (runs the same binary and pack headless as the dedicated server, turning SIGTERM into a clean stop);
- `server.cfg` (example);
- `README.md` (play, server, files, licence; from `packaging/dist/`);
- `VERSION` (version, commit, engine);
- `LICENSE`, `LICENSE-ASSETS`, `PROVENANCE.md`.
- **Version and commit:** `application/config/version` in project.godot is now `0.9.0`. R5 makes it 1.0.0. `BuildInfo` reads the commit from `build_commit.txt` (written by `make dist` and git-ignored), or from `.git` when run from the checkout. The main menu shows "Version 0.9.0 (commit)", and the server's `start` log line carries `version` and `commit`.
- `make dist-check` (`tools/dist_check.sh`) unpacks the package in a temp dir with HOME and XDG in that dir, then:
- checks the sha256 and the exact file list;
- runs `SMOKE_DIST=<dir> tools/smoke.sh` (new mode), which gives state hash `3b20a907…`, the same as the repo build on the same seed;
- runs a whole bot match to results with 0 errors, with version and commit in the log matching VERSION;
- has the exported game join the exported server over loopback, playing 3,558 frames.
- **Decisions:**
- One preset, not two. Godot's dedicated-server export didn't strip anything by default here (the server pack came out the same size), so it was a duplicate.
- Release templates refuse `--main-pack`, so the launcher relies on the binary loading `tidewall.pck` beside it.
- **What I learned about release templates:**
- A GDScript call on null crashes the process (exit 139) instead of being reported.
- An invalid call on a real object is silently ignored.
- So the smoke fault check expects only a non-zero exit in package mode.
- The systemd unit already has `Restart=on-failure`.
- This makes the debug-only checks in `make check` and the soak the real guard for script errors.
+31
View File
@@ -0,0 +1,31 @@
[preset.0]
name="Linux"
platform="Linux"
runnable=true
advanced_options=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter="build_commit.txt"
exclude_filter="test/*, tools/*, captures/*, build/*, docs/*, packaging/*, data/.gitkeep"
export_path="build/dist/stage/tidewall.x86_64"
patches=PackedStringArray()
encryption_include_filters=""
encryption_exclude_filters=""
seed=0
encrypt_pck=false
encrypt_directory=false
script_export_mode=2
[preset.0.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=0
binary_format/embed_pck=false
texture_format/s3tc_bptc=true
texture_format/etc2_astc=false
shader_baker/enabled=false
binary_format/architecture="x86_64"
ssh_remote_deploy/enabled=false
+41
View File
@@ -0,0 +1,41 @@
# Tidewall for Linux (x86_64)
A free and open-source build-and-survive battle royale. The sea rises in phases and
swallows the low ground, so the last dry land keeps getting higher and smaller.
## Play
./tidewall.x86_64
The game opens on its main menu: practice against bots offline, or join a server on
your network or by address. It needs a Vulkan-capable GPU and driver (Forward+). On
hardware without Vulkan, start it with `--rendering-driver opengl3` to use OpenGL.
Settings and key bindings are saved in `~/.local/share/godot/app_userdata/Tidewall/`.
## Run a server
./tidewall-server --config=server.cfg
`server.cfg` is an example: it takes players over UDP on port 24650, answers LAN
discovery on 24651, and fills empty places with bots. Every option can also be given
on the command line (`--port=24650`, `--bots=1`, `--name=...`). SIGTERM or Ctrl+C stops
the server cleanly. Logs are JSON lines on standard output.
## What's here
| File | |
|---|---|
| `tidewall.x86_64` | The Godot 4.7.2 engine (official release template) |
| `tidewall.pck` | The game |
| `tidewall-server` | Runs the same game headless as a dedicated server |
| `server.cfg` | Example server configuration |
| `VERSION` | Version, commit and engine |
| `PROVENANCE.md` | How every model, texture and sound was made |
## Licence
Code: GPL-3.0-or-later (`LICENSE`). Art and audio, all generated by scripts in the
source repository: CC BY-SA 4.0 (`LICENSE-ASSETS`). The Godot engine is MIT-licensed.
Source: https://gitea.eom.dev/claude/tidewall
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Runs a Tidewall dedicated server from the release package, headless, and turns
# SIGTERM or SIGINT into a clean stop: the server tells everyone connected it is
# shutting down, logs its statistics and exits 0. The engine can't catch signals
# itself, so this wrapper creates the server's --stop-file when one arrives, and kills
# the server only if it hasn't gone after TIDEWALL_STOP_SECONDS (default 15).
#
# ./tidewall-server [server options...] e.g. --config=server.cfg (options in server.cfg)
#
# TIDEWALL_STATE a writable directory for the engine's own files and the stop file
# (default $XDG_STATE_HOME/tidewall-server, else
# ~/.local/state/tidewall-server)
set -u
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
state="${TIDEWALL_STATE:-${XDG_STATE_HOME:-$HOME/.local/state}/tidewall-server}"
grace="${TIDEWALL_STOP_SECONDS:-15}"
stop_file="$state/stop"
mkdir -p "$state/data" "$state/config" "$state/cache"
rm -f "$stop_file"
export XDG_DATA_HOME="$state/data" XDG_CONFIG_HOME="$state/config" XDG_CACHE_HOME="$state/cache"
"$here/tidewall.x86_64" --headless -- --server --stop-file="$stop_file" "$@" &
child=$!
request_stop() {
touch "$stop_file"
( sleep "$grace"; kill -KILL "$child" 2>/dev/null ) &
}
trap request_stop TERM INT
wait "$child"
code=$?
while kill -0 "$child" 2>/dev/null; do
wait "$child"
code=$?
done
exit "$code"
+1
View File
@@ -11,6 +11,7 @@ config_version=5
[application] [application]
config/name="Tidewall" config/name="Tidewall"
config/version="0.9.0"
config/description="A free and open-source build-and-survive battle royale for Linux." config/description="A free and open-source build-and-survive battle royale for Linux."
run/main_scene="res://src/app/main.tscn" run/main_scene="res://src/app/main.tscn"
config/features=PackedStringArray("4.7") config/features=PackedStringArray("4.7")
+65
View File
@@ -0,0 +1,65 @@
## R1: which build this is. The version is project.godot's application/config/version.
## The commit is the one `make dist` wrote into build_commit.txt when it exported the
## game. Run from the repository, it is read from .git instead, and "unknown" if
## neither can be found.
class_name BuildInfo
extends RefCounted
const COMMIT_FILE: String = "res://build_commit.txt"
static var _commit: String = ""
static func version() -> String:
return String(ProjectSettings.get_setting("application/config/version", "0.0.0"))
static func commit() -> String:
if _commit.is_empty():
_commit = _read_commit()
return _commit
## "0.9.0 (1a2b3c4d5e6f)", for the main menu and logs.
static func describe() -> String:
return "%s (%s)" % [version(), commit()]
static func _read_commit() -> String:
if FileAccess.file_exists(COMMIT_FILE):
var written: String = FileAccess.get_file_as_string(COMMIT_FILE).strip_edges()
if is_valid_commit(written):
return written
var from_git: String = _git_head(ProjectSettings.globalize_path("res://").path_join(".git"))
return from_git if not from_git.is_empty() else "unknown"
## A short or full hex commit name, optionally marked "-dirty".
static func is_valid_commit(text: String) -> bool:
var name: String = text.trim_suffix("-dirty")
if name.length() < 7 or name.length() > 40:
return false
for character: String in name:
if not "0123456789abcdef".contains(character):
return false
return true
## The commit HEAD names in a .git directory, shortened to 12 characters, or "".
static func _git_head(git_dir: String) -> String:
var head_path: String = git_dir.path_join("HEAD")
if not FileAccess.file_exists(head_path):
return ""
var head: String = FileAccess.get_file_as_string(head_path).strip_edges()
var full: String = head
if head.begins_with("ref: "):
var ref: String = head.trim_prefix("ref: ")
var loose: String = git_dir.path_join(ref)
full = ""
if FileAccess.file_exists(loose):
full = FileAccess.get_file_as_string(loose).strip_edges()
elif FileAccess.file_exists(git_dir.path_join("packed-refs")):
for line: String in FileAccess.get_file_as_string(git_dir.path_join("packed-refs")).split("\n", false):
if line.ends_with(" " + ref):
full = line.get_slice(" ", 0)
return full.substr(0, 12) if is_valid_commit(full) else ""
+1
View File
@@ -0,0 +1 @@
uid://brutau3owyp2q
+2
View File
@@ -79,6 +79,8 @@ func _ready() -> void:
_finish(2) _finish(2)
return return
var started: Dictionary = config.to_dictionary() var started: Dictionary = config.to_dictionary()
started["version"] = BuildInfo.version()
started["commit"] = BuildInfo.commit()
started["engine"] = Engine.get_version_info()["string"] started["engine"] = Engine.get_version_info()["string"]
started["tick_rate_hz"] = Tuning.TICK_RATE_HZ started["tick_rate_hz"] = Tuning.TICK_RATE_HZ
started["world_hash"] = loop.sim.island.heightmap_hash() started["world_hash"] = loop.sim.island.heightmap_hash()
+7
View File
@@ -328,6 +328,13 @@ func _build_main() -> void:
_button(column, "Join a server", func() -> void: show_screen("join")) _button(column, "Join a server", func() -> void: show_screen("join"))
_button(column, "Settings", func() -> void: show_screen("settings")) _button(column, "Settings", func() -> void: show_screen("settings"))
_button(column, "Quit", func() -> void: quit_requested.emit()) _button(column, "Quit", func() -> void: quit_requested.emit())
var build: Label = Label.new()
build.name = "Build"
build.text = "Version " + BuildInfo.describe()
build.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
build.add_theme_font_size_override("font_size", FONT_SMALL)
build.modulate.a = 0.7
column.add_child(build)
func _build_practice() -> void: func _build_practice() -> void:
+46
View File
@@ -0,0 +1,46 @@
## R1: the version and commit shown in the main menu and server logs.
extends TestCase
func test_version_comes_from_the_project() -> void:
assert_eq(BuildInfo.version(), String(ProjectSettings.get_setting("application/config/version")))
var parts: PackedStringArray = BuildInfo.version().split(".")
assert_eq(parts.size(), 3, "a three-part version: %s" % BuildInfo.version())
for part: String in parts:
assert_true(part.is_valid_int(), "%s is a number" % part)
func test_commit_is_read_from_the_repository() -> void:
# Tests run from the checkout, which has a .git directory.
var commit: String = BuildInfo.commit()
assert_true(BuildInfo.is_valid_commit(commit), "a commit name: %s" % commit)
assert_true(BuildInfo.describe().begins_with(BuildInfo.version() + " ("))
func test_commit_names_are_checked() -> void:
assert_true(BuildInfo.is_valid_commit("0e6e12c"))
assert_true(BuildInfo.is_valid_commit("0e6e12cabc12-dirty"))
assert_false(BuildInfo.is_valid_commit("main"))
assert_false(BuildInfo.is_valid_commit("0e6e"))
assert_false(BuildInfo.is_valid_commit("<script>0e6e12c"))
func test_git_head_follows_loose_and_packed_refs() -> void:
var dir: String = OS.get_user_data_dir().path_join("test_build_info_git")
DirAccess.make_dir_recursive_absolute(dir.path_join("refs/heads"))
_write(dir.path_join("HEAD"), "ref: refs/heads/main\n")
_write(dir.path_join("refs/heads/main"), "0123456789abcdef0123456789abcdef01234567\n")
assert_eq(BuildInfo._git_head(dir), "0123456789ab")
DirAccess.remove_absolute(dir.path_join("refs/heads/main"))
_write(dir.path_join("packed-refs"), "# pack-refs with: peeled\nfedcba9876543210fedcba9876543210fedcba98 refs/heads/main\n")
assert_eq(BuildInfo._git_head(dir), "fedcba987654")
_write(dir.path_join("HEAD"), "not a commit\n")
assert_eq(BuildInfo._git_head(dir), "", "a detached HEAD that isn't a commit name")
for file: String in ["HEAD", "packed-refs"]:
DirAccess.remove_absolute(dir.path_join(file))
func _write(path: String, text: String) -> void:
var file: FileAccess = FileAccess.open(path, FileAccess.WRITE)
file.store_string(text)
file.close()
+1
View File
@@ -0,0 +1 @@
uid://cttjag58b0qvu
+7
View File
@@ -281,3 +281,10 @@ func test_menu_buttons_knock_when_pointed_at_and_pressed() -> void:
sounds.free() sounds.free()
later.free() later.free()
SoundBank.clear() SoundBank.clear()
func test_main_menu_shows_the_version_and_commit() -> void:
var build: Label = menus.find_child("Build", true, false) as Label
assert_not_null(build, "the main menu has a build line")
if build != null:
assert_eq(build.text, "Version " + BuildInfo.describe())
Executable
+96
View File
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
# R1: exports the Linux x86_64 game, which is also the dedicated server, with the
# official Godot export templates and packs them into build/dist/tidewall-<version>-linux-x86_64.tar.gz.
#
# tools/dist.sh
#
# The templates come from tools/godot/ (git-ignored), checked against
# tools/engine.sha512 before use, and are installed into the repo-local engine data
# (.godot-home/), never the user's home. The version is project.godot's
# application/config/version; the commit is written into the export as
# build_commit.txt, which BuildInfo reads.
#
# The package holds:
# tidewall.x86_64 the engine (the official release template)
# tidewall.pck the game
# tidewall-server runs the same game headless as a dedicated server, with
# clean SIGTERM handling
# server.cfg an example server configuration
# LICENSE, LICENSE-ASSETS, README.md, PROVENANCE.md, VERSION
set -euo pipefail
repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo"
engine_version="$(cut -d. -f1-3 tools/engine.version)" # 4.7.2
engine_tag="${engine_version}.$(cut -d. -f4 tools/engine.version)" # 4.7.2.stable
templates_zip="tools/godot/Godot_v${engine_version}-stable_export_templates.tpz"
templates_dir=".godot-home/data/godot/export_templates/$engine_tag"
version="$(sed -n 's/^config\/version="\(.*\)"$/\1/p' project.godot)"
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "dist FAIL: no version in project.godot" >&2; exit 1; }
commit="$(git rev-parse --short=12 HEAD)"
if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then
commit="$commit-dirty"
fi
name="tidewall-$version-linux-x86_64"
out="build/dist"
stage="$out/stage"
package="$out/$name"
tools/godot.sh --verify >/dev/null
# The official templates, checked, then only the Linux x86_64 ones installed.
if [[ ! -f "$templates_dir/linux_release.x86_64" || "$(cat "$templates_dir/.verified" 2>/dev/null)" != "$(grep 'export_templates\.tpz$' tools/engine.sha512 | cut -d' ' -f1)" ]]; then
[[ -f "$templates_zip" ]] || { echo "dist FAIL: missing $templates_zip (see tools/godot.sh)" >&2; exit 1; }
echo "dist: checking the export templates against tools/engine.sha512" >&2
grep 'export_templates\.tpz$' tools/engine.sha512 | sha512sum --check --quiet
mkdir -p "$templates_dir"
unzip -q -o -j "$templates_zip" templates/linux_release.x86_64 templates/linux_debug.x86_64 templates/version.txt -d "$templates_dir"
[[ "$(cat "$templates_dir/version.txt")" == "$engine_tag" ]] || { echo "dist FAIL: templates are for $(cat "$templates_dir/version.txt"), not $engine_tag" >&2; exit 1; }
grep 'export_templates\.tpz$' tools/engine.sha512 | cut -d' ' -f1 >"$templates_dir/.verified"
fi
rm -rf "$stage" "$package" "$out/$name.tar.gz" "$out/$name.tar.gz.sha256"
mkdir -p "$stage" "$package"
trap 'rm -f "$repo/build_commit.txt"' EXIT
printf '%s\n' "$commit" >build_commit.txt
tools/godot.sh --import --quit >/dev/null 2>&1 || true
export_preset() {
local preset="$1" target="$2" raw
echo "dist: exporting '$preset'" >&2
if ! raw="$(tools/godot.sh --export-release "$preset" "$repo/$target" 2>&1)"; then
echo "dist FAIL: exporting '$preset' failed" >&2
tail -n 20 <<<"$raw" >&2
exit 1
fi
if grep -E '^(ERROR|SCRIPT ERROR)' <<<"$raw" >&2; then
echo "dist FAIL: errors while exporting '$preset'" >&2
exit 1
fi
[[ -f "$repo/$target" ]] || { echo "dist FAIL: '$preset' wrote no $target" >&2; exit 1; }
}
export_preset "Linux" "$stage/tidewall.x86_64"
rm -f build_commit.txt
# The exported binary must be the verified official template, unchanged.
cmp -s "$stage/tidewall.x86_64" "$templates_dir/linux_release.x86_64" || { echo "dist FAIL: the exported binary isn't the release template" >&2; exit 1; }
install -m 0755 "$stage/tidewall.x86_64" "$package/tidewall.x86_64"
install -m 0644 "$stage/tidewall.pck" "$package/tidewall.pck"
install -m 0755 packaging/dist/tidewall-server "$package/tidewall-server"
install -m 0644 LICENSE LICENSE-ASSETS "$package/"
install -m 0644 packaging/server/server.cfg "$package/server.cfg"
install -m 0644 packaging/dist/README.md "$package/README.md"
install -m 0644 assets/PROVENANCE.md "$package/PROVENANCE.md"
printf 'Tidewall %s\ncommit %s\nengine Godot %s\n' "$version" "$commit" "$(cat tools/engine.version)" >"$package/VERSION"
# Reproducible-ish archive: fixed owner, sorted names, mtimes from the commit.
stamp="$(git log -1 --format=%ct)"
tar --sort=name --owner=0 --group=0 --numeric-owner --mtime="@$stamp" \
-C "$out" -czf "$out/$name.tar.gz" "$name"
(cd "$out" && sha256sum "$name.tar.gz" >"$name.tar.gz.sha256")
rm -rf "$stage"
echo "dist: $out/$name.tar.gz ($(du -h "$out/$name.tar.gz" | cut -f1)), commit $commit"
tar -tzvf "$out/$name.tar.gz" | awk '{print " " $3 "\t" $6}'
+99
View File
@@ -0,0 +1,99 @@
#!/usr/bin/env bash
# R1: builds the release package with tools/dist.sh, unpacks it outside the repository
# and checks that it works there with nothing from the checkout:
# - its checksum, and that it holds exactly the files it should;
# - tools/smoke.sh against its server (SMOKE_DIST);
# - a whole bot-only match, lobby to results, on its server;
# - its game, headless with the autoplay script, joining its server over loopback UDP
# and playing (as tools/client_check.sh does from the repo);
# - the version and commit in the logs match its VERSION file.
#
# tools/dist_check.sh about 3 minutes
set -uo pipefail
repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo"
status=0
fail() {
echo "dist-check FAIL: $*"
status=1
}
tools/dist.sh >/dev/null || { echo "dist-check FAIL: tools/dist.sh failed"; tools/dist.sh 2>&1 | tail -n 10; exit 1; }
archive="$(ls -t build/dist/tidewall-*-linux-x86_64.tar.gz | head -n 1)"
name="$(basename "$archive" .tar.gz)"
work="$(mktemp -d)"
cleanup() {
[[ -n "${server_pid:-}" ]] && kill -TERM "$server_pid" 2>/dev/null
rm -rf "$work"
}
trap cleanup EXIT
(cd "$(dirname "$archive")" && sha256sum --check --quiet "$name.tar.gz.sha256") || fail "the checksum doesn't match"
tar -xzf "$archive" -C "$work"
package="$work/$name"
# Nothing the package runs may reach back into the checkout, and nothing it writes may
# land in the user's home.
export HOME="$work/home" XDG_DATA_HOME="$work/home/data" XDG_CONFIG_HOME="$work/home/config" XDG_CACHE_HOME="$work/home/cache" XDG_STATE_HOME="$work/home/state"
mkdir -p "$HOME"
expected="LICENSE LICENSE-ASSETS PROVENANCE.md README.md VERSION server.cfg tidewall-server tidewall.pck tidewall.x86_64"
actual="$(cd "$package" && ls -A | LC_ALL=C sort | tr '\n' ' ' | sed 's/ $//')"
[[ "$actual" == "$expected" ]] || fail "the package holds '$actual', expected '$expected'"
version="$(sed -n 's/^Tidewall //p' "$package/VERSION")"
commit="$(sed -n 's/^commit //p' "$package/VERSION")"
[[ -n "$version" && -n "$commit" ]] || fail "VERSION doesn't name a version and commit"
echo "dist-check: smoke against $name" >&2
(cd "$work" && SMOKE_DIST="$package" "$repo/tools/smoke.sh") | sed 's/^/ /' || fail "smoke failed against the package"
echo "dist-check: a whole bot match on the package's server" >&2
match_log="$work/match.log"
(cd "$work" && timeout --signal=KILL 600 nice -n 15 "$package/tidewall-server" --seed=2 --bots=24 --matches=1 --unthrottled >"$match_log" 2>&1)
code=$?
[[ "$code" -eq 0 ]] || fail "the bot match exited $code"
grep -q '"event":"results"' "$match_log" || fail "the bot match never reached its results"
grep -q '"errors":0,"event":"stop"' "$match_log" || fail "the bot match logged errors"
start="$(grep -m1 '"event":"start"' "$match_log")"
grep -q "\"version\":\"$version\"" <<<"$start" || fail "the server log doesn't give version $version"
grep -q "\"commit\":\"$commit\"" <<<"$start" || fail "the server log doesn't give commit $commit"
echo " bot match: results reached, version $version, commit $commit"
echo "dist-check: the package's game joins its server" >&2
port=$((20000 + RANDOM % 20000))
server_log="$work/server.log"
cd "$work"
TIDEWALL_STATE="$work/server-state" nice -n 15 "$package/tidewall-server" --listen --port="$port" --seed=2 --bots=1 --matches=1 >"$server_log" 2>&1 &
server_pid=$!
cd "$repo"
for _ in $(seq 1 100); do
grep -q '"event":"start"' "$server_log" 2>/dev/null && break
sleep 0.1
done
client_log="$work/client.log"
(cd "$work" && timeout --signal=KILL 120 nice -n 15 "$package/tidewall.x86_64" --headless -- --connect="127.0.0.1:$port" --name=Mara --autoplay --client-seconds=55 >"$client_log" 2>&1)
client_code=$?
kill -TERM "$server_pid" 2>/dev/null
wait "$server_pid"
server_code=$?
server_pid=""
report="$(grep -m1 '"event":"client"' "$client_log" || true)"
[[ "$client_code" -eq 0 ]] || fail "the game exited with $client_code"
[[ "$server_code" -eq 0 ]] || fail "the server exited with $server_code"
[[ -n "$report" ]] || fail "the game said nothing"
grep -q '"joined":true' <<<"$report" || fail "the game never joined"
grep -q '"phases":\["lobby","countdown","drop"' <<<"$report" || fail "the game didn't follow the match from the lobby into the drop"
grep -q '"bad_packets":0' <<<"$report" || fail "the game was sent packets it couldn't read"
playing="$(sed -n 's/.*"frames_playing":\([0-9]*\).*/\1/p' <<<"$report")"
[[ "${playing:-0}" -ge 300 ]] || fail "the game's player was in the match for only ${playing:-0} frames"
grep -q '"event":"player_joined".*"name":"Mara"' "$server_log" || fail "the server never saw the game join"
grep -q '"errors":0,"event":"stop"' "$server_log" || fail "the server logged errors"
echo " game: joined, in the match for ${playing:-0} frames"
if [[ -n "$(ls -A "$HOME/data" 2>/dev/null | grep -v '^godot$')" ]]; then
fail "the package wrote outside the engine's user data: $(ls -A "$HOME/data")"
fi
if [[ "$status" -eq 0 ]]; then
echo "dist-check: ok ($name works outside the repository: smoke, a bot match, and its game playing on its server)"
fi
exit "$status"
+26 -2
View File
@@ -9,6 +9,8 @@
# #
# tools/smoke.sh unthrottled, so it finishes in seconds # tools/smoke.sh unthrottled, so it finishes in seconds
# SMOKE_REALTIME=1 tools/smoke.sh at the real 30 Hz tick rate (about 34 seconds) # SMOKE_REALTIME=1 tools/smoke.sh at the real 30 Hz tick rate (about 34 seconds)
# SMOKE_DIST=DIR tools/smoke.sh the same checks on an unpacked release package
# (R1): DIR/tidewall-server instead of the repo
set -uo pipefail set -uo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.." cd "$(dirname "${BASH_SOURCE[0]}")/.."
@@ -18,11 +20,21 @@ pace="--unthrottled"
[[ "${SMOKE_REALTIME:-0}" == "1" ]] && pace="" [[ "${SMOKE_REALTIME:-0}" == "1" ]] && pace=""
status=0 status=0
code=0 code=0
dist="${SMOKE_DIST:-}"
if [[ -n "$dist" ]]; then
[[ -x "$dist/tidewall-server" ]] || { echo "smoke FAIL: no $dist/tidewall-server"; exit 2; }
dist_state="$(mktemp -d)"
trap 'rm -rf "$dist_state"' EXIT
fi
# run <args...>: runs the server, sets $output (JSON lines only) and $code. # run <args...>: runs the server, sets $output (JSON lines only) and $code.
run() { run() {
local raw local raw
if [[ -n "$dist" ]]; then
raw="$(TIDEWALL_STATE="$dist_state" timeout --signal=KILL 300 "$dist/tidewall-server" "$@" 2>&1)"
else
raw="$(timeout --signal=KILL 300 tools/godot.sh -- --server "$@" 2>&1)" raw="$(timeout --signal=KILL 300 tools/godot.sh -- --server "$@" 2>&1)"
fi
code=$? code=$?
output="$(grep '^{' <<<"$raw")" output="$(grep '^{' <<<"$raw")"
stderr_tail="$(grep -v '^{' <<<"$raw" | tail -n 15)" stderr_tail="$(grep -v '^{' <<<"$raw" | tail -n 15)"
@@ -52,7 +64,7 @@ seeded="$(grep -c "\"seed\":$seed[,}]" <<<"$output")"
[[ "$lines" -eq "$seeded" ]] || fail "only $seeded of $lines log lines carry the seed" [[ "$lines" -eq "$seeded" ]] || fail "only $seeded of $lines log lines carry the seed"
[[ "$(field stats ticks)" == "$ticks" ]] || fail "ran $(field stats ticks) ticks, expected $ticks" [[ "$(field stats ticks)" == "$ticks" ]] || fail "ran $(field stats ticks) ticks, expected $ticks"
hash="$(field stats state_hash)" hash="$(field stats state_hash)"
echo "smoke: $ticks ticks, 24 bots, seed $seed" echo "smoke: $ticks ticks, 24 bots, seed $seed${dist:+, release package $dist}"
echo "smoke: tick us min $(field stats min_us) mean $(field stats mean_us) p50 $(field stats p50_us)" \ echo "smoke: tick us min $(field stats min_us) mean $(field stats mean_us) p50 $(field stats p50_us)" \
"p95 $(field stats p95_us) p99 $(field stats p99_us) max $(field stats max_us)," \ "p95 $(field stats p95_us) p99 $(field stats p99_us) max $(field stats max_us)," \
"$(field stats over_budget) over the $(field stats budget_us) us budget" "$(field stats over_budget) over the $(field stats budget_us) us budget"
@@ -63,8 +75,14 @@ run --seed="$seed" --bots=24 --ticks="$ticks" --unthrottled
|| fail "a second run with the same seed gave a different state hash" || fail "a second run with the same seed gave a different state hash"
run --seed="$seed" --bots=2 --ticks=50 --unthrottled --fault=script-error run --seed="$seed" --bots=2 --ticks=50 --unthrottled --fault=script-error
if [[ -n "$dist" ]]; then
# A release template has no script error checks: the call on null crashes the
# process (139) rather than being reported. Either way it must not exit 0.
[[ "$code" -ne 0 ]] || fail "a script error exited 0 in the release package"
else
[[ "$code" -eq 1 ]] || fail "a script error exited $code, expected 1" [[ "$code" -eq 1 ]] || fail "a script error exited $code, expected 1"
[[ "$(field stop errors)" -ge 1 ]] || fail "a script error wasn't counted in the stop line" [[ "$(field stop errors)" -ge 1 ]] || fail "a script error wasn't counted in the stop line"
fi
run --bots=99 --nonsense run --bots=99 --nonsense
[[ "$code" -eq 2 ]] || fail "a bad command line exited $code, expected 2" [[ "$code" -eq 2 ]] || fail "a bad command line exited $code, expected 2"
@@ -79,9 +97,13 @@ run --listen --port="$port" --seed="$seed" --bots=4 --ticks=120 --unthrottled
# SIGTERM to the packaged wrapper becomes a clean stop: stats and stop lines, exit 0. # SIGTERM to the packaged wrapper becomes a clean stop: stats and stop lines, exit 0.
state="$(mktemp -d)" state="$(mktemp -d)"
if [[ -n "$dist" ]]; then
TIDEWALL_STATE="$state" "$dist/tidewall-server" --seed="$seed" --bots=2 >"$state/log" 2>&1 &
else
TIDEWALL_ENGINE="$(pwd)/tools/godot/$(sed -n 's/^\([0-9a-f]*\) *tools\/godot\/\(.*_linux\.x86_64\)$/\2/p' tools/engine.sha512)" \ TIDEWALL_ENGINE="$(pwd)/tools/godot/$(sed -n 's/^\([0-9a-f]*\) *tools\/godot\/\(.*_linux\.x86_64\)$/\2/p' tools/engine.sha512)" \
TIDEWALL_GAME="$(pwd)" TIDEWALL_STATE="$state" \ TIDEWALL_GAME="$(pwd)" TIDEWALL_STATE="$state" \
packaging/server/tidewall-server --seed="$seed" --bots=2 >"$state/log" 2>&1 & packaging/server/tidewall-server --seed="$seed" --bots=2 >"$state/log" 2>&1 &
fi
wrapper=$! wrapper=$!
for _ in $(seq 1 100); do for _ in $(seq 1 100); do
grep -q '"event":"start"' "$state/log" 2>/dev/null && break grep -q '"event":"start"' "$state/log" 2>/dev/null && break
@@ -97,6 +119,8 @@ grep -q '"event":"stats"' <<<"$output" || fail "SIGTERM left no stats line"
[[ "$(field stop exit_code)" == "0" ]] || fail "SIGTERM left no clean stop line" [[ "$(field stop exit_code)" == "0" ]] || fail "SIGTERM left no clean stop line"
if [[ "$status" -eq 0 ]]; then if [[ "$status" -eq 0 ]]; then
echo "smoke: ok (clean run, reproducible hash, script error exits 1, bad config exits 2, listens, SIGTERM stops cleanly)" fault_exit="1"
[[ -n "$dist" ]] && fault_exit="non-zero"
echo "smoke: ok (clean run, reproducible hash, script error exits $fault_exit, bad config exits 2, listens, SIGTERM stops cleanly)"
fi fi
exit "$status" exit "$status"