From 2d8cc5104a899d3f36f3ca9eedd8522b4d90b33a Mon Sep 17 00:00:00 2001 From: Yun Wang Date: Thu, 3 Dec 2026 16:41:21 +0100 Subject: [PATCH 1/6] ci: calmer regen alerts that name breaking tickets, three integration attempts --- .github/workflows/regen.yml | 34 +++++++++++++++++++++++++++------- CONTRIBUTING.md | 2 +- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/workflows/regen.yml b/.github/workflows/regen.yml index 12cb814e..4b2a057d 100644 --- a/.github/workflows/regen.yml +++ b/.github/workflows/regen.yml @@ -11,7 +11,7 @@ on: tag: description: Protocol release, e.g. openapi-v240.4.0. Empty takes the latest. required: false - # Each finished integration attempt is handled right away: a pass merges the PR, a first red one is rerun even after the run that pushed has given up waiting, and a red rerun reaches a human. + # Each finished integration attempt is handled right away: a pass merges the PR, a red one is rerun up to three attempts even after the run that pushed has given up waiting, and a third red attempt reaches a human. workflow_run: workflows: [Regen integration] types: [completed] @@ -95,9 +95,29 @@ jobs: # Leaves a major to a human, who merges it in a breaking-change window, and disarms any auto-merge so an approval alone cannot merge it. hold() { gh pr merge "$num" --disable-auto 2>/dev/null || true - if [ "${2:-}" = quiet ]; then echo "::notice::#$num $1, so a human merges it"; else human "$1, so a human merges it"; fi + if [ "${2:-}" = quiet ]; then echo "::notice::#$num $1, so a human merges it"; else human "$1"; fi exit 0 } + # The approved breaking-change tickets the spec at commit $1 brings over the spec on $base. + new_tickets() { + local ref tag + for ref in "$base" "$1"; do + tag=$(gh api "repos/$GITHUB_REPOSITORY/contents/.spec-version?ref=$ref" -H 'Accept: application/vnd.github.raw' | sed -n 's/^spec: //p') && [ -n "$tag" ] || return 1 + curl -fsSL "https://raw.githubusercontent.com/GetStream/protocol/$tag/openapi/v2/serverside-api.yaml" | yq -r '(.info."x-stream-breaking-changes" // {}) | .[] | .[]' | sort -u > "$RUNNER_TEMP/tickets-$ref" || return 1 + done + comm -13 "$RUNNER_TEMP/tickets-$base" "$RUNNER_TEMP/tickets-$1" + } + # What a human judges in a breaking regen at commit $1: the tickets behind it, or that none explains it. + held() { + local t list n + t=$(new_tickets "$1") || { echo "is held as breaking. See the PR body and the Breaking changes check"; return; } + [ -n "$t" ] || { echo "is held as breaking, but no approved ticket explains it. See the PR body and the Breaking changes check"; return; } + list=$(head -3 <<< "$t" | while read -r id date; do printf ', ' "$id" "$id" "$date"; done) + list=${list%, } + n=$(wc -l <<< "$t") + if [ "$n" -gt 3 ]; then list="$list and $((n - 3)) more"; fi + echo "is held as breaking: $list. Label sdk-not-breaking if no customer can hit them, otherwise hold for the next window" + } # Whether a human took the open `!` PR: a `!` the regen wrote moves on with each newer tag, and a human takes the PR by renaming it or editing its body. A read error stops the run rather than overwrite their edit. took() { [[ $(gh pr view "$num" --json title --jq .title) =~ $bang ]] || return 1 @@ -120,7 +140,7 @@ jobs: # Posted when this run changed the PR's breaking changes ($prev is the body it replaced), not on every run that finds them unchanged. if grep -q '^BREAKING CHANGE: ' <<< "$body"; then if [ "$(grep '^BREAKING CHANGE: ' <<< "$body")" = "$(grep '^BREAKING CHANGE: ' <<< "${prev-$body}" || true)" ]; then hold "carries breaking changes" quiet; fi - hold "carries breaking changes" + hold "$(held "$1")" fi for _ in $(seq 45); do sleep 60 @@ -138,10 +158,10 @@ jobs: conclusion=${state#completed/} case $state in completed/success) ;; - # The shared app and the repo-wide run-integration concurrency group, which drops a queued run, make a first red or cancelled run often not the regen's fault. The workflow_run trigger merges once the rerun passes. + # The shared app and the repo-wide run-integration concurrency group, which drops a queued run, make a red or cancelled run often not the regen's fault, so up to three attempts run before a human is asked. The workflow_run trigger merges once a rerun passes. completed/*) - if [ "$attempt" = 1 ] && GH_TOKEN=$CHECKS_TOKEN gh run rerun "$id"; then echo "::notice::#$num reran its integration tests after a $conclusion, and a pass merges it"; exit 0; fi - human "has integration tests that ended in $conclusion on attempt $attempt, so a human takes it from here" + if [ "$attempt" -lt 3 ] && GH_TOKEN=$CHECKS_TOKEN gh run rerun "$id"; then echo "::notice::#$num reran its integration tests after a $conclusion on attempt $attempt, and a pass merges it"; exit 0; fi + human "is waiting: integration tests failed $attempt times. SDK bot needs a human to check" if [ "$GITHUB_EVENT_NAME" = workflow_run ]; then echo "ping=true" >> "$GITHUB_OUTPUT"; fi exit 0 ;; ''|queued/|in_progress/|waiting/|pending/|requested/) continue ;; @@ -285,4 +305,4 @@ jobs: if [ -z "$SLACK_WEBHOOK_URL" ]; then echo "SLACK_WEBHOOK_URL is not set, so nothing is posted"; exit 0; fi mention= if [ "$PING" = true ] || [ -z "$NOTE" ]; then mention=' '; fi - jq -n --arg text "${mention}:warning: stream-sdk-java auto-regen ${NOTE:-failed}. <$RUN|Details>" '{text: $text}' | curl -fsS -X POST -H 'Content-Type: application/json' --data @- "$SLACK_WEBHOOK_URL" + jq -n --arg text "${mention}stream-sdk-java regen ${NOTE:-failed}. <$RUN|Details>" '{text: $text}' | curl -fsS -X POST -H 'Content-Type: application/json' --data @- "$SLACK_WEBHOOK_URL" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d3fbe497..9f0cd526 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -140,7 +140,7 @@ A regen PR waits for a human when its changelog carries a `BREAKING CHANGE:` foo - **Regenerate now:** run **Regenerate** from the Actions tab with an `openapi-vX` tag, or leave it empty for the latest. Locally, `SPEC_TAG=openapi-vX ./generate.sh` does the same with the generator built from a `../chat` checkout at that tag. - **A breaking change that breaks this SDK:** when the regen titled the PR `feat!:`, review its footers. It moves on to each newer spec until you rename the PR or edit its body, which keeps it on the spec you judged. Otherwise add `!` to the PR title, and before `END_COMMIT_OVERRIDE` add a blank line and `BREAKING CHANGE: `. Then merge it yourself in a breaking-change window, with a `MIGRATION_vX_to_vY.md` guide. - **An approved breaking change that does not break this SDK:** label the PR `sdk-not-breaking` and name each ticket the check lists in the PR body. When the regen titled it `feat!:`, also drop the `!` and delete the entries that carry a `BREAKING CHANGE:` footer. The next Regenerate run merges it, daily at 06:23 UTC or when you start one. -- **Failed integration tests:** the tests share their Stream app with other SDKs' CI, so the Regenerate run reruns a red or cancelled **Regen integration** run once by itself, and merges the PR when the rerun passes. If the rerun is red too, fix the cause or rerun it again; a pass merges the PR. If no run started for the PR's head commit, start **Regen integration** on `regen/auto` from the Actions tab. +- **Failed integration tests:** the tests share their Stream app with other SDKs' CI, so the Regenerate run reruns a red or cancelled **Regen integration** run by itself for up to three attempts, and merges the PR when one passes. If the third attempt is red too, it pings the group: fix the cause or rerun it again; a pass merges the PR. If no run started for the PR's head commit, start **Regen integration** on `regen/auto` from the Actions tab. - **Rewrite a changelog line:** edit the `BEGIN_COMMIT_OVERRIDE` block in the merged PR's body, then run the **Release** workflow to rebuild the Release PR. Keep ticket IDs out of PR titles, because a title becomes a changelog line. ## Releasing a new version (for Stream developers) From 18fdc3763b075800e6184cc7f77963342bb77a47 Mon Sep 17 00:00:00 2001 From: Yun Wang Date: Thu, 3 Dec 2026 16:53:18 +0100 Subject: [PATCH 2/6] ci: tell failed, cancelled and unrerunnable integration apart; take alert tickets from wire and go --- .github/workflows/regen.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/regen.yml b/.github/workflows/regen.yml index 4b2a057d..b593016e 100644 --- a/.github/workflows/regen.yml +++ b/.github/workflows/regen.yml @@ -98,12 +98,12 @@ jobs: if [ "${2:-}" = quiet ]; then echo "::notice::#$num $1, so a human merges it"; else human "$1"; fi exit 0 } - # The approved breaking-change tickets the spec at commit $1 brings over the spec on $base. + # The approved breaking-change tickets the spec at commit $1 brings over the spec on $base, from the same lists as tickets() below. new_tickets() { local ref tag for ref in "$base" "$1"; do tag=$(gh api "repos/$GITHUB_REPOSITORY/contents/.spec-version?ref=$ref" -H 'Accept: application/vnd.github.raw' | sed -n 's/^spec: //p') && [ -n "$tag" ] || return 1 - curl -fsSL "https://raw.githubusercontent.com/GetStream/protocol/$tag/openapi/v2/serverside-api.yaml" | yq -r '(.info."x-stream-breaking-changes" // {}) | .[] | .[]' | sort -u > "$RUNNER_TEMP/tickets-$ref" || return 1 + curl -fsSL "https://raw.githubusercontent.com/GetStream/protocol/$tag/openapi/v2/serverside-api.yaml" | yq -r '.info."x-stream-breaking-changes" // {} | (.wire // []) + (.go // []) | .[]' | sort -u > "$RUNNER_TEMP/tickets-$ref" || return 1 done comm -13 "$RUNNER_TEMP/tickets-$base" "$RUNNER_TEMP/tickets-$1" } @@ -160,8 +160,11 @@ jobs: completed/success) ;; # The shared app and the repo-wide run-integration concurrency group, which drops a queued run, make a red or cancelled run often not the regen's fault, so up to three attempts run before a human is asked. The workflow_run trigger merges once a rerun passes. completed/*) - if [ "$attempt" -lt 3 ] && GH_TOKEN=$CHECKS_TOKEN gh run rerun "$id"; then echo "::notice::#$num reran its integration tests after a $conclusion on attempt $attempt, and a pass merges it"; exit 0; fi - human "is waiting: integration tests failed $attempt times. SDK bot needs a human to check" + if [ "$attempt" -lt 3 ]; then + if GH_TOKEN=$CHECKS_TOKEN gh run rerun "$id"; then echo "::notice::#$num reran its integration tests after a $conclusion on attempt $attempt, and a pass merges it"; exit 0; fi + human "is waiting: its integration tests ended in $conclusion on attempt $attempt and could not be rerun. SDK bot needs a human to check" + elif [ "$conclusion" = failure ]; then human "is waiting: integration tests failed $attempt times. SDK bot needs a human to check" + else human "is waiting: integration tests ended in $conclusion on attempt $attempt. SDK bot needs a human to check"; fi if [ "$GITHUB_EVENT_NAME" = workflow_run ]; then echo "ping=true" >> "$GITHUB_OUTPUT"; fi exit 0 ;; ''|queued/|in_progress/|waiting/|pending/|requested/) continue ;; From 7bcf2c6b7d3d845a53fb782549c0416b1783ea23 Mon Sep 17 00:00:00 2001 From: Yun Wang Date: Thu, 3 Dec 2026 17:23:25 +0100 Subject: [PATCH 3/6] ci: take alert tickets from the same lists as the Breaking changes check --- .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 b593016e..55ecbf8e 100644 --- a/.github/workflows/regen.yml +++ b/.github/workflows/regen.yml @@ -98,12 +98,12 @@ jobs: if [ "${2:-}" = quiet ]; then echo "::notice::#$num $1, so a human merges it"; else human "$1"; fi exit 0 } - # The approved breaking-change tickets the spec at commit $1 brings over the spec on $base, from the same lists as tickets() below. + # The approved breaking-change tickets the spec at commit $1 brings over the spec on $base, from the same lists as the Breaking changes check. new_tickets() { local ref tag for ref in "$base" "$1"; do tag=$(gh api "repos/$GITHUB_REPOSITORY/contents/.spec-version?ref=$ref" -H 'Accept: application/vnd.github.raw' | sed -n 's/^spec: //p') && [ -n "$tag" ] || return 1 - curl -fsSL "https://raw.githubusercontent.com/GetStream/protocol/$tag/openapi/v2/serverside-api.yaml" | yq -r '.info."x-stream-breaking-changes" // {} | (.wire // []) + (.go // []) | .[]' | sort -u > "$RUNNER_TEMP/tickets-$ref" || return 1 + curl -fsSL "https://raw.githubusercontent.com/GetStream/protocol/$tag/openapi/v2/serverside-api.yaml" | yq -r '(.info as $i | ($i."x-stream-breaking-changes".wire // []) + [$i."x-stream-breaking-change-lines" // {} | to_entries | .[] | select(.value.sdk // [] | any_c(test("^stream-sdk-java "))) | .key]) + (.info."x-stream-breaking-changes".go // []) | .[]' | sort -u > "$RUNNER_TEMP/tickets-$ref" || return 1 done comm -13 "$RUNNER_TEMP/tickets-$base" "$RUNNER_TEMP/tickets-$1" } From b98649ff4e6cc41cd37a35f887539b6d1231985f Mon Sep 17 00:00:00 2001 From: Yun Wang Date: Thu, 3 Dec 2026 17:35:40 +0100 Subject: [PATCH 4/6] ci: alert names tickets that gained a footer line; generic text when the base spec has no list --- .github/workflows/regen.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/regen.yml b/.github/workflows/regen.yml index 55ecbf8e..4872ca26 100644 --- a/.github/workflows/regen.yml +++ b/.github/workflows/regen.yml @@ -98,14 +98,17 @@ jobs: if [ "${2:-}" = quiet ]; then echo "::notice::#$num $1, so a human merges it"; else human "$1"; fi exit 0 } - # The approved breaking-change tickets the spec at commit $1 brings over the spec on $base, from the same lists as the Breaking changes check. + # The approved breaking-change tickets the spec at commit $1 brings over the spec on $base: tickets new to the Breaking changes check's lists, and tickets that gained a line the footers use. A base spec without a list cannot say which are new, as in that check. new_tickets() { - local ref tag + local ref tag spec for ref in "$base" "$1"; do tag=$(gh api "repos/$GITHUB_REPOSITORY/contents/.spec-version?ref=$ref" -H 'Accept: application/vnd.github.raw' | sed -n 's/^spec: //p') && [ -n "$tag" ] || return 1 - curl -fsSL "https://raw.githubusercontent.com/GetStream/protocol/$tag/openapi/v2/serverside-api.yaml" | yq -r '(.info as $i | ($i."x-stream-breaking-changes".wire // []) + [$i."x-stream-breaking-change-lines" // {} | to_entries | .[] | select(.value.sdk // [] | any_c(test("^stream-sdk-java "))) | .key]) + (.info."x-stream-breaking-changes".go // []) | .[]' | sort -u > "$RUNNER_TEMP/tickets-$ref" || return 1 + spec=$RUNNER_TEMP/tickets-$ref.yaml + curl -fsSL "https://raw.githubusercontent.com/GetStream/protocol/$tag/openapi/v2/serverside-api.yaml" -o "$spec" || return 1 + yq -e '.info."x-stream-breaking-changes"' "$spec" > /dev/null 2>&1 || return 1 + { yq -r '(.info as $i | ($i."x-stream-breaking-changes".wire // []) + [$i."x-stream-breaking-change-lines" // {} | to_entries | .[] | select(.value.sdk // [] | any_c(test("^stream-sdk-java "))) | .key]) + (.info."x-stream-breaking-changes".go // []) | .[]' "$spec" && yq -r '.info."x-stream-breaking-change-lines" // {} | to_entries | .[] | .key as $t | (.value.wire // []) + (.value.sdk // [] | map(select(test("^stream-sdk-java ")))) | .[] | $t + "\t" + .' "$spec"; } | sort -u > "$RUNNER_TEMP/tickets-$ref" || return 1 done - comm -13 "$RUNNER_TEMP/tickets-$base" "$RUNNER_TEMP/tickets-$1" + comm -13 "$RUNNER_TEMP/tickets-$base" "$RUNNER_TEMP/tickets-$1" | cut -f1 | sort -u } # What a human judges in a breaking regen at commit $1: the tickets behind it, or that none explains it. held() { From 5485e129fe452c26efa8de585c4b1d0fcc439c66 Mon Sep 17 00:00:00 2001 From: Yun Wang Date: Fri, 4 Dec 2026 09:03:25 +0100 Subject: [PATCH 5/6] ci: compare alert ticket lines only when both specs carry them --- .github/workflows/regen.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/regen.yml b/.github/workflows/regen.yml index 4872ca26..d5918075 100644 --- a/.github/workflows/regen.yml +++ b/.github/workflows/regen.yml @@ -98,15 +98,17 @@ jobs: if [ "${2:-}" = quiet ]; then echo "::notice::#$num $1, so a human merges it"; else human "$1"; fi exit 0 } - # The approved breaking-change tickets the spec at commit $1 brings over the spec on $base: tickets new to the Breaking changes check's lists, and tickets that gained a line the footers use. A base spec without a list cannot say which are new, as in that check. + # The approved breaking-change tickets the spec at commit $1 brings over the spec on $base: tickets new to the Breaking changes check's lists and, when both specs carry lines, tickets that gained a line the footers use. A base spec without a list cannot say which are new, as in that check. new_tickets() { - local ref tag spec + local ref tag lines=true for ref in "$base" "$1"; do tag=$(gh api "repos/$GITHUB_REPOSITORY/contents/.spec-version?ref=$ref" -H 'Accept: application/vnd.github.raw' | sed -n 's/^spec: //p') && [ -n "$tag" ] || return 1 - spec=$RUNNER_TEMP/tickets-$ref.yaml - curl -fsSL "https://raw.githubusercontent.com/GetStream/protocol/$tag/openapi/v2/serverside-api.yaml" -o "$spec" || return 1 - yq -e '.info."x-stream-breaking-changes"' "$spec" > /dev/null 2>&1 || return 1 - { yq -r '(.info as $i | ($i."x-stream-breaking-changes".wire // []) + [$i."x-stream-breaking-change-lines" // {} | to_entries | .[] | select(.value.sdk // [] | any_c(test("^stream-sdk-java "))) | .key]) + (.info."x-stream-breaking-changes".go // []) | .[]' "$spec" && yq -r '.info."x-stream-breaking-change-lines" // {} | to_entries | .[] | .key as $t | (.value.wire // []) + (.value.sdk // [] | map(select(test("^stream-sdk-java ")))) | .[] | $t + "\t" + .' "$spec"; } | sort -u > "$RUNNER_TEMP/tickets-$ref" || return 1 + curl -fsSL "https://raw.githubusercontent.com/GetStream/protocol/$tag/openapi/v2/serverside-api.yaml" -o "$RUNNER_TEMP/tickets-$ref.yaml" || return 1 + yq -e '.info."x-stream-breaking-changes"' "$RUNNER_TEMP/tickets-$ref.yaml" > /dev/null 2>&1 || return 1 + yq -e '.info."x-stream-breaking-change-lines"' "$RUNNER_TEMP/tickets-$ref.yaml" > /dev/null 2>&1 || lines=false + done + for ref in "$base" "$1"; do + { yq -r '(.info as $i | ($i."x-stream-breaking-changes".wire // []) + [$i."x-stream-breaking-change-lines" // {} | to_entries | .[] | select(.value.sdk // [] | any_c(test("^stream-sdk-java "))) | .key]) + (.info."x-stream-breaking-changes".go // []) | .[]' "$RUNNER_TEMP/tickets-$ref.yaml" && if [ "$lines" = true ]; then yq -r '.info."x-stream-breaking-change-lines" // {} | to_entries | .[] | .key as $t | (.value.wire // []) + (.value.sdk // [] | map(select(test("^stream-sdk-java ")))) | .[] | $t + "\t" + .' "$RUNNER_TEMP/tickets-$ref.yaml"; fi; } | sort -u > "$RUNNER_TEMP/tickets-$ref" || return 1 done comm -13 "$RUNNER_TEMP/tickets-$base" "$RUNNER_TEMP/tickets-$1" | cut -f1 | sort -u } From f2eb4dcef5587d9be5a63c74065f5e00752d098d Mon Sep 17 00:00:00 2001 From: Yun Wang Date: Fri, 4 Dec 2026 09:51:37 +0100 Subject: [PATCH 6/6] ci: generic wording for the final regen integration alert The third bad attempt now says the tests failed after several retries instead of counting attempts, which also counted cancelled ones. --- .github/workflows/regen.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/regen.yml b/.github/workflows/regen.yml index d5918075..06d314b4 100644 --- a/.github/workflows/regen.yml +++ b/.github/workflows/regen.yml @@ -168,8 +168,7 @@ jobs: if [ "$attempt" -lt 3 ]; then if GH_TOKEN=$CHECKS_TOKEN gh run rerun "$id"; then echo "::notice::#$num reran its integration tests after a $conclusion on attempt $attempt, and a pass merges it"; exit 0; fi human "is waiting: its integration tests ended in $conclusion on attempt $attempt and could not be rerun. SDK bot needs a human to check" - elif [ "$conclusion" = failure ]; then human "is waiting: integration tests failed $attempt times. SDK bot needs a human to check" - else human "is waiting: integration tests ended in $conclusion on attempt $attempt. SDK bot needs a human to check"; fi + else human "is waiting: integration tests failed after several retries. SDK bot needs a human to check"; fi if [ "$GITHUB_EVENT_NAME" = workflow_run ]; then echo "ping=true" >> "$GITHUB_OUTPUT"; fi exit 0 ;; ''|queued/|in_progress/|waiting/|pending/|requested/) continue ;;