Attribute a reusable workflow via `referenced_workflows` on caller runs. Wall/queue times come from the caller run, so they are caller-inclusive — a caller that inlines other jobs alongside the reusable workflow will overstate the reusable piece. Annotated in the rendered output.
(workflow: str, all_repo_runs: list[dict])
| 212 | |
| 213 | |
| 214 | def fetch_reusable_runs(workflow: str, all_repo_runs: list[dict]) -> list[RunSummary]: |
| 215 | """Attribute a reusable workflow via `referenced_workflows` on caller runs. |
| 216 | |
| 217 | Wall/queue times come from the caller run, so they are caller-inclusive — |
| 218 | a caller that inlines other jobs alongside the reusable workflow will |
| 219 | overstate the reusable piece. Annotated in the rendered output. |
| 220 | """ |
| 221 | suffix = f".github/workflows/{workflow}" |
| 222 | runs: list[RunSummary] = [] |
| 223 | for raw in all_repo_runs: |
| 224 | refs = raw.get("referenced_workflows") or [] |
| 225 | # GitHub returns paths like "org/repo/.github/workflows/foo.yml@<sha>" |
| 226 | # — strip the `@ref` suffix before matching. |
| 227 | if not any(r.get("path", "").split("@", 1)[0].endswith(suffix) for r in refs): |
| 228 | continue |
| 229 | run = _run_from_raw(raw) |
| 230 | if run is None: |
| 231 | continue |
| 232 | runs.append(run) |
| 233 | return runs |
| 234 | |
| 235 | |
| 236 | def _percentile(values: Iterable[float], p: float) -> float | None: |
no test coverage detected