From aabb11882708626a2e56ec9c7790490b91b995dc Mon Sep 17 00:00:00 2001 From: Yun Wang Date: Fri, 27 Nov 2026 17:40:42 +0100 Subject: [PATCH 1/2] ci: merge a regen PR that fell behind its base during the merge wait The default branch requires an up-to-date PR, so a PR merged during the 45-minute wait left the regen PR unmergeable until the wait ran out. The wait now takes in the base, as the start of a run already does for a labelled PR, and keeps waiting on the new head. --- .github/workflows/regen.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/regen.yml b/.github/workflows/regen.yml index 2d196144..237e02b7 100644 --- a/.github/workflows/regen.yml +++ b/.github/workflows/regen.yml @@ -99,6 +99,15 @@ jobs: --jq '.data.repository.pullRequest | [(.editor.__typename // "Bot"), (.timelineItems.nodes[].actor.__typename)] | any(. != "Bot")') || { echo "::error::could not read who edited #$num"; exit 1; } [ "$t" = true ] } + # Takes in $base with a merge, as the up-to-date rule requires, and moves $head to the new tip, whose checks start over. + catchup() { + gh pr update-branch "$num" || { human "does not take in $base cleanly, so a human takes it from here"; exit 0; } + moved=$head + for _ in $(seq 30); do sleep 5; moved=$(gh pr view "$num" --json headRefOid --jq .headRefOid); [ "$moved" != "$head" ] && break; done + [ "$moved" != "$head" ] || { echo "::error::#$num did not move after taking in $base"; exit 1; } + head=$moved + echo "ping=true" >> "$GITHUB_OUTPUT" + } # Merges the open regen PR at commit $1 as the App once its required checks and the Regen integration run on that commit pass. Auto-merge waits for a code owner review although the App may bypass it, and gh refuses a blocked PR without --admin, which skips only what the App may bypass. GitHub refuses the merge while a required check has not reported yet, so a refusal only means try again. land() { body=$(gh pr view "$num" --json body --jq .body) @@ -109,6 +118,9 @@ jobs: fi for _ in $(seq 45); do sleep 60 + # A PR merged into $base during the wait leaves this one behind, and the up-to-date rule refuses the merge until it takes that in. + behind=$(gh api "repos/$GITHUB_REPOSITORY/compare/$base...$branch" --jq .behind_by) || behind=0 + if [ "$behind" != 0 ]; then head=$1; catchup; set -- "$head"; continue; fi checks=$(GH_TOKEN=$CHECKS_TOKEN gh pr checks "$num" --required --json bucket --jq '[.[].bucket] | unique | join(",")' 2>&1) || true case $checks in *"checks reported"*|*pending*) ;; @@ -155,14 +167,7 @@ jobs: behind=$(gh api "repos/$GITHUB_REPOSITORY/compare/$base...$branch" --jq .behind_by) # Regenerating would drop the tickets a human named in the body, so a labelled PR that fell behind takes in the base with a merge, as the up-to-date rule requires. if jq -e 'any(.labels[]; .name == "sdk-not-breaking")' <<< "$pr" > /dev/null; then - if [ "$behind" != 0 ]; then - gh pr update-branch "$num" || { human "does not take in $base cleanly, so a human takes it from here"; exit 0; } - moved=$head - for _ in $(seq 30); do sleep 5; moved=$(gh pr view "$num" --json headRefOid --jq .headRefOid); [ "$moved" != "$head" ] && break; done - [ "$moved" != "$head" ] || { echo "::error::#$num did not move after taking in $base"; exit 1; } - head=$moved - echo "ping=true" >> "$GITHUB_OUTPUT" - fi + if [ "$behind" != 0 ]; then catchup; fi land "$head" fi open=$(grep -o 'openapi-v[0-9.]*[0-9]' <<< "$title" || true) From 8c7db079aa6e18fa7d0ee7ea4c5448de103a7815 Mon Sep 17 00:00:00 2001 From: Yun Wang Date: Fri, 27 Nov 2026 18:39:28 +0100 Subject: [PATCH 2/2] ci: leave a regen PR that took in its base to the run its integration starts Its checks start over on the new head, so waiting out the rest of this run's 45 minutes often ended in a human ping. The run that the new head's Regen integration starts on completion merges it, with a full wait of its own. --- .github/workflows/regen.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/regen.yml b/.github/workflows/regen.yml index 237e02b7..7d9ddaab 100644 --- a/.github/workflows/regen.yml +++ b/.github/workflows/regen.yml @@ -118,9 +118,9 @@ jobs: fi for _ in $(seq 45); do sleep 60 - # A PR merged into $base during the wait leaves this one behind, and the up-to-date rule refuses the merge until it takes that in. + # A PR merged into $base during the wait leaves this one behind, and the up-to-date rule refuses the merge until it takes that in. The new head's checks start over, so the run its Regen integration starts on completion merges it, with a full wait of its own. behind=$(gh api "repos/$GITHUB_REPOSITORY/compare/$base...$branch" --jq .behind_by) || behind=0 - if [ "$behind" != 0 ]; then head=$1; catchup; set -- "$head"; continue; fi + if [ "$behind" != 0 ]; then head=$1; catchup; echo "::notice::#$num took in $base, and the run its Regen integration starts merges it"; exit 0; fi checks=$(GH_TOKEN=$CHECKS_TOKEN gh pr checks "$num" --required --json bucket --jq '[.[].bucket] | unique | join(",")' 2>&1) || true case $checks in *"checks reported"*|*pending*) ;;