A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Tools: the itch save test runs only against a separate test page (#1922)
Eyal Golan33ec5a95390b
diff --git a/docs/RELEASING.md b/docs/RELEASING.mdindex 8ad4bad8e..a2bcf8087 100644--- a/docs/RELEASING.md+++ b/docs/RELEASING.md@@ -250,7 +250,10 @@ A night that starts after 03:30 is MISSED unless it was started by hand with `--**itch.io.** Pushes stay off until the owner runs `uv run tools/nightly.py savetest --tag <a published nightly>` onceand it prints `PASS` (the two-upload save test of `docs/m3-release.md`, "Upload to itch.io"); the nightly then logs-that itch was skipped.+that itch was skipped. The save test pushes only to a separate test page, named in the job's `config.json` as+`savetest_itch_target` (`user/project:channel`) and `savetest_itch_page_url`, and refuses to run without them or if+they name the public page: each upload hides the game while itch unpacks it, which took up to an hour on 28 October+2026.## Refreshing the README screenshotsdiff --git a/tools/nightly.py b/tools/nightly.pyindex a3d972c87..ca7c3082f 100644--- a/tools/nightly.py+++ b/tools/nightly.py@@ -864,10 +864,11 @@ def savetest(cfg: Config, config_path: Path, job: Path, runner: Runner, gh: GitH"""The two-upload save test of docs/m3-release.md: upload A, play a turn and let the autosave commit; upload B(the same content, a new upload URL on the same frame origin); B must load that date, turn and state hash twice."PASS" turns the itch push on (enable_itch); "INCONCLUSIVE" (the test could not be run or proves nothing) and- "FAIL" leave it off. It pushes to the PUBLIC itch page twice, so only the owner starts it."""+ "FAIL" leave it off. It pushes twice to the separate test page in savetest_itch_target, never to the public page:+ each upload hides the game while itch unpacks it (up to an hour on 28 October 2026). Only the owner starts it."""stamp = datetime.now(TZ).strftime("%Y%m%d-%H%M%S")work = Path(job) / "savetest" / stamp- evidence: dict = {"tag": tag, "page_url": cfg.itch_page_url, "target": cfg.itch_target}+ evidence: dict = {"tag": tag, "page_url": cfg.savetest_itch_page_url, "target": cfg.savetest_itch_target}result, detail = "INCONCLUSIVE", ""try:result, detail = _savetest(cfg, work, runner, gh, itch, tag, evidence, fetch, sleep)@@ -884,11 +885,38 @@ def savetest(cfg: Config, config_path: Path, job: Path, runner: Runner, gh: GitHreturn result+def _itch_project(target: str) -> str:+ """`user/project` of a butler target, without its channel: every channel of a project uploads to its one page."""+ return target.partition(":")[0].lower()+++def _page_key(url: str) -> tuple[str, str]:+ parts = urllib.parse.urlsplit(url.strip())+ return parts.netloc.lower(), parts.path.rstrip("/").lower()+++def _test_page_problem(cfg: Config) -> str | None:+ """Why the save test may not push, or None: it needs its own test project, distinct from the public one."""+ if not cfg.savetest_itch_target or not cfg.savetest_itch_page_url:+ return "savetest_itch_target and savetest_itch_page_url must name a separate test page in the job's config"+ if _itch_project(cfg.savetest_itch_target) == _itch_project(cfg.itch_target):+ return "the save test's test page must not be the public itch project (any channel of it uploads to its page)"+ try:+ test_page = _page_key(cfg.savetest_itch_page_url)+ public_page = _page_key(cfg.itch_page_url) if cfg.itch_page_url else None+ except ValueError as e:+ return f"the save test's test page URL or the public page URL is not usable: {e}"+ if test_page == public_page:+ return "the save test's test page must not be the public itch page"+ return None++def _savetest(cfg: Config, work: Path, runner: Runner, gh: GitHub, itch: Itch, tag: str, evidence: dict, fetch,sleep) -> tuple[str, str]:"""(result, detail) of the test; a Refused or OSError out of it is the caller's INCONCLUSIVE."""- if not cfg.itch_page_url:- return "INCONCLUSIVE", "itch_page_url is not set in the job's config"+ reason = _test_page_problem(cfg)+ if reason:+ return "INCONCLUSIVE", reasonstate = gh.release_state(tag)if state != "published":return "INCONCLUSIVE", f"{tag} is {state or 'not a release'}, the save test needs a published nightly"@@ -902,7 +930,7 @@ def _savetest(cfg: Config, work: Path, runner: Runner, gh: GitHub, itch: Itch, titch.push(folder, f"{version}-savetest-a")itch.wait_live(f"{version}-savetest-a", time.monotonic() + ITCH_WAIT_SECONDS)- frame_a = _frame_url(fetch, sleep, cfg.itch_page_url)+ frame_a = _frame_url(fetch, sleep, cfg.savetest_itch_page_url)evidence.update(upload_a={"build_id": itch.live_build_id(), "frame_url": frame_a})if frame_a is None:return "INCONCLUSIVE", "the itch page names no game frame after upload A"@@ -915,7 +943,7 @@ def _savetest(cfg: Config, work: Path, runner: Runner, gh: GitHub, itch: Itch, titch.push(folder, f"{version}-savetest-b")itch.wait_live(f"{version}-savetest-b", time.monotonic() + ITCH_WAIT_SECONDS)- frame_b = _frame_url(fetch, sleep, cfg.itch_page_url, other=frame_a)+ frame_b = _frame_url(fetch, sleep, cfg.savetest_itch_page_url, other=frame_a)evidence.update(upload_b={"build_id": itch.live_build_id(), "frame_url": frame_b})if frame_b is None:return "INCONCLUSIVE", "the itch page names no game frame after upload B"@@ -962,8 +990,11 @@ def run_savetest(cfg: Config, job: Path, tag: str) -> int:raise Refused("github-client", "gh is not on PATH")if not Path(cfg.butler).is_file():raise Refused("itch-client", f"{cfg.butler} is missing")+ problem = _test_page_problem(cfg)+ if problem:+ raise Refused("savetest", problem)runner = ProcRunner()- gh, itch = GitHub(runner, cfg.repo_slug, cfg.clone), Itch(runner, cfg.butler, cfg.itch_target)+ gh, itch = GitHub(runner, cfg.repo_slug, cfg.clone), Itch(runner, cfg.butler, cfg.savetest_itch_target)except Refused as e:print(e, file=sys.stderr)return 1@@ -978,7 +1009,7 @@ def main(argv: list[str] | None = None) -> int:run = sub.add_parser("run")run.add_argument("--manual", action="store_true")run.add_argument("--no-publish", action="store_true")- test = sub.add_parser("savetest", help="the two-upload itch.io save test: pushes to the PUBLIC itch page twice")+ test = sub.add_parser("savetest", help="the two-upload itch.io save test: pushes twice to the separate test page, never the public one")test.add_argument("--tag", required=True, help="a published nightly release tag")args = parser.parse_args(argv)job = JOBdiff --git a/tools/nightly_state.py b/tools/nightly_state.pyindex e207432d9..17a50ebea 100644--- a/tools/nightly_state.py+++ b/tools/nightly_state.py@@ -84,6 +84,8 @@ class Config:site_demo_url: str = "https://eyalgolan.github.io/statecraft-israel/demo/"itch_target: str = "eyalgolan/statecraft-israel:html5"itch_page_url: str | None = None+ savetest_itch_target: str | None = None # a separate test page: the save test never pushes to the public one+ savetest_itch_page_url: str | None = Noneitch_enabled: bool = Falseitch_evidence: str | None = Nonebutler: Path = HOME / ".local/bin/butler"diff --git a/tools/tests/test_nightly.py b/tools/tests/test_nightly.pyindex 3392efc3e..3245f7d55 100644--- a/tools/tests/test_nightly.py+++ b/tools/tests/test_nightly.py@@ -1783,7 +1783,8 @@ def test_an_unusable_client_is_a_recorded_github_client_refusal_not_internal(env# --- Task 8: the two-upload itch save test -----------------------------------------------------------------------------PAGE_URL = "https://example.invalid/statecraft-israel"+PAGE_URL = "https://example.invalid/statecraft-israel-savetest"+TEST_TARGET = "eyalgolan/statecraft-israel-savetest:html5"ITCH_HOST = "https://html-classic.itch.zone"SAVED = "PERSISTENCE saved 1948-05-16 turn 1 hash ab12\n"@@ -1852,11 +1853,13 @@ def page_for(itch, *, same=False, frame=True):class Saved:"""A save test: a config file, a published release and the fakes."""- def __init__(self, tmp_path, monkeypatch, *, release="published", page_url=PAGE_URL, **runner_kw):+ def __init__(self, tmp_path, monkeypatch, *, release="published", page_url=PAGE_URL, target=TEST_TARGET,+ public_page=None, **runner_kw):self.job = tmp_path / "job"self.job.mkdir()self.config = self.job / "config.json"- self.config.write_text('{"itch_page_url": "%s"}\n' % page_url)+ config = {"savetest_itch_page_url": page_url, "savetest_itch_target": target, "itch_page_url": public_page}+ self.config.write_text(json.dumps({k: v for k, v in config.items() if v is not None}) + "\n")self.cfg = ns.load_config(self.config)self.cfg = dataclasses.replace(self.cfg, handoff=tmp_path / "HANDOFF.md")self.gh = FakeGH(release=release)@@ -1965,6 +1968,49 @@ def test_savetest_waits_while_itch_is_still_unpacking_the_upload(saved):assert t.run(fetch) == "PASS" and t.enabled()[email protected]("kw", [{"target": None}, {"target": "eyalgolan/statecraft-israel:html5"},+ {"target": "eyalgolan/statecraft-israel:savetest"}, # another channel, same page+ {"target": "EyalGolan/Statecraft-Israel:html5"},+ {"target": "eyalgolan/statecraft-israel"}, # no channel: still the public project+ {"page_url": None}, {"public_page": PAGE_URL},+ {"public_page": PAGE_URL.upper() + "/#game"},+ {"page_url": "http://["}]) # a malformed URL refuses instead of raising+def test_savetest_runs_only_against_a_separate_test_page(saved, kw):+ t = saved(**kw) # 28 Oct 2026: each upload hid the public game while itch unpacked it, for up to an hour+ assert t.run() == "INCONCLUSIVE" and not t.enabled() and "test page" in t.log()+ assert not any(c[0].startswith("itch.") or c[0] == "download" for c in t.gh.calls) and t.runner.runs == []+++def test_savetest_reads_the_test_page_and_records_it_in_the_evidence(saved):+ t = saved()+ assert t.run() == "PASS"+ assert t.evidence()["page_url"] == PAGE_URL and t.evidence()["target"] == TEST_TARGET+++def test_the_savetest_command_refuses_before_any_client_without_a_test_target(tmp_path, monkeypatch, capsys):+ butler = tmp_path / "butler"+ butler.write_text("")+ monkeypatch.setattr(nightly.shutil, "which", lambda name: "/usr/bin/" + name)+ built = []+ monkeypatch.setattr(nightly, "Itch", lambda *a: built.append(a))+ cfg = dataclasses.replace(ns.Config(), butler=butler, handoff=tmp_path / "HANDOFF.md")+ assert nightly.run_savetest(cfg, tmp_path, TAG) == 1+ assert built == [] and "savetest_itch_target" in capsys.readouterr().err+++def test_the_savetest_command_builds_its_itch_client_on_the_test_target(tmp_path, monkeypatch):+ butler = tmp_path / "butler"+ butler.write_text("")+ monkeypatch.setattr(nightly.shutil, "which", lambda name: "/usr/bin/" + name)+ built = []+ monkeypatch.setattr(nightly, "Itch", lambda runner, path, target: built.append(target) or "itch")+ monkeypatch.setattr(nightly, "savetest", lambda cfg, config, job, runner, gh, itch, *, tag: "PASS")+ cfg = dataclasses.replace(ns.Config(), butler=butler, handoff=tmp_path / "HANDOFF.md",+ itch_page_url="https://eyalgolan.itch.io/statecraft-israel",+ savetest_itch_target=TEST_TARGET, savetest_itch_page_url=PAGE_URL)+ assert nightly.run_savetest(cfg, tmp_path, TAG) == 0 and built == [TEST_TARGET]++def too_many_requests(retry_after=None):import email.messageimport urllib.error