`examples/<name>/` was a tested surface in name only. The source-quality job had no examples check at all, and scripts/smoke_examples.sh accepted any process that had not printed one of its error markers: a project that died during startup, exited after a single frame, or crashed without a marker was reported as PASS. Nothing stopped a malformed or unregistered example from reaching dev, which is how 14 examples arrived without READMEs and 20 were never registered in the overview table. Source side - scripts/check_examples.py classifies every directory under examples/ as either runnable (main.nut plus a config.nut that assigns the engine `config` table) or as a reviewed non-runnable sample listed in NON_RUNNABLE_EXAMPLES with a reason. Both kinds must own a README.md and appear in examples/README.md. Stale exemptions and overview links to missing directories fail as well. - `make check/examples` and a new source-quality CI step run the gate. - scripts/tests/test_check_examples.py covers it and pins each failure mode against fixtures. Runtime side - scripts/smoke_examples.sh now enforces liveness, not just marker absence: every runnable example must still be running after MIN_RUN_SECONDS (default 2s; CI passes 2s), and a process that dies inside that window fails whatever its exit code. A clean self-exit after the window passes with an explicit note instead of being silently accepted as a pass. - The Linux CI step sets MIN_RUN_SECONDS=2 and keeps RUN_SECONDS=6, so the job's wall clock is unchanged (13.7 min of its 20 min budget on dev). Windows / GBK - scripts/utf8_stdio.py re-encodes stdout/stderr as UTF-8 and every scripts/*.py program calls it as the first statement of its __main__ block. On a Chinese Windows a redirected stream falls back to the ANSI code page (cp936), and printing a character that code page cannot encode (arrows, superscripts, bullet separators, emoji - all common in this repository) raised UnicodeEncodeError and turned a checker into a traceback. - The mirror image is input: read_text() without encoding= decoded UTF-8 repository text as cp936 and raised UnicodeDecodeError. - scripts/tests/test_utf8_stdio.py enforces both conventions for every script and test module; text file I/O and child-process decoding now pass encoding="utf-8" explicitly. - Unit-test invocations run with `python3 -X utf8` so the runner's own output never follows the host code page. Violations the new gates found on top of dev, fixed here: 14 examples shipped without a README (fluid3d, mesh-impact-lab, mesh-modifier-lab, spline-tube-lab on the earlier dev tip, plus pcg-depth-of-field, pcg-detail-overwrite, pcg-layer-culling, pcg-location-system, pcg-runtime-orchestration, pcg-scene-player-culling, pcg-snow-wind, pcg-thunder-strike, pcg-ui-scaler and pcg-underwater added by #397), 20 were missing from the overview table (those 14 plus archspace-editor, geometry-stroke-lab, interior-mapping, layered-animation, triplanar-decal, terrain-stamping), and scripts/export_meshret_onnx.py had no UTF-8 stdio guard. Verified locally: `python -m ruff check scripts` (All checks passed); scripts/check_test_manifest.py; scripts/check_quality_metadata.py; scripts/check_architecture_contracts.py --base HEAD; scripts/check_nodiscard.py; `make -n check/examples`; scripts/check_examples.py (125 examples: 118 runnable, 7 reviewed non-runnable); and `python -X utf8 -m unittest discover -s scripts/tests -p "test_*.py"` (155 tests, OK). The runtime half of the contract needs a Linux headless build, so it is verified by the CI examples smoke step rather than locally.
130 lines
4.5 KiB
Python
130 lines
4.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Download free Spine demo models (spineboy / hero / dragon) for 2D spine tests.
|
|
|
|
Source: EsotericSoftware/spine-runtimes branch 3.5 example exports. These use
|
|
only "region" attachments (no mesh / clipping / path), which is the subset the
|
|
EVEngine Spine module parses. Output layout:
|
|
|
|
test/assets/spine/<model>/export/<file>
|
|
|
|
Usage:
|
|
python3 scripts/download_spine_models.py
|
|
EVENGINE_SPINE_DIR=/path python3 scripts/download_spine_models.py
|
|
|
|
Idempotent: skips files already present with the expected size. Writes a
|
|
`.downloaded` marker and an ATTRIBUTION.md when all models are installed.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import urllib.request
|
|
import utf8_stdio
|
|
|
|
RAW_BASE = (
|
|
"https://raw.githubusercontent.com/EsotericSoftware/spine-runtimes/3.5"
|
|
"/examples/{model}/export/{name}"
|
|
)
|
|
LICENSE_BASE = (
|
|
"https://raw.githubusercontent.com/EsotericSoftware/spine-runtimes/3.5"
|
|
"/examples/{model}/license.txt"
|
|
)
|
|
|
|
# model -> extra files beyond <model>.json / <model>.atlas / <model>.png
|
|
MODELS = {
|
|
"spineboy": [],
|
|
"hero": [],
|
|
"dragon": ["dragon2.png"],
|
|
}
|
|
|
|
ATTRIBUTION = """# Spine demo models
|
|
|
|
These assets are the official Spine sample models exported by Esoteric
|
|
Software and are distributed with the spine-runtimes repository
|
|
(https://github.com/EsotericSoftware/spine-runtimes, branch 3.5) under
|
|
`examples/`.
|
|
|
|
Each model has its own `license.txt` in this folder. Spine Runtimes are
|
|
available for integration in games and other software under the terms of the
|
|
Spine Editor License Agreement (http://esotericsoftware.com/spine-editor-license).
|
|
|
|
Downloaded by `scripts/download_spine_models.py` from
|
|
`https://raw.githubusercontent.com/EsotericSoftware/spine-runtimes/3.5/examples/<model>/export/`.
|
|
"""
|
|
|
|
|
|
def out_root() -> str:
|
|
env = os.environ.get("EVENGINE_SPINE_DIR")
|
|
if env:
|
|
return env
|
|
here = os.path.dirname(os.path.abspath(__file__))
|
|
return os.path.join(here, "..", "test", "assets", "spine")
|
|
|
|
|
|
def fetch(url: str, path: str, expected: int) -> bool:
|
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
if os.path.isfile(path):
|
|
if expected is not None and os.path.getsize(path) == expected:
|
|
print(f" skip {os.path.basename(path)} ({expected} bytes)")
|
|
return True
|
|
if expected is None and os.path.getsize(path) > 0:
|
|
print(f" skip {os.path.basename(path)}")
|
|
return True
|
|
print(f" get {os.path.basename(path)}")
|
|
req = urllib.request.Request(url, headers={"User-Agent": "evengine-spine-models"})
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=180) as r, open(path, "wb") as out:
|
|
while True:
|
|
chunk = r.read(1024 * 256)
|
|
if not chunk:
|
|
break
|
|
out.write(chunk)
|
|
except Exception as exc: # noqa: BLE001 - report and let caller decide
|
|
print(f" error {os.path.basename(path)}: {exc}", file=sys.stderr)
|
|
return False
|
|
if expected is not None and os.path.getsize(path) != expected:
|
|
print(
|
|
f" size mismatch for {path}: got {os.path.getsize(path)}, want {expected}",
|
|
file=sys.stderr,
|
|
)
|
|
return False
|
|
return True
|
|
|
|
|
|
def fetch_license(model: str, dest_dir: str) -> None:
|
|
url = LICENSE_BASE.format(model=model)
|
|
path = os.path.join(dest_dir, "license.txt")
|
|
# license files are tiny; tolerate failures without failing the download
|
|
fetch(url, path, None)
|
|
|
|
|
|
def main() -> int:
|
|
root = os.path.abspath(out_root())
|
|
ok = True
|
|
for model, extra in MODELS.items():
|
|
files = [f"{model}.json", f"{model}.atlas", f"{model}.png"] + extra
|
|
dest_dir = os.path.join(root, model)
|
|
export_dir = os.path.join(dest_dir, "export")
|
|
for name in files:
|
|
url = RAW_BASE.format(model=model, name=name)
|
|
# Unknown size: rely on server content-length via streaming write.
|
|
if not fetch(url, os.path.join(export_dir, name), None):
|
|
ok = False
|
|
fetch_license(model, dest_dir)
|
|
|
|
if not ok:
|
|
print("One or more files failed to download.", file=sys.stderr)
|
|
return 1
|
|
|
|
marker = os.path.join(root, ".downloaded")
|
|
with open(marker, "w", encoding="utf-8") as f:
|
|
f.write("\n".join(MODELS.keys()) + "\n")
|
|
with open(os.path.join(root, "ATTRIBUTION.md"), "w", encoding="utf-8") as f:
|
|
f.write(ATTRIBUTION)
|
|
print(f"Spine models installed under {root}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
utf8_stdio.enable_utf8_stdio()
|
|
sys.exit(main())
|