Skip to content

Commit 3ea26ff

Browse files
committed
paginate the claim sweep instead of capping it
1 parent 680c59f commit 3ea26ff

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

‎.github/workflows/stale-claims.yml‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,32 @@ jobs:
3737
nudge_cutoff=$(( now - NUDGE_DAYS * 86400 ))
3838
free_cutoff=$(( now - FREE_DAYS * 86400 ))
3939
40-
limit=1000
41-
gh issue list --repo "$REPO" --state open --label claimed \
42-
--limit "$limit" --json number,updatedAt,assignees,labels > issues.json
40+
# Fully paginated: no cap, so no claim can age out of the sweep. The REST
41+
# issues endpoint also returns PRs, hence the pull_request filter. One JSON
42+
# object per line.
43+
gh api --paginate \
44+
"repos/$REPO/issues?state=open&labels=claimed&per_page=100" \
45+
--jq '.[]
46+
| select(.pull_request == null)
47+
| {number, updatedAt: .updated_at,
48+
assignees: [.assignees[].login],
49+
labels: [.labels[].name]}' > issues.jsonl
4350
4451
# Read into an array first. A `while read` over a pipe runs in a subshell,
4552
# which makes failures inside it easy to lose.
4653
rows=()
47-
while IFS= read -r line; do rows+=("$line"); done < <(jq -c '.[]' issues.json)
54+
while IFS= read -r line; do rows+=("$line"); done < issues.jsonl
4855
echo "claimed issues: ${#rows[@]:-0}"
4956
if [ "${#rows[@]:-0}" -eq 0 ]; then
5057
echo "nothing to sweep"
5158
exit 0
5259
fi
53-
# Never truncate quietly. If we ever hit the cap, the oldest claims are the
54-
# ones dropped, and those are exactly the ones this job exists to catch.
55-
if [ "${#rows[@]}" -ge "$limit" ]; then
56-
echo "::warning::Hit the $limit issue cap. Older claims were not swept; paginate this query."
57-
fi
5860
5961
for row in "${rows[@]}"; do
6062
number=$(jq -r '.number' <<<"$row")
6163
updated=$(date -u -d "$(jq -r '.updatedAt' <<<"$row")" +%s)
62-
assignees=$(jq -r '[.assignees[].login] | join(" ")' <<<"$row")
63-
is_stale=$(jq -r '[.labels[].name] | index("stale") != null' <<<"$row")
64+
assignees=$(jq -r '.assignees | join(" ")' <<<"$row")
65+
is_stale=$(jq -r '.labels | index("stale") != null' <<<"$row")
6466
6567
if [ -z "$assignees" ]; then
6668
echo "#$number: claimed but unassigned, skipping"

0 commit comments

Comments
 (0)