Note
Most of the code in this repository is automatically generated from the OpenAPI specification of the Stream API. Therefore, it does NOT make sense to try to change them manually.
Tests are written manually and more tests are always welcome.
Some parts like lib/src/main/java/io/getstream/services/framework and lib/src/main/java/io/getstream/models/framework, serve as the base and are written manually as well.
To contribute to this project, you need to have Lombok installed in your IDE. You also need to use javac >= 11 to compile (ensure that your JAVA_HOME points to such a location), even if the produced library is compatible with Java 8 (for some reasons, jdk 8 compiler fails on some Lombok annotations).
- Setup the project
- Architecture explanation
- Code rules
- How to
- Commit message convention
- Releasing a new version (for Stream developers)
The project is a Maven project.
Copy local.properties.example to local.properties and put configuration there. These properties are automatically picked up during tests execution
# Run the unit tests
./gradlew test
# Run the tests that talk to a live Stream app
./gradlew integrationTest
# Check code style
./gradlew spotlessCheck
# Fix code style problems
./gradlew spotlessApplyThe code is composed of:
They are the data objects. They correspond to the formats of the objects contained in the API responses.
They are builders for API requests, and also contain methods to perform the calls.
They are data objects. They correspond to the formats of the API requests.
They are data objects. They correspond to the formats of the API responses.
They are the interfaces that define the API endpoints.
This class is responsible to make the Service interfaces usable to call the API. It is used by all Request classes to define the generateCall method.
It also handles authentication and logging.
StreamResponse is the interface that correspond to an API response. Most APIs responses are StreamResponseObject (mean they contain duration and rate limit data).
StreamRequest is the generic Request class, that defines the request and requestAsync methods, which call the StreamServiceHandler.
The StreamServiceHandler class defines the synchronous and asynchronous processing. It also enriched the Response object with rate limit data when available.
They are organized by model. Each endpoint has at least one test related.
A test tagged @Tag("integration") talks to a live Stream app and needs credentials.
BasicTest carries the tag and JUnit inherits it, so extending that class is enough.
./gradlew test excludes them and needs no credentials, ./gradlew integrationTest runs
only them.
CI follows the same split:
| When | What runs | Gates anything |
|---|---|---|
| Pull request | spotlessCheck and build |
yes, 🧪 Tests is required on main |
| Daily at 10:00 UTC | integrationTest |
no, a red run opens an issue |
| Release PR merged | nothing on the default branch, the unit lane on N.x |
N.x only |
- The code should be formatted using Google formatter.
- All attributes, parameters and return values should be annotated with either
@Nullableor@NotNull - New implementations should follow the same principles as the existing ones (see how to section below)
- In Models, collections of submodel should be List (other collections and arrays are not supported by RequestObjectBuilder)
- String that only can take a given set of values should be represented as enums, with an
UNKNOWNvalue marked@JsonEnumDefaultValueto avoid problem if the list of possible values changes
Logging is enabled by default in tests. If you want to create a main class and activate logging, you should do the following:
StreamServiceGenerator.logLevel = HttpLoggingInterceptor.Level.BODY;This repository follows a commit message convention in order to automatically generate the CHANGELOG. Make sure you follow the rules of conventional commits when opening a pull request.
The client regenerates itself on every chat production release:
- chat attaches its
openapigenerator to the release and publishes the matchingopenapi-vXspec release in protocol. - protocol notifies this repo, and the Regenerate workflow opens one PR from
regen/auto, titledfeat: regenerate client from openapi-vX. ItsBEGIN_COMMIT_OVERRIDEblock lists the changelog lines. - 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/**.
- Regenerate now: run Regenerate from the Actions tab with an
openapi-vXtag, or leave it empty for the latest. Locally,SPEC_TAG=openapi-vX ./generate.shdoes the same with the generator built from a../chatcheckout 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 beforeEND_COMMIT_OVERRIDEadd a blank line andBREAKING CHANGE: <what breaks for customers>. Then merge it yourself in a breaking-change window, with aMIGRATION_vX_to_vY.mdguide. - An approved breaking change that does not break this SDK: label the PR
sdk-not-breakingand name each ticket the check lists in the PR body. When the regen titled itfeat!:, also drop the!and delete the entries that carry aBREAKING 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/autofrom the Actions tab. - Rewrite a changelog line: edit the
BEGIN_COMMIT_OVERRIDEblock 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.
Releases are driven by release-please.
- Merge PRs to
mainwith conventional-commit titles, using Squash and merge. The title becomes the commit subject and decides the next version:feat:is a minor,fix:andperf:are a patch,feat!:or<type>(scope)!:is a major. Other types (chore,ci,docs,test,refactor) ship nothing. This is new: the version used to be typed by hand into theinitiate_releasejob, which is gone. - release-please keeps a Release PR open with the version bump in
gradle.propertiesandCHANGELOG.md. Never edit the version by hand, and leave thex-release-please-start-versioncomments around it in place; a.propertiesfile takes a trailing comment as part of the value, so the marker has to bracket the line. - Its checks sit Pending until someone clicks Approve and run, because a PR opened
with
GITHUB_TOKENstarts no workflow runs. After that the unit lane reportsskippedand🧪 Testsgoes green in seconds without running a test. The skip only applies while the diff is nothing but what release-please writes, down to the version line in each version file, so a code or dependency change pushed onto a Release PR by hand runs the unit lane like any other PR. - Merging creates the tag and the GitHub Release on the merge commit and publishes to Maven Central, with no further test run: the Release PR adds only the version bump and changelog to an already-tested
main. A hotfix release fromN.xruns the unit lane first, since its commits were pushed without a PR. A tag, a GitHub Release and a Maven Central push cannot be withdrawn. The publish step builds the project, so a build that does not compile fails there after the tag exists; the fix ships under the next version, sincepublish_tagrebuilds the same tag.
Tags here have no v prefix (10.1.1, not v10.1.1), which include-v-in-tag: false
in release-please-config.json preserves.
To retry a publish that failed after the release was tagged, use "Re-run failed jobs" on
that workflow run. Once GitHub has retired the run, dispatch Release from main with
publish_tag set to the tag, which builds and publishes that tag without touching
release-please. If the release job fails after the Release PR merged, the release stays
pending and every later push logs a warning naming the commit to go back to.
To force a specific version, type Release-As: X.Y.Z in the commit message box of the
squash dialog when merging a PR; the PR description is not copied there.