A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
nightly: push to itch only with a separate test page and a recorded save test PASS (Refs #2056) (#2232)
Eyal Golanadcec6c1e815
diff --git a/docs/RELEASING.md b/docs/RELEASING.mdindex a0784728a..3ded024e8 100644--- a/docs/RELEASING.md+++ b/docs/RELEASING.md@@ -300,8 +300,8 @@ is shown. The stage is skipped while `steam/steam.json` still has a `null` ID (u#2151), and with `uv run tools/nightly.py run --no-steam`.**itch.io.** Pushes stay off until the owner runs `uv run tools/nightly.py savetest --tag <a published nightly>` once-and 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. The save test pushes only to a separate test page, named in the job's `config.json` as+and it prints `PASS` (the two-upload save test of `docs/m3-release.md`, "Upload to itch.io"); until then each night+logs `itch: skipped (<reason>)`, naming the missing config key or the problem, and pushes nothing to itch. 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 ifthey name the public page: each upload hides the game while itch unpacks it, which took up to an hour on 28 October2026.diff --git a/tools/README.md b/tools/README.mdindex 4f8bf88a3..9f6a3ea4a 100644--- a/tools/README.md+++ b/tools/README.md@@ -224,7 +224,9 @@ and what is public are in `docs/RELEASING.md`, "Nightly builds". It runs on thetest page, then, from the clone and after the first PUBLISHED night,`uv run tools/nightly.py savetest --tag <that nightly's tag>`. It pushes to the test page twice, never to the publicpage, and refuses to run without those two keys or if they name the public page. On a pass, it turns `itch_enabled`- on in `config.json`. `INCONCLUSIVE` and `FAIL` leave itch off.+ on in `config.json`. `INCONCLUSIVE` and `FAIL` leave itch off. A night pushes to itch only while the two test-page+ keys name a separate page and `itch_evidence` records that PASS; otherwise its log line says+ `itch: skipped (<reason>)`, naming the missing key or the problem (#2056).- The boot-time baseline is the median headless boot of the first 5 PUBLISHED nights; later nights must stay withinthe spread of those 5. To measure it again (a new machine, a new Chrome), delete `boot_baseline` from `state.json`;the next 5 published nights record it.diff --git a/tools/nightly.py b/tools/nightly.pyindex 202b9b350..fd9025c70 100644--- a/tools/nightly.py+++ b/tools/nightly.py@@ -667,7 +667,8 @@ def publish_night(night: Night, state: State, gh: GitHub, itch, zips: tuple[Path`save` persists the state; it runs right after the draft exists and right after the release is public, so akill leaves a record of both."""prev_tag, prev_sha = previous- use_itch = night.cfg.itch_enabled+ itch_skip = itch_skip_reason(night.cfg)+ use_itch = itch_skip is Noneif use_itch and itch is None: # before any store change: enabled means the push is part of this nightraise Refused("itch", "itch is enabled but there is no itch client")since = prev_sha or prev_tag@@ -739,7 +740,7 @@ def publish_night(night: Night, state: State, gh: GitHub, itch, zips: tuple[Pathstate.site_pending = night.version # until the demo serves this version, a later night retries the deploysave()if not use_itch:- skip = "itch: skipped (save test not passed)"+ skip = f"itch: skipped ({itch_skip})"print(skip)night.notes.append(skip)failure = "no attempt"@@ -1087,6 +1088,32 @@ def _test_page_problem(cfg: Config) -> str | None:return None+SAVETEST_KEYS = ("savetest_itch_target", "savetest_itch_page_url")+++def itch_skip_reason(cfg: Config) -> str | None:+ """Why tonight's build must not be pushed to the public itch page, or None when it may (#2056). A push needs a+ separate test page in the job's config and a recorded save test PASS on it: itch_enabled alone is not enough,+ so a hand-set flag or a test page that is the public one never leads to a push. Every reason is logged."""+ missing = [key for key in SAVETEST_KEYS if not getattr(cfg, key)]+ if missing:+ return f"the job config has no {' or '.join(missing)}, so no save test can run on a separate test page"+ problem = _test_page_problem(cfg)+ if problem:+ return problem+ if not cfg.itch_enabled:+ return "save test not passed"+ if not cfg.itch_evidence:+ return "itch_enabled is set but no save test evidence is recorded (itch_evidence)"+ try:+ evidence = json.loads(Path(cfg.itch_evidence).read_text(encoding="utf-8"))+ except (OSError, ValueError) as e:+ return f"the save test evidence {cfg.itch_evidence} is unreadable ({type(e).__name__})"+ if not isinstance(evidence, dict) or evidence.get("result") != "PASS":+ return f"the save test evidence {cfg.itch_evidence} does not record a save test PASS"+ 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."""diff --git a/tools/tests/test_nightly.py b/tools/tests/test_nightly.pyindex abda51faf..c81bf5447 100644--- a/tools/tests/test_nightly.py+++ b/tools/tests/test_nightly.py@@ -1515,13 +1515,15 @@ def test_a_published_night_updates_state_and_boot_baseline(night, env, pub, servdef test_itch_is_skipped_with_a_logged_reason_when_there_is_no_client(night, env, pub, served, capsys):publish(night, ns.State(last_published=last_published()), FakeGH(), pub, env)- assert "itch: skipped (save test not passed)" in capsys.readouterr().out+ assert NO_TEST_PAGE in capsys.readouterr().out# --- Task 7: itch.io, behind itch_enabled ---------------------------------------------------------------------------------PREV_TAG = "v0.3.0-nightly.20261027"PREV_VERSION = "0.3.0-nightly.20261027"+PAGE_URL = "https://example.invalid/statecraft-israel-savetest"+TEST_TARGET = "eyalgolan/statecraft-israel-savetest:html5"class FakeItch:@@ -1548,6 +1550,13 @@ class FakeItch:self._call("matches", Path(folder).name)+def evidence_file(tmp_path, result):+ """A save test evidence file as savetest() writes it; `result` may also be any JSON value for a broken file."""+ path = tmp_path / "savetest-evidence.json"+ path.write_text(json.dumps({"result": result} if isinstance(result, str) else result))+ return str(path)++def zip_of(path, name):with zipfile.ZipFile(path, "w") as z:z.writestr("index.html", name)@@ -1556,8 +1565,10 @@ def zip_of(path, name):@pytest.fixturedef itch_night(night, env, tmp_path, served):- """An itch-enabled night with real zips for tonight and the previous build."""- night.cfg = dataclasses.replace(night.cfg, itch_enabled=True)+ """An itch-enabled night with real zips for tonight and the previous build: a separate test page is configured+ and the save test's PASS evidence is on record, so the push may go ahead (#2056)."""+ night.cfg = dataclasses.replace(night.cfg, itch_enabled=True, savetest_itch_target=TEST_TARGET,+ savetest_itch_page_url=PAGE_URL, itch_evidence=evidence_file(tmp_path, "PASS"))clone = str(night.cfg.clone)env.runner.add(["git", "-C", clone, "log", "--format=%s"], out="Fix a thing\n")zips = (zip_of(tmp_path / "web.zip", "tonight"), zip_of(tmp_path / "pages.zip", "pages"))@@ -1583,7 +1594,7 @@ def refused_itch(itch_night, env, itch="fake"):def test_itch_disabled_is_logged_and_never_calls_the_client(night, env, pub, served, capsys):gh = FakeGH()publish(night, ns.State(last_published=last_published()), gh, pub, env, itch=FakeItch(gh.calls))- assert "itch: skipped (save test not passed)" in capsys.readouterr().out+ assert NO_TEST_PAGE in capsys.readouterr().outassert gh.names() == ["ensure_tag_available", "create_draft", "verify_draft", "latest_tag", "publish", "dispatch_site"]@@ -1674,7 +1685,7 @@ def test_an_interrupt_during_publish_rolls_itch_back_and_cleans_the_draft(itch_ndef test_the_itch_skip_reason_is_noted_on_the_night(night, env, pub, served):publish(night, ns.State(last_published=last_published()), FakeGH(), pub, env)- assert night.notes == ["itch: skipped (save test not passed)"]+ assert night.notes == [NO_TEST_PAGE]def test_the_night_notes_reach_the_log_line(env, monkeypatch):@@ -1696,6 +1707,47 @@ def test_a_site_failure_after_publish_does_not_roll_itch_back(itch_night, env):assert "delete_draft" not in gh.names()+# --- #2056: itch only with a separate test page and a recorded save test PASS -------------------------------------------++NO_TEST_PAGE = ("itch: skipped (the job config has no savetest_itch_target or savetest_itch_page_url, so no save test "+ "can run on a separate test page)")++[email protected]("change, reason", [+ ({"savetest_itch_target": None, "savetest_itch_page_url": None}, NO_TEST_PAGE),+ ({"savetest_itch_target": None}, "itch: skipped (the job config has no savetest_itch_target, so"),+ ({"savetest_itch_page_url": ""}, "itch: skipped (the job config has no savetest_itch_page_url, so"),+ ({"savetest_itch_target": "eyalgolan/statecraft-israel:savetest"}, "must not be the public itch project"),+ ({"itch_page_url": PAGE_URL}, "must not be the public itch page"),+ ({"itch_enabled": False}, "itch: skipped (save test not passed)"),+ ({"itch_evidence": None}, "itch_enabled is set but no save test evidence is recorded"),+ ({"itch_evidence": "/nonexistent/evidence.json"}, "is unreadable"),+ ("INCONCLUSIVE", "does not record a save test PASS"),+ (["PASS"], "does not record a save test PASS"),+])+def test_itch_is_skipped_with_its_reason_unless_a_test_page_and_a_pass_are_on_record(itch_night, env, tmp_path, capsys,+ change, reason):+ night = itch_night[0]+ if not isinstance(change, dict): # a broken or non-PASS evidence file+ change = {"itch_evidence": evidence_file(tmp_path, change)}+ night.cfg = dataclasses.replace(night.cfg, **change)+ gh, st = run_itch(itch_night, env)+ assert not [c for c in gh.calls if c[0].startswith("itch.")] and "download" not in gh.names()+ assert len(night.notes) == 1 and night.notes[0].startswith("itch: skipped (") and reason in night.notes[0]+ assert night.notes[0] in capsys.readouterr().out+ assert st.last_published.tag == TAG # the GitHub release still goes out; only itch is held back+++def test_the_job_config_of_2_november_skips_itch_and_names_the_missing_keys(tmp_path):+ config = tmp_path / "config.json" # the live job config held only this key on 2 Nov 2026+ config.write_text(json.dumps({"itch_page_url": "https://eyalgolan.itch.io/statecraft-israel"}))+ assert nightly.itch_skip_reason(ns.load_config(config)) == NO_TEST_PAGE[len("itch: skipped ("):-1]+++def test_a_pass_on_record_with_a_separate_test_page_lets_the_push_go_ahead(itch_night):+ assert nightly.itch_skip_reason(itch_night[0].cfg) is None++# --- the stage wiring ---------------------------------------------------------------------------------------------------@pytest.fixture@@ -1887,8 +1939,6 @@ 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-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"