Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions .github/workflows/breaking_changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
breaking-changes:
name: Breaking changes check
runs-on: { group: github-public-amd64 }
timeout-minutes: 5
timeout-minutes: 10
steps:
- env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -32,7 +32,9 @@ jobs:
: > "$RUNNER_TEMP/$2"
fi
}
read_version "$BASE_SHA" base-version
# The merge base, not the base tip: a branch cut before a regen merged still carries the older .spec-version, which is no downgrade.
base=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BASE_SHA...$HEAD_SHA" --jq .merge_base_commit.sha)
read_version "$base" base-version
read_version "$HEAD_SHA" head-version
if [ ! -s "$RUNNER_TEMP/head-version" ]; then echo "the PR has no .spec-version"; exit 0; fi
if cmp -s "$RUNNER_TEMP/base-version" "$RUNNER_TEMP/head-version"; then echo ".spec-version unchanged"; exit 0; fi
Expand Down Expand Up @@ -100,8 +102,53 @@ jobs:
fi
echo "::error::$new brings approved breaking changes (${added//$'\n'/, }). Add '!' to the PR title to release a major, or label the PR sdk-not-breaking and name each ticket in the PR body if none of them breaks this SDK. $hold"
exit 1
# A hand-written change never moves .spec-version, so the public API itself is compared too, with japicmp on jars built from the base tip and the merge commit.
- uses: actions/checkout@v5.0.1
if: ${{ !cancelled() }}
with:
fetch-depth: 2
persist-credentials: false
- uses: actions/setup-java@v5.1.0
if: ${{ !cancelled() }}
with:
distribution: 'corretto'
java-version: '17'
- uses: gradle/actions/setup-gradle@v4
if: ${{ !cancelled() }}
- name: Public API stays compatible
if: ${{ !cancelled() }}
env:
TITLE: ${{ github.event.pull_request.title }}
NOT_BREAKING: ${{ contains(github.event.pull_request.labels.*.name, 'sdk-not-breaking') }}
run: |
set -euo pipefail
curl -fsSL -o "$RUNNER_TEMP/japicmp.jar" https://repo1.maven.org/maven2/com/github/siom79/japicmp/japicmp/0.27.0/japicmp-0.27.0-jar-with-dependencies.jar
echo "1b69870198a6d321139f3cfa9f47ccbf3eea4b91167fefd3c69c77e9cc213917 $RUNNER_TEMP/japicmp.jar" | sha256sum -c --quiet
# The checkout is the merge commit, whose first parent is the base tip, so the difference is this PR's alone.
git worktree add -q "$RUNNER_TEMP/base" HEAD^1
(cd "$RUNNER_TEMP/base" && ./gradlew jar --no-daemon -q)
./gradlew jar --no-daemon -q
# -m keeps source-only breaks, such as a changed generic type, that --only-incompatible drops. Added methods are skipped: callers use the service interfaces and never implement them. So are model constructors: Lombok's all-args constructor changes with every added field, and callers build models with the builder.
java -jar "$RUNNER_TEMP/japicmp.jar" -o "$RUNNER_TEMP"/base/build/libs/*.jar -n build/libs/*.jar -m --ignore-missing-classes \
| awk '
/^[^\t]/ { c = $0; sub(/ \(.*$/, "", c); h = c; sub(/.* /, "", c) }
Comment thread
getstream-metis[bot] marked this conversation as resolved.
Resolved
/^---[!*] REMOVED / { print "removed " c }
# A class-level change, such as a class made final or package-private, shows only on its header, as "(<- old)".
/^(\*\*\*|===)[!*] / && h ~ /\(<-/ { print c ": " h }
/^\t+GENERIC TEMPLATES: (\*\*\*|---)/ { l = $0; sub(/^\t+/, "", l); print c ": " l }
/^\t+(===|\*\*\*|---)[!*] / && !(c ~ /^io\.getstream\.models\./ && /CONSTRUCTOR/) { l = $0; sub(/^\t+/, "", l); print c ": " l }
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
Comment thread
mogita marked this conversation as resolved.
Resolved
' > "$RUNNER_TEMP/incompatible"
if [ ! -s "$RUNNER_TEMP/incompatible" ]; then echo "the public API stays compatible"; exit 0; fi
echo "incompatible public API changes:"
cat "$RUNNER_TEMP/incompatible"
bang='^[a-z]+(\([^)]*\))?!:'
if [[ $TITLE =~ $bang ]]; then echo "the title marks a major"; exit 0; fi
if [ "$NOT_BREAKING" = true ]; then echo "labelled sdk-not-breaking"; exit 0; fi
echo "::error::This PR breaks the public API (listed above). Prefer a compatible change. To release a major, add '!' to the PR title, plus a BREAKING CHANGE footer if the body has a BEGIN_COMMIT_OVERRIDE block; if no customer can hit these, label the PR sdk-not-breaking. If auto-merge is on, turn it off before adding '!', or the major merges as soon as this check passes."
exit 1
# release-please reads a BEGIN_COMMIT_OVERRIDE block in place of the title, so the block releases a major only through a BREAKING CHANGE footer, whatever the title says.
- name: Title and changelog agree on a major
Comment thread
mogita marked this conversation as resolved.
Resolved
if: ${{ !cancelled() }}
env:
TITLE: ${{ github.event.pull_request.title }}
BODY: ${{ github.event.pull_request.body }}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ The client regenerates itself on every chat production release:
2. protocol notifies this repo, and the **Regenerate** workflow opens one PR from `regen/auto`, titled `feat: regenerate client from openapi-vX`. Its `BEGIN_COMMIT_OVERRIDE` block lists the changelog lines.
3. Once the required checks pass and the **Regen integration** run passes on the PR's head commit, the PR merges itself, and release-please adds those lines to the Release PR. Merging the Release PR ships, as described below.

A regen PR waits for a human when its changelog carries a `BREAKING CHANGE:` footer, when the `Breaking changes check` finds an approved breaking change in the new spec, or when a required check fails. For each approved breaking change with wire lines, the regen writes `BREAKING CHANGE:` footers from the lines chat allowlisted and titles the PR `feat!:`, so the check passes and the PR only waits for a human to merge it. A ticket chat approved for getstream-go only has no Java lines, so the check fails until a human names it in the PR body, also on a `feat!:` PR. Only `getstream-sdk-bot` can push to `regen/**`.
A regen PR waits for a human when its changelog carries a `BREAKING CHANGE:` footer, when the `Breaking changes check` finds an approved breaking change in the new spec, or when a required check fails. For each approved breaking change with wire lines or `stream-sdk-java` sdk lines, the regen writes `BREAKING CHANGE:` footers from the lines chat allowlisted and titles the PR `feat!:`, so the check passes and the PR only waits for a human to merge it. A ticket chat approved for getstream-go only has no Java lines, so the check fails until a human names it in the PR body, also on a `feat!:` PR. The `Breaking changes check` also compares the public API of every PR, hand-written code included, against its base with japicmp, and fails on an incompatible change unless the title has `!` or the PR is labelled `sdk-not-breaking`. A regen PR can fail this comparison too, when a generator change alone breaks a caller; it then waits for a human, who handles it as one of the breaking-change cases below. Only `getstream-sdk-bot` can push to `regen/**`.

### Manual cases

Expand Down
Loading