A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
ci(oss): sim, tools (with dotnet) and repo-policy jobs, changelog check, pinned actions, CODEOWNERS
eyalgolan593294007c3e
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERSnew file mode 100644index 000000000..c162a9f25--- /dev/null+++ b/.github/CODEOWNERS@@ -0,0 +1,3 @@+# Every pull request needs the maintainer's approval. the `main-review` ruleset requires a code-owner review, and this+# file makes the maintainer the owner of every path, so another collaborator's approval does not satisfy it.+* @eyalgolandiff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlnew file mode 100644index 000000000..c94697975--- /dev/null+++ b/.github/workflows/ci.yml@@ -0,0 +1,93 @@+name: CI++# Nothing here uses a secret, calls a paid API, runs an AI agent or pushes anywhere. Pull requests from forks run+# untrusted code (MSBuild targets, pytest conftest files, uv inline scripts), so the token is read-only, checkouts keep+# no credentials, and there is no secret to steal. A pull request can also edit this file and make its own checks green;+# CODEOWNERS review of any .github/ diff is the guard (docs/UNTRUSTED_PR_REVIEW.md). There is no CLA or DCO check:+# contributions come in under the repository licences (inbound = outbound, GitHub Terms of Service D.6; decision D2).+# Unity edit-mode tests are not run here; CONTRIBUTING.md, "What CI runs", says why.+# No `schedule:` and no `pull_request_target`, on purpose. Every action is pinned to a commit SHA+# (scripts/oss/pin_actions.py). The job names are the required checks in scripts/oss/github/ruleset-protect-main.json;+# a test keeps the two identical.++on:+ push:+ branches: [main]+ pull_request:+ types: [opened, synchronize, reopened, labeled, unlabeled]++permissions:+ contents: read++concurrency:+ group: ci-${{ github.workflow }}-${{ github.ref }}+ cancel-in-progress: true++jobs:+ sim:+ name: Sim (dotnet test)+ runs-on: ubuntu-latest+ timeout-minutes: 20+ steps:+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4+ with:+ persist-credentials: false+ - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4+ with:+ dotnet-version: "10.0.x"+ - name: Simulation and content tests+ run: dotnet test sim/Statecraft.sln -c Release++ tools:+ name: Tools (pytest)+ runs-on: ubuntu-latest+ timeout-minutes: 20+ steps:+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4+ with:+ persist-credentials: false+ # tools/tests/test_package_release.py runs the sim's release gate (dotnet run --project sim/Statecraft.Cli).+ - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4+ with:+ dotnet-version: "10.0.x"+ - uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6+ with:+ version: "0.12.5"+ - name: Data tool tests+ run: uv run --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 --with pyyaml==6.0.3 --with pillow==12.3.0 --with requests==2.32.5 pytest tools/tests -q++ policy:+ name: Repo policy+ runs-on: ubuntu-latest+ timeout-minutes: 10+ steps:+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4+ with:+ persist-credentials: false+ - uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6+ with:+ version: "0.12.5"+ - name: Policy checker tests+ run: uv run --with pytest==9.1.1 --with pyyaml==6.0.3 --with requests==2.32.5 pytest scripts/oss/tests -q+ - name: Licences, provenance, secrets and required files at the tip+ run: uv run scripts/oss/check_repo.py --only secrets,emails,home-paths,sizes,symlinks++ changelog:+ name: Changelog+ if: github.event_name == 'pull_request'+ runs-on: ubuntu-latest+ timeout-minutes: 5+ steps:+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4+ with:+ fetch-depth: 0+ persist-credentials: false+ - uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6+ with:+ version: "0.12.5"+ - name: A user-visible change carries a CHANGELOG line or the no-changelog label+ env:+ BASE_SHA: ${{ github.event.pull_request.base.sha }}+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}+ SKIP_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'no-changelog') }}+ run: uv run scripts/oss/changelog_check.py --base "$BASE_SHA" --head "$HEAD_SHA" --skip-label "$SKIP_LABEL"diff --git a/CHANGELOG.md b/CHANGELOG.mdnew file mode 100644index 000000000..82bccdf99--- /dev/null+++ b/CHANGELOG.md@@ -0,0 +1,17 @@+# Changelog++All notable changes to Statecraft: Israel. The format follows+[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow+[Semantic Versioning](https://semver.org/). Every pull request that changes the game (`sim/`, `content/`, `unity/`)+adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBUTING.md`).++## [Unreleased]++### Added+- Browser-playable 1948–1951 (milestone M3): HUD, Cabinet with appointments, Budget, Events, Defence and "Why did this+ happen?" screens over the 3D hex map; sourced content to 31 December 1951; saves; a calibrated economy; the golden+ hash checked in WebGL and macOS players.+- The map (milestone M2): terrain from Copernicus elevation data, biomes from rainfall, 1948 settlements on hexes.+- Open-source release (public since 2026-10-10): licences (MIT code, CC BY-SA 4.0 content, CC BY 4.0 original docs+ and art, CC0 for AI-only images), asset provenance (`ASSETS.yaml`), contributor+ and content policies, CI for the sim, tools and repository policy.diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 948fddad3..6e1438cf0 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -36,10 +36,15 @@ Follow [docs/dev-setup.md](docs/dev-setup.md). In short:- Record the new values everywhere they are pinned (see [docs/determinism.md](docs/determinism.md)), with a one-line reason in its history table.3. **Tests first.** Add or change a test that fails without your change, then make it pass. Run:- `dotnet test sim/Statecraft.sln`, which must pass with 0 warnings (warnings are errors);- - the tools tests: the command is in `tools/README.md`;- - Unity EditMode tests, if you touched `unity/`. The command is in `docs/dev-setup.md`. There must be 0 `warning CS` in the log.+ - the tools tests (they need the .NET SDK too: one runs the sim's release gate):+ `uv run --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 --with pyyaml==6.0.3 --with pillow==12.3.0 --with requests==2.32.5 pytest tools/tests -q`;+ - the repository policy checks:+ `uv run --with pytest==9.1.1 --with pyyaml==6.0.3 --with requests==2.32.5 pytest scripts/oss/tests -q` and `uv run scripts/oss/check_repo.py`;+ - Unity EditMode tests, if you touched `unity/` (`-buildTarget OSXUniversal` keeps an earlier WebGL build from leaving the editor on the wrong platform):+ `"$UNITY" -batchmode -projectPath unity -buildTarget OSXUniversal -runTests -testPlatform EditMode -testResults "$PWD/unity-editmode.xml" -logFile unity-tests.log`. There must be 0 `warning CS` in the log.4. **Text the player sees** has no internal ids, gives dates as "15 May 1948", and shows money as "IL 1.2m" or "$1.2m". The tests enforce this.5. **Keep the pull request focused:** one change per PR, and no unrelated refactors.+6. **Changelog.** If you change `sim/`, `content/` or `unity/` (tests excepted), add a line under `## [Unreleased]` in [CHANGELOG.md](CHANGELOG.md). CI's `Changelog` job checks it; the maintainer can add the `no-changelog` label to a change no player would notice.## History and content rules@@ -57,7 +62,13 @@ AI-assisted work is welcome. Say so in the pull request: which parts, and how yo- Base your branch on `main`. History on `main` is protected, so no force-pushes.- In the description, say what changed and why. Paste the test commands you ran and their output; a description of the output doesn't count.-- The maintainer reviews every PR. CI is being set up; until then, the pasted test output is the evidence.+- The maintainer reviews every PR (`.github/CODEOWNERS`); a push after approval needs a fresh approval. PRs are squash-merged and keep you as the author.++## What CI runs++Every pull request and every push to `main` runs `Sim (dotnet test)`, `Tools (pytest)`, `Repo policy`, and, on pull requests, `Changelog`. The jobs use no secrets, call no paid API, run no AI agent and push nothing.++**Unity EditMode tests are not in CI.** Running Unity in CI needs the maintainer's Unity account credentials stored as repository secrets. GitHub never gives secrets to pull requests from forks, so the job could not run on the pull requests that most need it, and those credentials would sit on machines that run outside code. So the Unity tests are a local gate: paste their result in your PR, and the maintainer re-runs them before merging any change under `unity/`.## Securitydiff --git a/scripts/oss/allow.yaml b/scripts/oss/allow.yamlnew file mode 100644index 000000000..223f322df--- /dev/null+++ b/scripts/oss/allow.yaml@@ -0,0 +1,6 @@+# Reviewed exceptions to scripts/oss/check_repo.py. Each row: the check it silences, a glob (fnmatch: '*' also+# matches '/'), and the reason. A row that silences nothing is reported as stale-allow.+allow:+ - check: home-paths+ glob: "unity/Assets/Tests/*"+ reason: "Fake home paths in the boot-failure path-redaction tests (GameSceneTests, SaveUiTests); fixtures by design"diff --git a/scripts/oss/changelog_check.py b/scripts/oss/changelog_check.pynew file mode 100755index 000000000..11e3d460a--- /dev/null+++ b/scripts/oss/changelog_check.py@@ -0,0 +1,54 @@+# /// script+# requires-python = ">=3.11"+# dependencies = []+# ///+"""Per-pull-request changelog rule: if the PR changes a user-visible path, it must touch CHANGELOG.md or carry the+`no-changelog` label. Looks at the PR's own diff only, never at earlier history.++Usage: uv run scripts/oss/changelog_check.py --base <base-sha> [--head HEAD] [--skip-label true|false]"""+from __future__ import annotations++import argparse+import subprocess+import sys++USER_VISIBLE = ("content/", "sim/Statecraft.Sim/", "sim/Statecraft.Cli/", "unity/Assets/", "unity/ProjectSettings/",+ "unity/Packages/")+NOT_USER_VISIBLE = ("unity/Assets/Tests/",)+++def user_visible(paths: list[str]) -> list[str]:+ return [p for p in paths if p.startswith(USER_VISIBLE) and not p.startswith(NOT_USER_VISIBLE)]+++def verdict(paths: list[str], skip_label: bool) -> tuple[bool, str]:+ visible = user_visible(paths)+ if not visible:+ return True, "No user-visible change; no CHANGELOG entry needed."+ if "CHANGELOG.md" in paths:+ return True, "CHANGELOG.md is updated."+ if skip_label:+ return True, "The no-changelog label is set."+ listed = "\n".join(f" {p}" for p in visible)+ return False, ("These user-visible paths changed without a CHANGELOG.md entry:\n" + listed ++ "\nAdd a line under ## [Unreleased] in CHANGELOG.md, or ask a maintainer for the no-changelog label.")+++def changed_paths(base: str, head: str) -> list[str]:+ out = subprocess.run(["git", "diff", "--name-only", f"{base}...{head}"], capture_output=True, text=True, check=True)+ return [p for p in out.stdout.splitlines() if p]+++def main(argv: list[str] | None = None) -> int:+ ap = argparse.ArgumentParser()+ ap.add_argument("--base", required=True)+ ap.add_argument("--head", default="HEAD")+ ap.add_argument("--skip-label", default="false")+ a = ap.parse_args(argv)+ ok, msg = verdict(changed_paths(a.base, a.head), a.skip_label.lower() == "true")+ print(msg)+ return 0 if ok else 1+++if __name__ == "__main__":+ sys.exit(main())diff --git a/scripts/oss/check_repo.py b/scripts/oss/check_repo.pynew file mode 100755index 000000000..938a96b9d--- /dev/null+++ b/scripts/oss/check_repo.py@@ -0,0 +1,225 @@+# /// script+# requires-python = ">=3.11"+# dependencies = ["pyyaml==6.0.3"]+# ///+"""Policy checks over the TRACKED files at the tip of the tree, the tree a clone receives. Prints one line per finding+(check, path, line, kind) and never the matched text, so a found secret is not copied into a CI log.++Known, reviewed exceptions live in scripts/oss/allow.yaml ({check, glob, reason}); a row that suppresses nothing is+itself reported (stale-allow), so the list cannot silently outlive its reason.++Usage: uv run scripts/oss/check_repo.py [--root DIR] [--only a,b,...] [--release]+--release also refuses open owner decisions (docs/oss/DECISIONS.md) and ASSETS.yaml rows still marked owner-verify+or with licence unknown; CI runs without it, the release gate with it. Exit 0 clean, 1 findings, 2 usage error."""+from __future__ import annotations++import argparse+import fnmatch+import os+import subprocess+import sys+from dataclasses import dataclass+from pathlib import Path+from typing import Callable++import yaml++sys.path.insert(0, str(Path(__file__).resolve().parent))+import oss_policy as P # noqa: E402++ALLOW_FILE = "scripts/oss/allow.yaml"+ASSET_FILES = ("ASSETS.yaml", "ASSETS.portraits.yaml")+++@dataclass(frozen=True)+class Finding:+ check: str+ path: str+ line: int # 0 when the finding is about the whole file+ kind: str++ def __str__(self) -> str:+ where = f"{self.path}:{self.line}" if self.line else self.path+ return f"{self.check}: {where}: {self.kind}"+++def tracked_files(root: Path) -> list[str]:+ out = subprocess.run(["git", "-C", str(root), "ls-files", "-z"], capture_output=True, check=True).stdout+ return sorted(p for p in out.decode("utf-8").split("\0") if p)+++def git_binary_files(root: Path) -> set[str]:+ """Files git's own attribute logic treats as binary in the index (`i/-text`)."""+ out = subprocess.run(["git", "-C", str(root), "ls-files", "--eol", "-z"], capture_output=True, check=True).stdout+ found = set()+ for rec in out.decode("utf-8").split("\0"):+ if rec.startswith("i/-text"):+ found.add(rec.split("\t", 1)[1])+ return found+++def _text(root: Path, rel: str) -> str | None:+ p = root / rel+ if p.is_symlink() or not p.is_file():+ return None+ data = p.read_bytes()+ if b"\0" in data[:8192]:+ return None+ try:+ return data.decode("utf-8")+ except UnicodeDecodeError:+ return None+++def _line_check(name: str, fn: Callable[[str], list[str]]):+ def check(root: Path, files: list[str], release: bool) -> list[Finding]:+ found = []+ for rel in files:+ text = _text(root, rel)+ if text is None:+ continue+ for n, line in enumerate(text.splitlines(), 1):+ found += [Finding(name, rel, n, k) for k in fn(line)]+ return found+ return check+++def check_sizes(root: Path, files: list[str], release: bool) -> list[Finding]:+ return [Finding("sizes", rel, 0, "over-size-limit") for rel in files+ if (root / rel).is_file() and not (root / rel).is_symlink()+ and (root / rel).stat().st_size > P.MAX_FILE_BYTES]+++def check_symlinks(root: Path, files: list[str], release: bool) -> list[Finding]:+ found = []+ for rel in files:+ p = root / rel+ if not p.is_symlink():+ continue+ target = os.readlink(p)+ inside = (p.parent / target).resolve().is_relative_to(root.resolve())+ if os.path.isabs(target) or not inside:+ found.append(Finding("symlinks", rel, 0, "symlink-outside-repo"))+ return found+++def check_required(root: Path, files: list[str], release: bool) -> list[Finding]:+ tracked = set(files)+ return [Finding("required", rel, 0, "missing") for rel in P.REQUIRED_FILES if rel not in tracked]+++def check_decisions(root: Path, files: list[str], release: bool) -> list[Finding]:+ rel = "docs/oss/DECISIONS.md"+ if not release or rel not in files:+ return []+ text = _text(root, rel) or ""+ return [Finding("decisions", rel, n, "open-decision")+ for n, line in enumerate(text.splitlines(), 1) if line.lstrip().startswith("- [ ]")]+++def load_asset_rules(root: Path) -> tuple[list[dict], list[dict]]:+ rules: list[dict] = []+ removed: list[dict] = []+ for name in ASSET_FILES:+ p = root / name+ if p.is_file():+ doc = yaml.safe_load(p.read_text(encoding="utf-8")) or {}+ rules += [dict(r, _file=name) for r in doc.get("rules") or []]+ removed += doc.get("removed") or []+ return rules, removed+++def _needs_provenance(rel: str, binary: set[str]) -> bool:+ return (rel in binary or Path(rel).suffix.lower() in P.BINARY_EXTENSIONS+ or any(fnmatch.fnmatch(rel, g) for g in P.PROVENANCE_GLOBS))+++def check_assets(root: Path, files: list[str], release: bool) -> list[Finding]:+ """Note: fnmatch's '*' also matches '/', so "promo/ref/*-src.jpg" covers subfolders too. That is intended."""+ rules, removed = load_asset_rules(root)+ found: list[Finding] = []+ good: list[dict] = []+ for r in rules:+ missing = [k for k in P.RULE_KEYS if not r.get(k)]+ if missing:+ found.append(Finding("assets", r["_file"], 0, f"bad-rule missing {','.join(missing)}"))+ continue+ good.append(r)+ if r["licence"] not in P.ALLOWED_LICENCES:+ found.append(Finding("assets", r["_file"], 0, f"unknown-licence {r['licence']}"))+ if r["status"] not in P.STATUSES:+ found.append(Finding("assets", r["_file"], 0, f"bad-status {r['status']}"))+ elif release and (r["status"] == "owner-verify" or r["licence"] == "unknown"):+ found.append(Finding("assets", r["_file"], 0, f"owner-verify {r['glob']}"))+ if not r.get("allow_empty") and not any(fnmatch.fnmatch(f, r["glob"]) for f in files):+ found.append(Finding("assets", r["_file"], 0, f"stale-rule {r['glob']}"))+ binary = git_binary_files(root)+ for rel in files:+ if rel in ASSET_FILES or not _needs_provenance(rel, binary):+ continue+ if not any(fnmatch.fnmatch(rel, r["glob"]) for r in good):+ found.append(Finding("assets", rel, 0, "no-provenance"))+ tracked = set(files)+ found += [Finding("assets", d["path"], 0, "removed-but-tracked") for d in removed if d["path"] in tracked]+ return found+++CHECKS: dict[str, Callable[[Path, list[str], bool], list[Finding]]] = {+ "secrets": _line_check("secrets", P.secret_kinds),+ "emails": _line_check("emails", P.email_kinds),+ "home-paths": _line_check("home-paths", P.home_path_kinds),+ "sizes": check_sizes,+ "symlinks": check_symlinks,+ "required": check_required,+ "decisions": check_decisions,+ "assets": check_assets,+}+++def apply_allowlist(root: Path, findings: list[Finding], checks: list[str]) -> list[Finding]:+ p = root / ALLOW_FILE+ rows: list[dict] = []+ if p.is_file():+ rows = (yaml.safe_load(p.read_text(encoding="utf-8")) or {}).get("allow") or []+ kept, used = [], set()+ for f in findings:+ hit = next((i for i, r in enumerate(rows)+ if r.get("check") == f.check and fnmatch.fnmatch(f.path, r.get("glob", ""))), None)+ if hit is None:+ kept.append(f)+ else:+ used.add(hit)+ for i, r in enumerate(rows):+ if not r.get("reason"):+ kept.append(Finding("allow", ALLOW_FILE, 0, f"allow-row-without-reason {r.get('glob')}"))+ elif r.get("check") in checks and i not in used:+ kept.append(Finding("allow", ALLOW_FILE, 0, f"stale-allow {r.get('check')} {r.get('glob')}"))+ return kept+++def main(argv: list[str] | None = None) -> int:+ ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])+ ap.add_argument("--root", type=Path, default=Path.cwd())+ ap.add_argument("--only", default="")+ ap.add_argument("--release", action="store_true")+ args = ap.parse_args(argv)+ names = [n for n in args.only.split(",") if n] or list(CHECKS)+ unknown = [n for n in names if n not in CHECKS]+ if unknown:+ print(f"unknown check(s): {', '.join(unknown)}; known: {', '.join(CHECKS)}")+ return 2+ root = args.root.resolve()+ files = tracked_files(root)+ findings = [f for n in names for f in CHECKS[n](root, files, args.release)]+ findings = apply_allowlist(root, findings, names)+ for f in findings:+ print(f)+ if findings:+ print(f"FAIL: {len(findings)} finding(s) in checks {', '.join(names)}")+ return 1+ print(f"OK: checks {', '.join(names)} over {len(files)} tracked files")+ return 0+++if __name__ == "__main__":+ sys.exit(main())diff --git a/scripts/oss/oss_policy.py b/scripts/oss/oss_policy.pynew file mode 100755index 000000000..d93059df5--- /dev/null+++ b/scripts/oss/oss_policy.py@@ -0,0 +1,79 @@+"""Shared rules for the open-source checks: what a secret looks like, which emails and paths are personal, what files a+public tree must carry, which files need a provenance row, and how large a file may be. One module, so check_repo.py+(tip of tree) and scan_history.py (every commit) can never disagree about what they look for."""+from __future__ import annotations++import re++SECRET_PATTERNS: dict[str, re.Pattern[str]] = {+ "elevenlabs-key": re.compile(r"\bsk_[0-9a-f]{40,}\b"),+ "anthropic-key": re.compile(r"sk-ant-[A-Za-z0-9_\-]{20,}"),+ "openai-key": re.compile(r"\bsk-(?:proj-)?[A-Za-z0-9]{20,}"),+ "aws-access-key-id": re.compile(r"\b(?:AKIA|ASIA)[0-9A-Z]{16}\b"),+ "github-token": re.compile(r"\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,}"),+ "google-api-key": re.compile(r"\bAIza[0-9A-Za-z_\-]{35}\b"),+ "slack-token": re.compile(r"xox[baprs]-[A-Za-z0-9-]{10,}"),+ "private-key": re.compile(r"-----BEGIN [A-Z ]*PRIVATE KEY-----"),+ "jwt": re.compile(r"\beyJ[A-Za-z0-9_\-]{10,}\.[A-Za-z0-9_\-]{10,}\.[A-Za-z0-9_\-]{10,}"),+ "secret-assignment": re.compile(+ r"(?i)(?:api[_-]?key|secret|token|passw(?:or)?d)['\"]?\s*[:=]\s*['\"][A-Za-z0-9_\-/+=]{16,}['\"]"),+ # Unity writes these into ProjectSettings.asset when the project is linked to Unity Cloud. Empty is fine. The value+ # shapes are narrow on purpose (a GUID; a slug that ends the line) so that this file and its tests, which mention+ # the keys, do not match themselves.+ "unity-cloud-project-id": re.compile(r"cloudProjectId:[ \t]*[0-9a-fA-F]{8}-"),+ "unity-organization-id": re.compile(r"organizationId:[ \t]*[A-Za-z0-9][\w.-]*[ \t]*$"),+ "unity-licence-secret": re.compile(r"(?i)UNITY_(?:SERIAL|PASSWORD|LICENSE)\s*[:=]\s*\S{6,}"),+}++# The local part must start with a letter or digit (so "@pytest.mark" is not an address), and the last domain label+# must be letters only (so a Unity package id such as "[email protected]" is not an address).+EMAIL = re.compile(r"(?<![\w.+-])[A-Za-z0-9][A-Za-z0-9._%+\-]*@((?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,})(?![\w.-])")+ALLOWED_EMAIL_DOMAINS = frozenset({"users.noreply.github.com", "anthropic.com", "example.com", "example.org",+ "example.net"})++HOME_PATH = re.compile(r"(?:/Users/(?!Shared/)|/home/)[A-Za-z][\w.\-]*/")++MAX_FILE_BYTES = 10 * 1024 * 1024++REQUIRED_FILES: tuple[str, ...] = (+ "LICENSE", "LICENSES/CC-BY-4.0.txt", "LICENSES/CC-BY-SA-4.0.txt", "LICENSES/CC0-1.0.txt",+ "LICENSES/YamlDotNet-MIT.txt", "LICENSING.md", "NOTICE", "THIRD-PARTY-NOTICES.md", "ASSETS.yaml",+ "README.md", "README.he.md", "BUILDING.md", "CONTRIBUTING.md", "CODE_OF_CONDUCT.md", "SECURITY.md",+ "TRADEMARK.md", "CHANGELOG.md", "docs/CONTENT_POLICY.md",+ "docs/UNTRUSTED_PR_REVIEW.md", "docs/RELEASING.md", "docs/oss/DECISIONS.md", ".github/CODEOWNERS",+ ".github/pull_request_template.md", ".github/workflows/ci.yml",+)++# Files whose provenance ASSETS.yaml must record (check "assets"). Any file git itself treats as binary counts too.+BINARY_EXTENSIONS = frozenset({+ ".png", ".jpg", ".jpeg", ".webp", ".gif", ".bmp", ".tif", ".tiff", ".tga", ".psd", ".exr", ".hdr", ".svg",+ ".mp4", ".mov", ".webm", ".r16", ".u16", ".raw",+ ".ttf", ".otf", ".woff", ".woff2",+ ".wav", ".ogg", ".mp3", ".flac", ".aiff", ".m4a",+ ".fbx", ".obj", ".blend", ".glb", ".gltf",+ ".pdf", ".unitypackage",+})+PROVENANCE_GLOBS: tuple[str, ...] = ("content/map/*", "unity/Assets/StreamingAssets/map/*")++ALLOWED_LICENCES = frozenset({"MIT", "CC-BY-4.0", "CC-BY-SA-4.0", "CC0-1.0", "OFL-1.1", "Public-Domain",+ "Copernicus-DEM", "IMS-data.gov.il", "Unity-Companion-License", "unknown"})+STATUSES = frozenset({"verified", "owner-verify"})+RULE_KEYS = ("glob", "licence", "source", "status")+++def secret_kinds(line: str) -> list[str]:+ return [kind for kind, rx in SECRET_PATTERNS.items() if rx.search(line)]+++def email_kinds(line: str) -> list[str]:+ for m in EMAIL.finditer(line):+ domain = m.group(1).lower()+ local = m.group(0).split("@", 1)[0].lower()+ if domain in ALLOWED_EMAIL_DOMAINS or local == "noreply":+ continue+ return ["personal-email"]+ return []+++def home_path_kinds(line: str) -> list[str]:+ return ["home-path"] if HOME_PATH.search(line) else []diff --git a/scripts/oss/pin_actions.py b/scripts/oss/pin_actions.pynew file mode 100755index 000000000..f8bd32950--- /dev/null+++ b/scripts/oss/pin_actions.py@@ -0,0 +1,53 @@+# /// script+# requires-python = ">=3.11"+# dependencies = []+# ///+"""Pin every `uses: owner/repo@ref` in .github/workflows/*.yml to the ref's full commit SHA, keeping the ref as a+trailing comment. Resolves with a read-only `gh api` GET. A tag can be moved by its owner; a SHA cannot (no_human+5f99b7af3: unpinned third-party downloads in the release build).++Usage: uv run scripts/oss/pin_actions.py"""+from __future__ import annotations++import re+import subprocess+import sys+from pathlib import Path+from typing import Callable++ROOT = Path(__file__).resolve().parents[2]+USES = re.compile(r"^(?P<lead>\s*-?\s*uses:\s*)(?P<action>[\w.-]+/[\w./-]+)@(?P<ref>[^\s#]+)(?P<rest>.*)$")+++def gh_resolve(action: str, ref: str) -> str:+ repo = "/".join(action.split("/")[:2])+ out = subprocess.run(["gh", "api", f"repos/{repo}/commits/{ref}", "--jq", ".sha"], capture_output=True,+ text=True, check=True).stdout.strip()+ if not re.fullmatch(r"[0-9a-f]{40}", out):+ raise SystemExit(f"could not resolve {action}@{ref}: {out!r}")+ return out+++def pin_text(text: str, resolve: Callable[[str, str], str]) -> str:+ lines = []+ for line in text.splitlines(keepends=True):+ m = USES.match(line.rstrip("\n"))+ if m and not re.fullmatch(r"[0-9a-f]{40}", m["ref"]):+ sha = resolve(m["action"], m["ref"])+ line = f"{m['lead']}{m['action']}@{sha} # {m['ref']}\n"+ lines.append(line)+ return "".join(lines)+++def main() -> int:+ for wf in sorted((ROOT / ".github/workflows").glob("*.yml")):+ before = wf.read_text(encoding="utf-8")+ after = pin_text(before, gh_resolve)+ if after != before:+ wf.write_text(after, encoding="utf-8")+ print(f"pinned {wf.relative_to(ROOT)}")+ return 0+++if __name__ == "__main__":+ sys.exit(main())diff --git a/scripts/oss/tests/conftest.py b/scripts/oss/tests/conftest.pynew file mode 100644index 000000000..0d4a97f1d--- /dev/null+++ b/scripts/oss/tests/conftest.py@@ -0,0 +1,42 @@+import subprocess+import sys+from pathlib import Path++import pytest++sys.path.insert(0, str(Path(__file__).resolve().parents[1]))+++def git(root: Path, *args: str) -> str:+ return subprocess.run(["git", "-C", str(root), *args], capture_output=True, text=True, check=True).stdout+++def commit_all(root: Path, msg: str) -> str:+ git(root, "add", "-A")+ git(root, "-c", "user.name=t", "-c", "[email protected]", "commit", "-qm", msg)+ return git(root, "rev-parse", "HEAD").strip()[:10]+++def make_repo(tmp_path):+ """A throwaway git repo with the given files tracked. Values are bytes or str; a str starting with '->' is a+ symlink target."""+ def _make(files: dict[str, bytes | str], untracked: dict[str, str] | None = None) -> Path:+ root = tmp_path / "repo"+ root.mkdir()+ git(root, "init", "-q", "-b", "main")+ for rel, data in files.items():+ p = root / rel+ p.parent.mkdir(parents=True, exist_ok=True)+ if isinstance(data, str) and data.startswith("->"):+ p.symlink_to(data[2:])+ elif isinstance(data, bytes):+ p.write_bytes(data)+ else:+ p.write_text(data, encoding="utf-8")+ git(root, "add", "-A")+ for rel, data in (untracked or {}).items():+ (root / rel).parent.mkdir(parents=True, exist_ok=True)+ (root / rel).write_text(data, encoding="utf-8")+ return root+ return _makediff --git a/scripts/oss/tests/test_assets.py b/scripts/oss/tests/test_assets.pynew file mode 100644index 000000000..3cfef7d2c--- /dev/null+++ b/scripts/oss/tests/test_assets.py@@ -0,0 +1,104 @@+import check_repo++RULES = """rules:+ - glob: "img/*.png"+ licence: CC-BY-4.0+ source: ours+ status: verified+ - glob: "future/*"+ licence: Copernicus-DEM+ source: visual-v1 bakes+ status: verified+ allow_empty: true+removed: []+"""+++def run(root, *args):+ return check_repo.main(["--root", str(root), "--only", "assets", *args])+++def test_covered_binary_passes(make_repo, capsys):+ root = make_repo({"ASSETS.yaml": RULES, "img/a.png": b"\x89PNG"})+ assert run(root) == 0+++def test_uncovered_binary_is_named(make_repo, capsys):+ root = make_repo({"ASSETS.yaml": RULES, "img/a.png": b"\x89PNG", "art/new.jpg": b"\xff\xd8"})+ assert run(root) == 1+ assert "assets: art/new.jpg: no-provenance" in capsys.readouterr().out+++def test_every_listed_asset_extension_needs_provenance(make_repo, capsys):+ exts = [".svg", ".psd", ".exr", ".fbx", ".woff", ".woff2", ".otf", ".tga", ".hdr", ".glb", ".gltf", ".blend",+ ".wav", ".ogg", ".mp3"]+ files = {"ASSETS.yaml": RULES, "img/a.png": b"\x89PNG"}+ files.update({f"art/f{e}": "text-like content\n" for e in exts})+ root = make_repo(files)+ assert run(root) == 1+ out = capsys.readouterr().out+ for e in exts:+ assert f"assets: art/f{e}: no-provenance" in out, e+++def test_a_file_git_sees_as_binary_needs_provenance_whatever_its_name(make_repo, capsys):+ root = make_repo({"ASSETS.yaml": RULES, "img/a.png": b"\x89PNG", "data/blob.dat": b"\x00\x01\x02binary"})+ assert run(root) == 1+ assert "assets: data/blob.dat: no-provenance" in capsys.readouterr().out+++def test_provenance_globs_cover_map_data_text_files(make_repo, capsys):+ root = make_repo({"ASSETS.yaml": RULES, "img/a.png": b"\x89PNG", "content/map/x.json": "{}"})+ assert run(root) == 1+ assert "content/map/x.json: no-provenance" in capsys.readouterr().out+++def test_stale_rule_is_named_unless_allow_empty(make_repo, capsys):+ root = make_repo({"ASSETS.yaml": RULES})+ assert run(root) == 1+ out = capsys.readouterr().out+ assert "assets: ASSETS.yaml: stale-rule img/*.png" in out and "future/*" not in out+++def test_rule_missing_a_key_is_a_bad_rule_not_a_crash(make_repo, capsys):+ root = make_repo({"ASSETS.yaml": "rules:\n - licence: MIT\n source: x\n status: verified\n"})+ assert run(root) == 1+ assert "bad-rule missing glob" in capsys.readouterr().out+++def test_unknown_licence_and_bad_status(make_repo, capsys):+ bad = RULES.replace("licence: CC-BY-4.0", "licence: WTFPL").replace("status: verified\n - glob: \"future",+ "status: maybe\n - glob: \"future")+ root = make_repo({"ASSETS.yaml": bad, "img/a.png": b"\x89PNG"})+ assert run(root) == 1+ out = capsys.readouterr().out+ assert "unknown-licence WTFPL" in out and "bad-status maybe" in out+++def test_release_mode_refuses_owner_verify_rows(make_repo, capsys):+ rules = RULES.replace("source: ours\n status: verified", "source: ours\n status: owner-verify")+ root = make_repo({"ASSETS.yaml": rules, "img/a.png": b"\x89PNG"})+ assert run(root) == 0+ assert run(root, "--release") == 1+ assert "assets: ASSETS.yaml: owner-verify img/*.png" in capsys.readouterr().out+++def test_release_mode_refuses_unknown_licence(make_repo, capsys):+ rules = RULES.replace("licence: CC-BY-4.0", "licence: unknown")+ root = make_repo({"ASSETS.yaml": rules, "img/a.png": b"\x89PNG"})+ assert run(root) == 0+ assert run(root, "--release") == 1+++def test_portraits_file_is_read_too(make_repo, capsys):+ portraits = 'rules:\n - glob: "p/a.jpg"\n licence: Public-Domain\n source: commons\n status: verified\n'+ root = make_repo({"ASSETS.yaml": RULES, "ASSETS.portraits.yaml": portraits, "img/a.png": b"\x89PNG",+ "p/a.jpg": b"\xff\xd8"})+ assert run(root) == 0+++def test_removed_path_must_not_be_tracked(make_repo, capsys):+ rules = RULES.replace("removed: []", 'removed:\n - { path: "img/a.png", reason: "x", date: 2026-10-11 }')+ root = make_repo({"ASSETS.yaml": rules, "img/a.png": b"\x89PNG"})+ assert run(root) == 1+ assert "img/a.png: removed-but-tracked" in capsys.readouterr().outdiff --git a/scripts/oss/tests/test_changelog_check.py b/scripts/oss/tests/test_changelog_check.pynew file mode 100644index 000000000..49d3821d1--- /dev/null+++ b/scripts/oss/tests/test_changelog_check.py@@ -0,0 +1,26 @@+import changelog_check as cc+++def test_user_visible_change_without_changelog_fails_and_names_the_paths():+ ok, msg = cc.verdict(["content/events/x.yaml", "README.md"], skip_label=False)+ assert not ok and "content/events/x.yaml" in msg and "## [Unreleased]" in msg and "no-changelog" in msg+++def test_changelog_entry_satisfies_it():+ assert cc.verdict(["sim/Statecraft.Sim/Rng.cs", "CHANGELOG.md"], skip_label=False)[0]+++def test_label_satisfies_it():+ assert cc.verdict(["unity/Assets/Scripts/UI/GameRoot.cs"], skip_label=True)[0]+++def test_tests_docs_tools_and_ci_need_no_entry():+ for p in ("unity/Assets/Tests/EditMode/MapTests.cs", "sim/Statecraft.Sim.Tests/CoreTests.cs", "docs/x.md",+ "tools/hexgrid.py", ".github/workflows/ci.yml", "scripts/oss/check_repo.py"):+ assert cc.verdict([p], skip_label=False)[0], p+++def test_every_user_visible_root_is_named():+ for p in ("content/people.yaml", "sim/Statecraft.Sim/Rng.cs", "sim/Statecraft.Cli/Program.cs",+ "unity/Assets/UI/Game.uxml", "unity/ProjectSettings/ProjectSettings.asset", "unity/Packages/manifest.json"):+ assert cc.user_visible([p]) == [p], pdiff --git a/scripts/oss/tests/test_check_repo.py b/scripts/oss/tests/test_check_repo.pynew file mode 100644index 000000000..ae7741ba9--- /dev/null+++ b/scripts/oss/tests/test_check_repo.py@@ -0,0 +1,132 @@+import check_repo+import oss_policy++# Fake secrets are assembled at run time so that this file never holds a secret-shaped literal.+FAKE_ELEVENLABS = "sk_" + "ab" * 24+FAKE_GITHUB = "ghp_" + "A1" * 18+ALLOW = 'allow:\n - check: home-paths\n glob: "tests/fixtures/*"\n reason: "redaction fixtures"\n'+++def run(root, *args):+ return check_repo.main(["--root", str(root), *args])+++def test_fake_key_is_reported_by_type_and_never_by_value(make_repo, capsys):+ root = make_repo({"promo/x.py": f'KEY = "{FAKE_ELEVENLABS}"\nTOKEN = "{FAKE_GITHUB}"\n'})+ assert run(root, "--only", "secrets") == 1+ out = capsys.readouterr().out+ assert "secrets: promo/x.py:1: elevenlabs-key" in out+ assert "secrets: promo/x.py:2: github-token" in out+ assert FAKE_ELEVENLABS not in out and FAKE_GITHUB not in out+++def test_clean_tree_passes(make_repo, capsys):+ root = make_repo({"sim/a.cs": "class A {}\n"})+ assert run(root, "--only", "secrets,emails,home-paths,sizes,symlinks") == 0+ assert "OK" in capsys.readouterr().out+++def test_unity_cloud_ids_empty_pass(make_repo, capsys):+ root = make_repo({"unity/ProjectSettings/ProjectSettings.asset": " cloudProjectId: \n organizationId: \n"})+ assert run(root, "--only", "secrets") == 0+++def test_unity_cloud_ids_filled_fail(make_repo, capsys):+ guid = "1234abcd-" + "12ab-" * 3 + "1234567890ab"+ root = make_repo({"unity/ProjectSettings/ProjectSettings.asset":+ f" cloudProjectId: {guid}\n organizationId: some-org\n"})+ assert run(root, "--only", "secrets") == 1+ out = capsys.readouterr().out+ assert "unity-cloud-project-id" in out and "unity-organization-id" in out+ assert guid not in out and "some-org" not in out+++def test_personal_email_fails_and_noreply_passes(make_repo, capsys):+ personal = "someone" + "@" + "gmail.com"+ root = make_repo({"a.py": f'UA = "x ({personal})"\n',+ "b.md": "Co-Authored-By: Claude <noreply" + "@" + "anthropic.com>\n",+ "c.md": "x <5146175+eyalgolan" + "@" + "users.noreply.github.com>\n",+ "d.py": " @pytest.mark.parametrize('a', [1])\n"})+ assert run(root, "--only", "emails") == 1+ out = capsys.readouterr().out+ assert "emails: a.py:1: personal-email" in out+ assert "b.md" not in out and "c.md" not in out and "d.py" not in out+ assert personal not in out+++def test_package_ids_with_numeric_versions_are_not_emails(make_repo, capsys):+ # Review C1: ProjectSettings.asset and docs carry Unity package ids such as these.+ root = make_repo({"ProjectSettings.asset": " templatePackageId: com.unity.template.urp-blank" + "@" + "17.0.14\n",+ "m0.md": "com.unity.ai.assistant" + "@" + "2.20.0-pre.2 and pkg" + "@" + "17.0.14\n"})+ assert run(root, "--only", "emails") == 0+++def test_home_path_fails_and_tilde_passes(make_repo, capsys):+ root = make_repo({"a.md": "see /Users/" + "someone/x\n", "b.md": "see ~/Library/Caches\n",+ "c.md": "see /home/" + "someone/x\n"})+ assert run(root, "--only", "home-paths") == 1+ out = capsys.readouterr().out+ assert "a.md:1: home-path" in out and "c.md:1: home-path" in out and "b.md" not in out+++def test_allowlisted_fixture_passes_and_the_same_line_elsewhere_fails(make_repo, capsys):+ line = 'var p = "/Users/' + 'someone/game";\n'+ root = make_repo({"scripts/oss/allow.yaml": ALLOW, "tests/fixtures/a.cs": line, "src/b.cs": line})+ assert run(root, "--only", "home-paths") == 1+ out = capsys.readouterr().out+ assert "src/b.cs:1: home-path" in out and "tests/fixtures/a.cs" not in out+++def test_stale_allow_row_is_reported(make_repo, capsys):+ root = make_repo({"scripts/oss/allow.yaml": ALLOW, "src/b.cs": "fine\n"})+ assert run(root, "--only", "home-paths") == 1+ assert "stale-allow home-paths tests/fixtures/*" in capsys.readouterr().out+++def test_allow_row_without_reason_is_reported(make_repo, capsys):+ rows = 'allow:\n - check: home-paths\n glob: "x/*"\n'+ root = make_repo({"scripts/oss/allow.yaml": rows, "x/a.cs": "/home/" + "someone/a\n"})+ assert run(root, "--only", "home-paths") == 1+ assert "allow-row-without-reason x/*" in capsys.readouterr().out+++def test_untracked_files_are_not_scanned(make_repo, capsys):+ root = make_repo({"a.txt": "fine\n"}, untracked={"secret.env": f"K={FAKE_ELEVENLABS}\n"})+ assert run(root, "--only", "secrets") == 0+++def test_binary_files_are_not_text_scanned(make_repo, capsys):+ root = make_repo({"img.png": b"\x89PNG\x00\x00" + FAKE_GITHUB.encode()})+ assert run(root, "--only", "secrets") == 0+++def test_large_file_fails(make_repo, capsys):+ root = make_repo({"big.bin": b"\x00" * (oss_policy.MAX_FILE_BYTES + 1)})+ assert run(root, "--only", "sizes") == 1+ assert "sizes: big.bin: over-size-limit" in capsys.readouterr().out+++def test_absolute_symlink_fails(make_repo, capsys):+ root = make_repo({"link": "->/etc/hosts", "ok": "->a.txt", "a.txt": "x\n"})+ assert run(root, "--only", "symlinks") == 1+ out = capsys.readouterr().out+ assert "symlinks: link: symlink-outside-repo" in out and "ok:" not in out+++def test_required_files_are_named_when_missing(make_repo, capsys):+ root = make_repo({"README.md": "x\n"})+ assert run(root, "--only", "required") == 1+ out = capsys.readouterr().out+ assert "required: LICENSE: missing" in out and "required: README.md:" not in out+++def test_release_mode_refuses_open_decisions(make_repo, capsys):+ root = make_repo({"docs/oss/DECISIONS.md": "- [x] D1 decided\n- [ ] D2 open\n"})+ assert run(root, "--only", "decisions") == 0+ assert run(root, "--only", "decisions", "--release") == 1+ assert "decisions: docs/oss/DECISIONS.md:2: open-decision" in capsys.readouterr().out+++def test_unknown_check_name_is_an_error(make_repo, capsys):+ root = make_repo({"a.txt": "x\n"})+ assert run(root, "--only", "nonsense") == 2diff --git a/scripts/oss/tests/test_github_config.py b/scripts/oss/tests/test_github_config.pynew file mode 100644index 000000000..cd599eea5--- /dev/null+++ b/scripts/oss/tests/test_github_config.py@@ -0,0 +1,94 @@+import json+import re+from pathlib import Path++import yaml++ROOT = Path(__file__).resolve().parents[3]+CI = ROOT / ".github/workflows/ci.yml"+RULESET = ROOT / "scripts/oss/github/ruleset-main-review.json"+EXPECTED_JOBS = {"Sim (dotnet test)", "Tools (pytest)", "Repo policy", "Changelog"}+++def ci() -> dict:+ return yaml.safe_load(CI.read_text(encoding="utf-8"))+++def triggers(wf: dict) -> dict:+ return wf.get("on", wf.get(True)) # PyYAML reads the bare key `on` as True+++def steps(wf: dict):+ return [s for j in wf["jobs"].values() for s in j["steps"]]+++def test_job_names_are_the_required_checks():+ assert {j["name"] for j in ci()["jobs"].values()} == EXPECTED_JOBS+ if RULESET.exists():+ rules = json.loads(RULESET.read_text())["rules"]+ checks = next(r for r in rules if r["type"] == "required_status_checks")["parameters"]+ assert {c["context"] for c in checks["required_status_checks"]} == EXPECTED_JOBS+++def test_default_token_is_read_only_and_nothing_targets_the_base_repo():+ wf = ci()+ assert wf["permissions"] == {"contents": "read"}+ t = triggers(wf)+ assert "pull_request_target" not in t and "schedule" not in t and "workflow_run" not in t+++def test_checkouts_keep_no_credentials():+ for s in steps(ci()):+ if s.get("uses", "").startswith("actions/checkout@"):+ assert s.get("with", {}).get("persist-credentials") is False, s+++def test_pull_request_types_rerun_on_label_changes():+ types = set(triggers(ci())["pull_request"]["types"])+ assert {"opened", "synchronize", "reopened", "labeled", "unlabeled"} <= types+++def test_ci_uses_no_secret_but_the_read_only_token():+ text = CI.read_text(encoding="utf-8")+ assert "secrets." not in text+ assert set(re.findall(r"\$\{\{\s*github\.token\s*\}\}", text)) <= {"${{ github.token }}"}+++def test_every_action_is_pinned_to_a_full_sha():+ for wf in (ROOT / ".github/workflows").glob("*.yml"):+ for ref in re.findall(r"uses:\s*[\w.-]+/[\w./-]+@(\S+)", wf.read_text(encoding="utf-8")):+ assert re.fullmatch(r"[0-9a-f]{40}", ref), f"{wf.name}: {ref}"+++def test_tools_job_installs_dotnet():+ # Review C2: tools/tests/test_package_release.py runs the sim's release gate through dotnet.+ tools = next(j for j in ci()["jobs"].values() if j["name"] == "Tools (pytest)")+ assert any(s.get("uses", "").startswith("actions/setup-dotnet@") for s in tools["steps"])+ assert "--deselect" not in CI.read_text(encoding="utf-8")+++def test_changelog_diffs_the_pr_head_not_the_merge_ref():+ text = CI.read_text(encoding="utf-8")+ assert "github.event.pull_request.head.sha" in text and '--head "$HEAD_SHA"' in text+++def test_no_cla_or_dco_machinery():+ # Decision D2 (owner ruling): inbound = outbound under the repository licences; no CLA, no DCO.+ text = CI.read_text(encoding="utf-8")+ assert "CLA" not in text.replace("no CLA or DCO", "").replace("There is no CLA", "") and "Signed-off-by" not in text+ assert not (ROOT / "CLA.md").exists() and not (ROOT / "contributors").exists()+ assert not (ROOT / ".github/workflows/cla-nudge.yml").exists()+++def test_ci_commands_match_contributing():+ contributing = (ROOT / "CONTRIBUTING.md").read_text(encoding="utf-8")+ runs = [s["run"].strip() for s in steps(ci()) if "run" in s]+ for cmd in ("dotnet test sim/Statecraft.sln -c Release", "pytest tools/tests -q", "pytest scripts/oss/tests -q",+ "uv run scripts/oss/check_repo.py"):+ assert any(cmd in r for r in runs), cmd+ assert cmd.replace(" -c Release", "") in contributing, cmd+++def test_codeowners_makes_the_maintainer_owner_of_everything():+ lines = [l for l in (ROOT / ".github/CODEOWNERS").read_text().splitlines() if l and not l.startswith("#")]+ assert lines == ["* @eyalgolan"]diff --git a/scripts/oss/tests/test_pin_actions.py b/scripts/oss/tests/test_pin_actions.pynew file mode 100644index 000000000..42c0dd873--- /dev/null+++ b/scripts/oss/tests/test_pin_actions.py@@ -0,0 +1,15 @@+import pin_actions++SHA = "a" * 40+++def test_tags_are_replaced_by_sha_with_the_tag_kept_as_a_comment():+ text = "steps:\n - uses: actions/checkout@v4\n - uses: astral-sh/setup-uv@v6\n with:\n version: x\n"+ out = pin_actions.pin_text(text, lambda repo, ref: SHA)+ assert f" - uses: actions/checkout@{SHA} # v4\n" in out+ assert f" - uses: astral-sh/setup-uv@{SHA} # v6\n" in out+++def test_already_pinned_lines_are_left_alone():+ text = f" - uses: actions/checkout@{SHA} # v4\n"+ assert pin_actions.pin_text(text, lambda repo, ref: (_ for _ in ()).throw(AssertionError)) == textdiff --git a/scripts/oss/tests/test_policies.py b/scripts/oss/tests/test_policies.pyindex c35ec7f16..471347206 100644--- a/scripts/oss/tests/test_policies.py+++ b/scripts/oss/tests/test_policies.py@@ -35,3 +35,19 @@ def test_untrusted_pr_review_forbids_running_pr_code_and_warns_about_github_difftext = read("docs/UNTRUSTED_PR_REVIEW.md")assert "--network none" in text and "Assets/Editor" in text and "Directory.Build.props" in textassert "Any diff under `.github/` can make every required check green" in text+++def test_contributing_names_every_ci_command_and_the_unity_gate():+ text = read("CONTRIBUTING.md")+ for cmd in ("dotnet test sim/Statecraft.sln",+ "uv run --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 --with pyyaml==6.0.3 "+ "--with pillow==12.3.0 --with requests==2.32.5 pytest tools/tests -q",+ "uv run --with pytest==9.1.1 --with pyyaml==6.0.3 --with requests==2.32.5 pytest scripts/oss/tests -q",+ "uv run scripts/oss/check_repo.py",+ "-buildTarget OSXUniversal -runTests -testPlatform EditMode", "## What CI runs", "CHANGELOG.md"):+ assert cmd in text, cmd+++def test_changelog_has_unreleased_on_top():+ text = read("CHANGELOG.md")+ assert text.index("## [Unreleased]") == text.index("## [")