Fetch runs for a workflow in the window via `/actions/workflows/{id}/runs`. Returns [] for reusable (workflow_call) workflows — the API only surfaces them under the caller. Use `fetch_reusable_runs` for those.
(workflow: str, since: dt.datetime)
| 148 | |
| 149 | |
| 150 | def fetch_runs(workflow: str, since: dt.datetime) -> list[RunSummary]: |
| 151 | """Fetch runs for a workflow in the window via `/actions/workflows/{id}/runs`. |
| 152 | |
| 153 | Returns [] for reusable (workflow_call) workflows — the API only surfaces |
| 154 | them under the caller. Use `fetch_reusable_runs` for those. |
| 155 | """ |
| 156 | runs: list[RunSummary] = [] |
| 157 | page = 1 |
| 158 | cutoff = since.date().isoformat() |
| 159 | while True: |
| 160 | path = ( |
| 161 | f"/repos/{REPO}/actions/workflows/{workflow}/runs" |
| 162 | f"?created=%3E%3D{cutoff}&per_page=100&page={page}" |
| 163 | ) |
| 164 | payload = gh_api(path) |
| 165 | assert isinstance(payload, dict), f"unexpected payload: {type(payload)}" |
| 166 | batch = payload.get("workflow_runs") or [] |
| 167 | if not batch: |
| 168 | break |
| 169 | for raw in batch: |
| 170 | run = _run_from_raw(raw) |
| 171 | if run is None or run.created_at < since: |
| 172 | continue |
| 173 | runs.append(run) |
| 174 | if len(batch) < 100: |
| 175 | break |
| 176 | page += 1 |
| 177 | if page > 50: # safety valve: 5000 runs is plenty for 30 days |
| 178 | break |
| 179 | return runs |
| 180 | |
| 181 | |
| 182 | def fetch_all_repo_runs(since: dt.datetime) -> list[dict]: |
no test coverage detected