diff --git a/scripts/__tests__/test_pr_latency.py b/scripts/__tests__/test_pr_latency.py index 3c0f5403..99954ff8 100644 --- a/scripts/__tests__/test_pr_latency.py +++ b/scripts/__tests__/test_pr_latency.py @@ -56,6 +56,9 @@ def job(i, name, status="success", end=finish): job(21, "Self-hosted runner registration preflight", end=failed), { **job(22, "Unity 6000 all modes"), + "runner_name": "assigned", + "created_at": failed, + "started_at": "2026-01-02T10:05:00Z", "steps": [ {"name": "Set up job", "started_at": "2026-01-02T10:05:00Z"} ], @@ -90,6 +93,17 @@ def job(i, name, status="success", end=finish): (recovered,) = report.collect("owner/repo", 40) self.assertEqual(row, recovered) responses[f"{root}/actions/workflows/ci.yml/runs"] = [] + unity_jobs = responses[f"{root}/actions/runs/2/attempts/1/jobs"] + unity_jobs[0] = job(20, "Unity CI Success", None, None) + unity_jobs.append( + { + **job(23, "Unity 2021 all modes", None, None), + "runner_name": "", + "created_at": failed, + "started_at": failed, + "steps": None, + } + ) with patch.object( report, "pages", side_effect=lambda path, *a, **kw: iter(responses[path]) ): @@ -98,6 +112,9 @@ def job(i, name, status="success", end=finish): ("missing or ambiguous", None), (orphan["outcome"], orphan["seconds"]) ) self.assertEqual(240, row["native_jobs"][0]["preflight_to_setup_seconds"]) + self.assertEqual([240], row["queue_seconds"]) + self.assertEqual([240], orphan["queue_seconds"]) + self.assertIsNone(orphan["native_jobs"][1]["preflight_to_setup_seconds"]) self.assertTrue(row["retried"]) self.assertEqual( ("success", 420, 60), diff --git a/scripts/pr_latency.py b/scripts/pr_latency.py index 2f851941..560d7933 100644 --- a/scripts/pr_latency.py +++ b/scripts/pr_latency.py @@ -318,7 +318,8 @@ def branch_prs(origin, branch): instant(j["started_at"]) - instant(j["created_at"]) ).total_seconds() for j in native - if j.get("created_at") and j.get("started_at") + # GitHub can fill in started_at while a job still has no runner. + if j.get("runner_name") and j.get("created_at") and j.get("started_at") ], "native_jobs": native, }