A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Steam staging: refuse a record whose local golden did not pass, and malformed Steam IDs (Refs #2701) (#2703)
Eyal Golanbe32a17edb7b
diff --git a/tools/steam_upload.py b/tools/steam_upload.pyindex 823cea9b3..df77c3310 100644--- a/tools/steam_upload.py+++ b/tools/steam_upload.py@@ -13,8 +13,9 @@ Usage:uv run tools/steam_upload.py verify --dir <draft> --tag vX.Y.Z --branch beta|nightly --record-sha256 <sha> (CI)- stage reads the folder tools/release_build.py --steam wrote (build-record.json and steam/<platform>/), refuses a- record that is not a clean, non-dev Steam build of that tag for `beta` or `nightly`, steam/steam.json while any- ID is null, and a folder that no longer matches the file list the build recorded. It zips the files of that list to steam-<tag>-<platform>.zip (keeping the executable bits and symlinks:+ record that is not a clean, non-dev Steam build of that tag for `beta` or `nightly`, whose locally runnable golden+ did not pass, steam/steam.json while any ID is invalid or depot IDs repeat, and a folder that no longer matches the+ file list the build recorded. It zips the files of that list to steam-<tag>-<platform>.zip (keeping the executable bits and symlinks:steamcmd uploads from a Linux machine), writes steam-record.json (tag, commit, branch, each zip's SHA-256 and size),attaches them to a DRAFT release steam-<tag> (never published; an existing release of that name is replaced only ifit is a draft) and runs `gh workflow run steam-upload.yml --ref main -f tag=<tag> -f branch=<branch>`.@@ -71,14 +72,31 @@ def load_config(path: Path = CONFIG) -> dict:def refuse(config: dict, record: dict | None = None) -> str | None:- """Why nothing may be uploaded, or None: every null ID by name; with a record, a build that is not a clean,- non-dev Steam build for one of the configured branches."""+ """Why nothing may be uploaded, or None: valid distinct IDs; with a record, a clean, non-dev Steam build for a+ configured branch whose golden checks that ran on this machine passed."""problems = []- depots = config.get("depots") or {}- nulls = [n for n, v in [("app_id", config.get("app_id")), *((f"depots.{p}", depots.get(p)) for p in PLATFORMS)]- if v is None]+ raw_depots = config.get("depots")+ depots = raw_depots if isinstance(raw_depots, dict) else {}+ ids = [("app_id", config.get("app_id"))]+ if raw_depots is None or isinstance(raw_depots, dict):+ ids += [(f"depots.{p}", depots.get(p)) for p in PLATFORMS]+ else: # not the owner's missing step: the file itself is malformed+ problems.append(f"steam/steam.json field depots must be an object of platform IDs, not {raw_depots!r}")+ nulls = [name for name, value in ids if value is None]if nulls:problems.append("steam/steam.json has no " + ", ".join(nulls) + " yet (the owner's step, #2151)")+ for name, value in ids:+ if value is not None and (isinstance(value, bool) or not isinstance(value, int) or value <= 0):+ problems.append(f"steam/steam.json field {name} must be a positive integer, not {value!r}")+ seen_depots = {}+ for platform in PLATFORMS:+ value = depots.get(platform)+ if isinstance(value, int) and not isinstance(value, bool) and value > 0:+ if value in seen_depots:+ problems.append(f"steam/steam.json field depots.{platform} duplicates "+ f"depots.{seen_depots[value]} ({value})")+ else:+ seen_depots[value] = platformif record is not None:if record.get("steam") is not True:problems.append("the record is not a Steam build (tools/release_build.py --steam)")@@ -89,6 +107,14 @@ def refuse(config: dict, record: dict | None = None) -> str | None:channel = record.get("channel")if channel == NEVER or channel not in config.get("branches", []):problems.append(f"the record's channel {channel!r} is not one of {config.get('branches')}")+ runs_here = {name for name, platform in rb.PLATFORMS.items() if platform.runs_here}+ for artifact in record.get("artifacts", []):+ platform = artifact.get("platform")+ if platform in runs_here:+ golden = artifact.get("golden")+ status = golden.get("status") if isinstance(golden, dict) else None+ if status != "pass":+ problems.append(f"the record's {platform} golden status {status!r} is not 'pass'")return "; ".join(problems) or Nonediff --git a/tools/tests/test_steam_upload.py b/tools/tests/test_steam_upload.pyindex abd94cc29..93cdaf165 100644--- a/tools/tests/test_steam_upload.py+++ b/tools/tests/test_steam_upload.py@@ -35,7 +35,9 @@ def no_steamcmd(monkeypatch):def record(**over):r = {"schema": 1, "commit": SHA, "tag": "v0.3.2", "release": True, "tree_clean": True,"tree_clean_after_builds": True, "steam": True, "channel": "nightly", "dev": False,- "artifacts": [{"platform": p, "steam_folder": f"steam/{p}", "archive": None} for p in su.PLATFORMS]}+ "artifacts": [{"platform": p, "steam_folder": f"steam/{p}", "archive": None,+ "golden": {"status": "pass" if rb.PLATFORMS[p].runs_here else "unchecked"}}+ for p in su.PLATFORMS]}r.update(over)return r@@ -117,6 +119,25 @@ def test_null_ids_refuse_by_name():assert su.refuse(IDS) is None+def test_a_malformed_depots_field_is_not_reported_as_the_owners_missing_step():+ """#2703 review: a non-object depots value is a broken file, not IDs the owner has yet to fill in."""+ why = su.refuse({**IDS, "depots": [1, 2, 3]})+ assert "field depots must be an object" in why and "owner's step" not in why++[email protected](("config", "field"), [+ ({**IDS, "app_id": False}, "app_id"),+ ({**IDS, "app_id": "1000"}, "app_id"),+ ({**IDS, "depots": {**IDS["depots"], "windows": 0}}, "depots.windows"),+ ({**IDS, "depots": {**IDS["depots"], "mac": -1}}, "depots.mac"),+ ({**IDS, "depots": {**IDS["depots"], "linux": True}}, "depots.linux"),+ ({**IDS, "depots": {**IDS["depots"], "mac": IDS["depots"]["windows"]}}, "depots.mac"),+])+def test_invalid_or_duplicate_ids_refuse_by_field_name(config, field):+ problem = su.refuse(config)+ assert problem is not None and field in problem++def test_the_game_app_id_matches_steam_json():config = json.loads((REPO / "steam/steam.json").read_text())source = REPO / "unity/Assets/Steam/SteamAppId.cs"@@ -238,6 +259,29 @@ def test_stage_refuses_null_ids_before_any_gh_call(tmp_path):assert gh.calls == [][email protected](("config", "field"), [+ ({**IDS, "app_id": False}, "app_id"),+ ({**IDS, "depots": {**IDS["depots"], "windows": 0}}, "depots.windows"),+ ({**IDS, "depots": {**IDS["depots"], "mac": IDS["depots"]["windows"]}}, "depots.mac"),+])+def test_stage_refuses_invalid_or_duplicate_ids_before_any_gh_call(tmp_path, config, field):+ gh = FakeGh()+ with pytest.raises(SystemExit, match=field.replace(".", r"\.")):+ stage(tmp_path, gh, config=config)+ assert gh.calls == []++[email protected]("status", ["fail", "unchecked", "passed", None])+def test_stage_refuses_a_nonpassing_local_golden_before_any_gh_call(tmp_path, status):+ artifacts = record()["artifacts"]+ mac = next(a for a in artifacts if a["platform"] == "mac")+ mac["golden"] = {} if status is None else {"status": status}+ gh = FakeGh()+ with pytest.raises(SystemExit, match=rf"mac golden status .*{status!r}.*not 'pass'"):+ stage(tmp_path, gh, artifacts=artifacts)+ assert gh.calls == []++def test_stage_keeps_the_executable_bits(tmp_path):out = stage(tmp_path, FakeGh())with zipfile.ZipFile(out / "steam-v0.3.2-linux.zip") as z: