diff --git a/docs/progress_dashboard.md b/docs/progress_dashboard.md index c5e7f48a42..b36e938c81 100644 --- a/docs/progress_dashboard.md +++ b/docs/progress_dashboard.md @@ -27,12 +27,12 @@ are read directly; there is no need to re-save them as UTF-8. | Translator contract | the contract table in [design.md](design.md#translator-status-and-runtime-contract), each row classified by how it says it was confirmed | contract row | | Runtime imports | the measured tables in [runtime_imports.md](runtime_imports.md) | import | | Shader corpus | `--work `: counts per stage from `/shaders/dxbc/index.json` and `/shaders/spirv/index.json` | shaders, aggregated per stage | -| Pull requests into main | `--github`: every pull request into `main` of the main repository (`--repo`, default `ItsNotRexed/Leonida`), grouped by the item ID its title names (`D3D-86: …`, `… (SHADER-339)`) | pull request | -| D3D12 layer | `--github`: the `D3D-` table of [#313](https://github.com/ItsNotRexed/Leonida/issues/313), read through `gh` and checked against the merged and open pull requests | item | +| Pull requests into main | `--github`: every pull request into `main` of the main repository (`--repo`, default `ubiquitarianism/leonida`), grouped by the item ID its title names (`D3D-86: …`, `… (SHADER-339)`) | pull request | +| D3D12 layer | `--github`: the `D3D-` table of the D3D12 tracking issue, read through `gh` and checked against the merged and open pull requests. The issue is the open one whose title starts with "D3D12 → Vulkan layer", or the one `--d3d-issue N` names; when the repository has neither, the sources list says so and the panel stays empty (the number is not fixed: it was #313 in the original repository) | item | | CI on main | `--github`: the latest completed run of each workflow on `main` | workflow | Every run with `--github` reads the pull requests again, so a merge into `main` shows up on the next run as -IMPLEMENTED, even before a tracking table (such as #313's PR column) is edited. A pull request closed without merging is +IMPLEMENTED, even before a tracking table (such as the D3D12 tracking issue's PR column) is edited. A pull request closed without merging is left out. The page also lists the 30 latest merges, and the trend chart follows the share of pull requests merged and of item IDs with a merged pull request. `gh pr list` reads at most 5000 per state; the Sources table says when that limit is reached. diff --git a/make_game.py b/make_game.py index ff5ff76767..877eae4642 100644 --- a/make_game.py +++ b/make_game.py @@ -1037,7 +1037,7 @@ def ensure_submodule() -> None: core = os.path.join(ROOT, "third_party", "rpf9-explorer", "Core") if submodule_ready(): return - clone = "git clone --recursive https://github.com/ItsNotRexed/Leonida" + clone = "git clone --recursive https://github.com/ubiquitarianism/leonida" git = shutil.which("git") if not git: fail("third_party/rpf9-explorer is missing (a \"Download ZIP\" from GitHub leaves it out). Install Git " diff --git a/tests/test_make_game_preflight.py b/tests/test_make_game_preflight.py index 7f4f3c7748..9ea5f79ab5 100644 --- a/tests/test_make_game_preflight.py +++ b/tests/test_make_game_preflight.py @@ -651,7 +651,7 @@ def test_ensure_submodule_missing_fails_cleanly(self): with mock.patch.object(make_game, "ROOT", tmp), \ mock.patch("shutil.which", return_value=None): self.assert_fails(make_game.ensure_submodule, - match="git clone --recursive https://github.com/ItsNotRexed/Leonida") + match="git clone --recursive https://github.com/ubiquitarianism/leonida") def test_ensure_submodule_zip_with_git_does_not_say_install_git(self): with tempfile.TemporaryDirectory() as tmp: @@ -660,9 +660,21 @@ def test_ensure_submodule_zip_with_git_does_not_say_install_git(self): mock.patch("shutil.which", return_value="/usr/bin/git"), \ mock.patch("subprocess.run", return_value=not_a_repo): err = self.assert_fails(make_game.ensure_submodule, - match="git clone --recursive https://github.com/ItsNotRexed/Leonida") + match="git clone --recursive https://github.com/ubiquitarianism/leonida") self.assertNotIn("Install Git", err) + def test_ensure_submodule_names_the_clone_command_the_readme_gives(self): + # the hint once named a repository that had gone private; the README is where the address is kept current + with open(os.path.join(ROOT, "README.md"), encoding="utf-8") as f: + readme = f.read() + with tempfile.TemporaryDirectory() as tmp: + with mock.patch.object(make_game, "ROOT", tmp), \ + mock.patch("shutil.which", return_value=None): + err = self.assert_fails(make_game.ensure_submodule, match="git clone --recursive ") + clone = re.search(r"git clone --recursive https://github\.com/[\w.-]+/[\w.-]+", err) + self.assertIsNotNone(clone, err) + self.assertIn(f"`{clone.group(0)}`", readme) + def test_ensure_submodule_failed_fetch_in_clone_names_the_fetch(self): with tempfile.TemporaryDirectory() as tmp: results = [subprocess.CompletedProcess([], 0), subprocess.CompletedProcess([], 1)] diff --git a/tests/test_progress_dashboard.py b/tests/test_progress_dashboard.py index 522d9d5660..ad22e81499 100644 --- a/tests/test_progress_dashboard.py +++ b/tests/test_progress_dashboard.py @@ -304,6 +304,11 @@ def test_panel_groups_by_gpu_label(self): class Github(unittest.TestCase): + def test_default_repo_is_the_one_the_readme_clones(self): + # --github once read a repository that had gone private; the README is where the address is kept current + with open(os.path.join(ROOT, "README.md"), encoding="utf-8") as f: + self.assertIn(f"`git clone --recursive https://github.com/{pd.DEFAULT_REPO}`", f.read()) + def test_d3d_states(self): self.assertEqual(pd.d3d_state("@a", "#291 merged, #819, #831 on main", "")[0], "partial") self.assertEqual(pd.d3d_state("@a", "#1489 merged, #907 closed", "")[0], "implemented") @@ -339,6 +344,8 @@ def fake_gh(args, timeout=60): return merged if "merged" in args else open_prs if args[:2] == ["issue", "view"]: return {"body": body, "updatedAt": "2026-11-22T00:00:00Z"} + if args[:2] == ["issue", "list"] and "D3D12" in args[args.index("--search") + 1]: + return [{"number": 313, "title": "D3D12 → Vulkan layer: critical path, who builds what"}] return [] col = pd.Collector() with mock.patch.object(pd, "gh_json", fake_gh), mock.patch.object(pd.shutil, "which", lambda _: "/usr/bin/gh"): @@ -353,12 +360,84 @@ def fake_gh(args, timeout=60): return merged if "merged" in args else open_prs if args[:2] == ["issue", "view"]: return {"body": body, "updatedAt": "2026-11-22T00:00:00Z"} + if args[:2] == ["issue", "list"] and "D3D12" in args[args.index("--search") + 1]: + return [{"number": 313, "title": "D3D12 → Vulkan layer: critical path, who builds what"}] return [] col = pd.Collector() with mock.patch.object(pd, "gh_json", fake_gh), mock.patch.object(pd.shutil, "which", lambda _: "/usr/bin/gh"): pd.collect_github(col, "o/r", "me") return next(m for m in col.metrics if m["id"] == "d3d12.merged") + D3D_BODY = ("| ID | Title | Owner | PR | Status |\n|---|---|---|---|---|\n" + "| D3D-4 | b | @b | #60 merged | merged |\n| D3D-5 | c | @c | #61 | PR open |\n") + + def run_d3d_lookup(self, issues, d3d_issue=None, readable=True): + """collect_github() with these open issues answering the D3D12 title search: the collector, the summary and + every gh call made.""" + calls = [] + + def fake_gh(args, timeout=60): + calls.append(args) + if args[:2] == ["issue", "view"]: + return {"body": self.D3D_BODY, "updatedAt": "2026-11-22T00:00:00Z"} if readable else None + if args[:2] == ["issue", "list"] and "D3D12" in args[args.index("--search") + 1]: + return issues + return [] + col = pd.Collector() + with mock.patch.object(pd, "gh_json", fake_gh), mock.patch.object(pd.shutil, "which", lambda _: "/usr/bin/gh"): + summary = pd.collect_github(col, "o/r", None, d3d_issue) + return col, summary, calls + + @staticmethod + def viewed(calls): + return [a[2] for a in calls if a[:2] == ["issue", "view"]] + + def test_d3d_issue_is_found_by_title_not_by_a_fixed_number(self): + # #313 was the tracking issue in the repository the project started in; here that number is something else + col, summary, calls = self.run_d3d_lookup([ + {"number": 12, "title": "d3d12_vulkan_device: a crash in the Vulkan layer"}, + {"number": 90, "title": "D3D12 -> Vulkan layer: critical path (continues the one below)"}, + {"number": 41, "title": "D3D12 → Vulkan layer: critical path, who builds what, open methods"}, + ]) + self.assertEqual(self.viewed(calls), ["41"]) # the oldest issue with the title; never "313" + self.assertEqual(summary["d3d_issue"], 41) + self.assertEqual(col.panels["d3d12"]["title"], "D3D12 → Vulkan layer items (#41)") + source = next(s for s in col.sources if s["id"] == "github_d3d12") + self.assertEqual((source["status"], source["records"]), ("ok", 2)) + self.assertTrue(any(m["id"] == "d3d12.merged" for m in col.metrics)) + + def test_no_d3d_issue_is_reported_and_no_other_issue_is_read(self): + for issues in ([], None, [{"number": 313, "title": "tests: an unrelated pull request"}]): + with self.subTest(issues=issues): + col, summary, calls = self.run_d3d_lookup(issues) + self.assertEqual(self.viewed(calls), []) + self.assertNotIn("d3d_issue", summary) + source = next(s for s in col.sources if s["id"] == "github_d3d12") + self.assertEqual(source["status"], "missing") + self.assertIn("--d3d-issue", source["note"]) + self.assertEqual(col.panels["d3d12"]["title"], "D3D12 → Vulkan layer items") + self.assertFalse(any(m["id"] == "d3d12.merged" for m in col.metrics)) + + def test_d3d_issue_option_names_the_issue(self): + col, summary, calls = self.run_d3d_lookup([{"number": 41, "title": "D3D12 → Vulkan layer: x"}], d3d_issue=7) + self.assertEqual(self.viewed(calls), ["7"]) + self.assertFalse(any(a[:2] == ["issue", "list"] and "D3D12" in a[a.index("--search") + 1] for a in calls)) + self.assertEqual(summary["d3d_issue"], 7) + + def test_unreadable_d3d_issue_is_reported(self): + col, _, _ = self.run_d3d_lookup([], d3d_issue=7, readable=False) + source = next(s for s in col.sources if s["id"] == "github_d3d12") + self.assertEqual(source["status"], "invalid") + self.assertIn("#7", source["note"]) + + def test_d3d_issue_option_is_checked(self): + for argv in (["--out", "x", "--d3d-issue", "7"], ["--out", "x", "--github", "--d3d-issue", "0"]): + with self.subTest(argv=argv), contextlib.redirect_stderr(io.StringIO()) as err: + with self.assertRaises(SystemExit) as stop: + pd.main(argv) + self.assertEqual(stop.exception.code, 2) + self.assertIn("--d3d-issue", err.getvalue()) + @staticmethod def prs(*pairs): return [{"number": n, "title": t, "isDraft": False, "mergedAt": "2026-11-22T10:00:00Z", "author": {"login": "x"}} diff --git a/tools/progress_dashboard.py b/tools/progress_dashboard.py index 0a9636dc51..9e9d0eb28b 100644 --- a/tools/progress_dashboard.py +++ b/tools/progress_dashboard.py @@ -19,7 +19,7 @@ imports the measured import tables in docs/runtime_imports.md corpus --work: counts per stage from /shaders/dxbc/index.json and /shaders/spirv/index.json github --github, read-only through `gh`: every pull request into main (merged = implemented, open = - partial), latest CI runs on main, the D3D- table of #313 checked against those merges, the + partial), latest CI runs on main, the D3D- table of the D3D12 tracking issue checked against those merges, the coordination issue's section sizes and, with --login, that account's claims and pull requests No game data leaves the inputs: the page and the JSON carry counts, pass/fail, error classes and the project's @@ -51,7 +51,7 @@ SCHEMA = "leonida.progress/1" STATUSES = ("verified", "implemented", "partial", "failed", "missing", "blocked", "unknown") PYTEST_MARKERS = re.compile(r"^import pytest|^ *HAVE_NUMPY =", re.M) # the CI selection rule (ci.yml) -DEFAULT_REPO = "ItsNotRexed/Leonida" +DEFAULT_REPO = "ubiquitarianism/leonida" # ----------------------------------------------------------------------------------------------- helpers @@ -831,8 +831,25 @@ def collect_pulls(col, repo, merged, open_prs, limit=PR_LIMIT): "items": item_ids(p.get("title")), "author": (p.get("author") or {}).get("login")} for p in latest] -def collect_github(col, repo, login): - col.panel("d3d12", "D3D12 → Vulkan layer items (#313)", "D3D- items") +D3D_ISSUE_TITLE = "D3D12 → Vulkan layer" + + +def find_d3d_issue(repo): + """Number of the open issue that tracks the D3D12 → Vulkan layer in this repository, or None. + + It is looked up by title, like the coordination issue: a fixed number only holds for one repository (it was + #313 where the project started), and in another one the same number is some unrelated issue or pull request.""" + found = gh_json(["issue", "list", "-R", repo, "--state", "open", "--search", "D3D12 Vulkan layer in:title", + "--json", "number,title"]) or [] + want = re.sub(r"\W+", " ", D3D_ISSUE_TITLE).lower().split() + for issue in sorted(found, key=lambda i: i["number"]): + if re.sub(r"\W+", " ", issue.get("title") or "").lower().split()[:len(want)] == want: + return issue["number"] + return None + + +def collect_github(col, repo, login, d3d_issue=None): + col.panel("d3d12", "D3D12 → Vulkan layer items", "D3D- items") col.panel("ci", "CI on main", "workflows") if not shutil.which("gh"): col.source("github", None, "missing", note="gh is not installed") @@ -871,7 +888,17 @@ def collect_github(col, repo, login): detail=f"{what} on {r['headSha'][:10]}" + (f"; a newer run is {newer['status']}" if newer and newer is not r else ""), at=r["createdAt"], url=r.get("url")) col.source("github_ci", None, "ok", len(latest)) - issue = gh_json(["issue", "view", "313", "-R", repo, "--json", "body,updatedAt"]) + d3d_number = d3d_issue or find_d3d_issue(repo) + issue = None + if d3d_number is None: + col.source("github_d3d12", None, "missing", + note=f'no open issue titled "{D3D_ISSUE_TITLE} ..." in {repo}: pass --d3d-issue N to name one') + else: + col.panel("d3d12", f"D3D12 → Vulkan layer items (#{d3d_number})", "D3D- items") + summary["d3d_issue"] = d3d_number + issue = gh_json(["issue", "view", str(d3d_number), "-R", repo, "--json", "body,updatedAt"]) + if not issue: + col.source("github_d3d12", None, "invalid", note=f"issue #{d3d_number} could not be read") if issue: n = 0 table_ids, table_done = set(), set() @@ -890,19 +917,19 @@ def collect_github(col, repo, login): n += 1 col.add(f"d3d.{plain(row[0])}", "d3d12", why, f"{plain(row[0])} {plain(row[1])}"[:120], status, detail=(st or why)[:200], owner=owner, prs=pr[:120]) - col.source("github_313", None, "ok", n, note=f"issue updated {issue.get('updatedAt')}") + col.source("github_d3d12", None, "ok", n, note=f"issue #{d3d_number}, updated {issue.get('updatedAt')}") if n: # the table lists only items still in progress; a merged item leaves it, so the merges are counted where they are recorded lists_read = merged_set is not None merged_ids = d3d_item_ids(merged) if lists_read else set() open_ids = d3d_item_ids(open_prs) if lists_read else set() - pr_done = (merged_ids - table_ids) - open_ids # rows in #313 keep the table's state; the rest need a merged PR and no open one + pr_done = (merged_ids - table_ids) - open_ids # rows in the issue keep the table's state; the rest need a merged PR and no open one col.metric("d3d12.merged", "d3d12", "D3D- items merged on main" + ("" if lists_read else " (partial)"), len(table_done | pr_done), len(table_ids | merged_ids | open_ids), - "#313 rows whose state is implemented (d3d_state), plus D3D- IDs not in #313 that a merged PR title names " - "and no open PR title names / all known D3D- IDs (#313 rows plus IDs named by any merged or open PR title)", + "tracking-issue rows whose state is implemented (d3d_state), plus D3D- IDs not in it that a merged PR title names " + "and no open PR title names / all known D3D- IDs (its rows plus IDs named by any merged or open PR title)", note=None if lists_read else "partial: the merged or open PR list could not be read, " - "so only the #313 rows are counted") + "so only the tracking issue's rows are counted") coord = gh_json(["issue", "list", "-R", repo, "--state", "open", "--search", "Coordinating who works on what in:title", "--json", "number,title,updatedAt"]) if coord: @@ -953,9 +980,10 @@ def build(args, out_dir): collect_contract(col) collect_imports(col) collect_corpus(col, args.work) - gh = collect_github(col, args.repo, args.login) if args.github else {} + gh = collect_github(col, args.repo, args.login, args.d3d_issue) if args.github else {} if not args.github: - col.source("github", None, "skipped", note="pass --github to read pull requests into main, CI, #313 and the coordination issue") + col.source("github", None, "skipped", note="pass --github to read pull requests into main, CI, the D3D12 tracking issue and the " + "coordination issue") snap = { "schema": SCHEMA, "generated_at": iso(now_utc()), "git": g, "panels": [col.panels[k] for k in ("tests", "runtime", "gpu", "contract", "imports", "corpus", "merged", "d3d12", "ci") if k in col.panels], @@ -1016,12 +1044,20 @@ def main(argv=None): ap.add_argument("--junit", nargs="*", metavar="FILE", help="additional independent CTest or pytest JUnit reports") ap.add_argument("--gpu-log", nargs="*", metavar="FILE[=LABEL]", help="saved output of runtime/test/shaders/check.py; LABEL names the GPU, driver and OS") - ap.add_argument("--github", action="store_true", help="read pull requests into main, CI runs, #313 and the coordination issue through gh") + ap.add_argument("--github", action="store_true", help="read pull requests into main, CI runs, the D3D12 tracking issue and the coordination issue " + "through gh") ap.add_argument("--repo", default=DEFAULT_REPO, help=f"GitHub repository (default {DEFAULT_REPO})") + ap.add_argument("--d3d-issue", type=int, metavar="N", + help=f'with --github, the issue holding the D3D- table (default: the open issue titled ' + f'"{D3D_ISSUE_TITLE} ...")') ap.add_argument("--login", help="with --github, show this account's claims and pull requests") args = ap.parse_args(argv) if args.login is not None and not args.github: ap.error("--login requires --github") + if args.d3d_issue is not None and not args.github: + ap.error("--d3d-issue requires --github") + if args.d3d_issue is not None and args.d3d_issue < 1: + ap.error("--d3d-issue must be a positive integer") if args.jobs < 1: ap.error("--jobs must be a positive integer") if args.test_timeout < 1: