Repository navigation
refactor(ci): extract run-fetching into reusable script with time-window filtering - #1302
Conversation
The hourly review bot was entering 2-minute sleep-poll loops waiting for still-running CI jobs to complete, wasting 14+ minutes of compute per occurrence. The prompt now explicitly instructs the bot to skip in-progress runs at both the discovery (Step 1) and download (Step 2) stages. Fixes #1301 Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
|
||
| Some runs may not have artifacts (e.g., skipped runs). That's fine — skip them. | ||
|
|
||
| **IMPORTANT: If a run is still in progress (empty conclusion), skip it entirely. Do NOT poll, sleep-wait, or retry — only analyze runs that have already completed. Waiting for in-progress runs wastes significant compute time.** |
There was a problem hiding this comment.
Agreed — removed this in c0d2dbb. The filtering is now consolidated in Step 1.
| ``` | ||
|
|
||
| If no Claude CI runs occurred in the past hour, report "no runs to review" and exit. | ||
| Filter out runs that are still in progress (empty `conclusion`) — only include completed runs. If no completed Claude CI runs occurred in the past hour, report "no runs to review" and exit. |
There was a problem hiding this comment.
when we collect runs to look at, are we filtering by their ending time.
this change is good, but conditional on that
There was a problem hiding this comment.
Good question — the answer is no. The --created flag filters by creation time, not completion time. So a run created 2+ hours ago that only recently finished would be missed by the 1-hour window.
gh run list doesn't offer an end-time filter — --created is the only date option. A workaround would be to widen the creation window (e.g., 4 hours) and then post-filter the JSON by updatedAt to only analyze runs that completed in the last hour. But that's a separate improvement from what this PR does.
This PR's change (skip in-progress runs) is still correct regardless — it prevents the sleep-polling waste. The creation-time vs end-time gap is a pre-existing issue. Want me to file a follow-up issue for the windowing improvement?
There was a problem hiding this comment.
let's do them both in this issue: pull anything that started in the past (3?) hours and then filter for whether it finished in the last hour; add comments explaining why + linking to this logic
There was a problem hiding this comment.
Done. Updated in c0d2dbb:
- Widened the
--createdwindow to 3 hours - Added
updatedAtto the JSON fields - Added two-step filtering: drop in-progress, then keep only runs whose
updatedAtis within the past hour - Added a "Why" paragraph explaining the start-time vs end-time gap, linking to hourly-review: sleep-polling still-running jobs wastes 14+ minutes of compute #1301
- Removed the duplicative "skip in-progress" instruction from Step 2 (addresses the other comment too)
`gh run list --created` filters by start time, not end time. A 1-hour creation window misses runs that started earlier but finished recently. - Fetch runs created in the past 3 hours (wide net) - Post-filter: drop in-progress runs, keep only those completed in the last hour - Add `updatedAt` to JSON fields for completion-time filtering - Remove duplicative "skip in-progress" instruction from Step 2 - Add explanatory comments linking to #1301 Co-Authored-By: Claude Opus 4.6 <[email protected]>
| Filter out runs that are still in progress (empty `conclusion`) — only include completed runs. If no completed Claude CI runs occurred in the past hour, report "no runs to review" and exit. | ||
| Then apply two filters: | ||
| 1. **Drop in-progress runs** — skip any run with an empty `conclusion`. | ||
| 2. **Keep only recently finished runs** — from the completed runs, only include those whose `updatedAt` timestamp is within the past hour. |
There was a problem hiding this comment.
is updatedAt the correct field?
can we just supply a script that does this filtering? then these changes can much terser
There was a problem hiding this comment.
updatedAt is the best available — gh run list doesn't expose a completedAt field. The available time fields are createdAt, startedAt, and updatedAt. For completed runs, updatedAt tracks completion closely (verified on recent runs — typically within a second of the check run's completedAt).
Good idea on the script. I'll extract the fetch + filter logic into a script (e.g., .github/scripts/list-recent-runs.sh) so the prompt just says "run the script" instead of explaining the filtering in prose.
There was a problem hiding this comment.
No — I said I would but didn't follow through. Let me do that now: extract the fetch + filter logic into a .github/scripts/list-recent-runs.sh script so the prompt can just reference the script instead of explaining the filtering inline.
There was a problem hiding this comment.
Please do this!
For the hourly reviewer — please work out what's going on, ty
There was a problem hiding this comment.
Done in 704e139. Extracted the fetch + filter logic into .github/scripts/list-recent-runs.sh — the prompt now just says "run the script" instead of explaining the filtering inline. The script has comments explaining the 3h window + 1h completion filter rationale.
Move the fetch + filter logic (3h creation window, drop in-progress, keep recently finished) from inline prompt prose into `.github/scripts/list-recent-runs.sh`. The workflow prompt now just references the script, making it much terser. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
|
||
| set -euo pipefail | ||
|
|
||
| WORKFLOWS=( |
There was a problem hiding this comment.
could we get all workflows and then filter by claude.*?
There was a problem hiding this comment.
Good idea — done in 0a48468. Replaced the hardcoded list with dynamic discovery via gh workflow list --json name --jq '.[].name | select(startswith("claude-"))'. No more maintenance when workflows are added or removed.
Replace hardcoded workflow list with `gh workflow list` filtered by the `claude-` prefix. This avoids needing to update the script when workflows are added or removed. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…ion (#4231) `.github/scripts/list-recent-runs.sh` has had no caller since March. It was extracted in #1302 to feed the `review-reviewers` skill ("Run `.github/scripts/list-recent-runs.sh` for recently completed Claude CI runs"), and #1676 moved that skill to the tend repo while replacing the hand-written Claude workflows with generated ones. The script survived the move; its only reference didn't. Nothing references it today — neither the repo (`git grep list-recent-runs` returns nothing outside the file itself) nor tend's bundled skills, which is where the calling skill now lives. The deletion empties `.github/scripts/`, so the directory goes with it. No test accompanies this: the change removes an unreferenced file and alters no behavior to regress. Co-authored-by: worktrunk-bot <[email protected]>
Summary
.github/scripts/list-recent-runs.shscriptclaude-*workflows instead of maintaining a hardcoded listupdatedAtis within the past hour (see hourly-review: sleep-polling still-running jobs wastes 14+ minutes of compute #1301 for why)Fixes #1301
Test plan
🤖 Generated with Claude Code