Skip to content

Commit b335418

Browse files
committed
initial sdk release
0 parents  commit b335418

840 files changed

Lines changed: 41521 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Submit a pull request
2+
3+
## CLA
4+
5+
- [ ] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required).
6+
- [ ] The code changes follow best practices
7+
- [ ] Code changes are tested (add some information if not applicable)
8+
9+
## Description of the pull request

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build
2+
3+
on: [pull_request]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.head_ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
ci:
11+
name: 🧪 Test & lint
12+
environment: ci
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
# - name: Commit message lint
21+
# uses: wagoid/commitlint-github-action@v4
22+
23+
- name: Setup JDK 17
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: 'corretto'
27+
java-version: '17'
28+
29+
- name: Setup Gradle
30+
uses: gradle/actions/setup-gradle@v4
31+
32+
- name: Test
33+
env:
34+
STREAM_BASE_URL: ${{ vars.STREAM_BASE_URL }}
35+
STREAM_API_KEY: ${{ vars.STREAM_API_KEY }}
36+
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
37+
run: |
38+
./gradlew spotlessCheck --no-daemon
39+
./gradlew build --info --no-daemon
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Create release PR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "The new version number. Example: 1.40.1"
8+
required: true
9+
type: string
10+
pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$"
11+
12+
jobs:
13+
init_release:
14+
name: 🚀 Create release PR
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0 # gives the changelog generator access to all previous commits
20+
21+
- name: Update CHANGELOG.md, build.gradle and push release branch
22+
env:
23+
VERSION: ${{ github.event.inputs.version }}
24+
run: |
25+
npx --yes standard-version@9.3.2 --release-as "$VERSION" --skip.tag --skip.commit --tag-prefix=
26+
echo "version=$VERSION" > gradle.properties
27+
git config --global user.name 'github-actions'
28+
git config --global user.email 'release@getstream.io'
29+
git checkout -q -b "release-$VERSION"
30+
git add CHANGELOG.md gradle.properties
31+
git commit -am "chore(release): $VERSION"
32+
git push -q -u origin "release-$VERSION"
33+
34+
- name: Open pull request
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
gh pr create \
39+
-t "Release ${{ github.event.inputs.version }}" \
40+
-b "# :rocket: ${{ github.event.inputs.version }}
41+
Make sure to use squash & merge when merging!
42+
Once this is merged, another job will kick off automatically and publish the package.
43+
# :memo: Changelog
44+
$(cat CHANGELOG.md)"

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
jobs:
10+
Release:
11+
name: 🚀 Release
12+
if: github.event.pull_request.merged && startsWith(github.head_ref, 'release-')
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/github-script@v6
20+
with:
21+
script: |
22+
// Getting the release version from the PR source branch
23+
// Source branch looks like this: release-1.0.0
24+
const version = context.payload.pull_request.head.ref.split('-')[1]
25+
core.exportVariable('VERSION', version)
26+
27+
- name: Publish to MavenCentral
28+
run: |
29+
./gradlew publishToSonatype --no-daemon --max-workers 1 closeAndReleaseSonatypeStagingRepository
30+
env:
31+
STREAM_API_KEY: ${{ vars.STREAM_API_KEY }}
32+
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
33+
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
34+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
35+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
36+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
37+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
38+
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
39+
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
40+
41+
- name: Create release on GitHub
42+
uses: ncipollo/release-action@v1
43+
with:
44+
tag: ${{ env.VERSION }}
45+
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Scheduled tests
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Monday at 9:00 UTC
7+
- cron: "0 9 * * 1"
8+
9+
jobs:
10+
test:
11+
environment: ci
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Run tests
16+
env:
17+
STREAM_BASE_URL: ${{ vars.STREAM_BASE_URL }}
18+
STREAM_API_KEY: ${{ vars.STREAM_API_KEY }}
19+
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
20+
run: |
21+
# Retry 3 times because tests can be flaky
22+
for _ in 1 2 3;
23+
do
24+
./gradlew test --no-daemon && break
25+
done
26+
27+
- name: Notify Slack if failed
28+
uses: voxmedia/github-action-slack-notify-build@v1
29+
if: failure()
30+
with:
31+
channel_id: C02RPDF7T63
32+
color: danger
33+
status: FAILED
34+
env:
35+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}

.gitignore

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## https://github.com/github/gitignore/blob/main/Java.gitignore
2+
# Compiled class file
3+
*.class
4+
5+
# Log file
6+
*.log
7+
8+
# BlueJ files
9+
*.ctxt
10+
11+
# Mobile Tools for Java (J2ME)
12+
.mtj.tmp/
13+
14+
# Package Files #
15+
*.jar
16+
*.war
17+
*.nar
18+
*.ear
19+
*.zip
20+
*.tar.gz
21+
*.rar
22+
23+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
24+
hs_err_pid*
25+
replay_pid*
26+
27+
## https://github.com/github/gitignore/blob/main/Gradle.gitignore
28+
.gradle
29+
**/build/
30+
!src/**/build/
31+
32+
# Ignore Gradle GUI config
33+
gradle-app.setting
34+
35+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
36+
!gradle-wrapper.jar
37+
38+
# Avoid ignore Gradle wrappper properties
39+
!gradle-wrapper.properties
40+
41+
# Cache of project
42+
.gradletasknamecache
43+
44+
# Eclipse Gradle plugin generated files
45+
# Eclipse Core
46+
.project
47+
# JDT-specific (Eclipse Java Development Tools)
48+
.classpath
49+
50+
## project specific
51+
/local.properties
52+
53+
.idea

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4+
5+
6+
### 0.1.5 (2025-02-12)
7+
8+
### 0.1.4 (2025-02-12)
9+
10+
### 0.1.3 (2025-02-12)
11+
12+
### 0.1.2 (2025-02-12)
13+
14+
### 0.1.1 (2025-02-12)
15+
16+
17+
## 0.1.0 (2025-02-12)

CONTRIBUTING.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# :recycle: Contributing <!-- omit in toc -->
2+
3+
> [!NOTE]
4+
> Most of the code in this repository is **automatically generated** from the [OpenAPI specification](https://getstream.github.io/protocol/) of the Stream API. Therefore, **it does NOT make sense to try to change them manually**.
5+
6+
Tests are written manually and more tests are always welcome.
7+
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.
8+
9+
## Requirements <!-- omit in toc -->
10+
11+
To contribute to this project, you need to have [Lombok](https://projectlombok.org/) installed in your IDE.
12+
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).
13+
14+
- [Setup the project](#setup-the-project)
15+
- [Architecture explanation](#architecture-explanation)
16+
- [Model classes](#model-classes)
17+
- [Request classes](#request-classes)
18+
- [RequestData and RequestObject classes](#requestdata-and-requestobject-classes)
19+
- [Response classes](#response-classes)
20+
- [Service interfaces](#service-interfaces)
21+
- [The StreamServiceGenerator class](#the-streamservicegenerator-class)
22+
- [The StreamResponse interface and related classes](#the-streamresponse-interface-and-related-classes)
23+
- [The StreamRequest and StreamServiceHandler classes](#the-streamrequest-and-streamservicehandler-classes)
24+
- [Test classes](#test-classes)
25+
- [Code rules](#code-rules)
26+
- [How to](#how-to)
27+
- [Enable logging](#enable-logging)
28+
- [Commit message convention](#commit-message-convention)
29+
- [Releasing a new version (for Stream developers)](#releasing-a-new-version-for-stream-developers)
30+
31+
## Setup the project
32+
33+
The project is a Maven project.
34+
35+
Copy `local.properties.example` to `local.properties` and put configuration there. These properties are automatically picked up during tests execution
36+
37+
```shell
38+
# Run tests
39+
./gradlew test
40+
41+
# Check code style
42+
./gradlew spotlessCheck
43+
44+
# Fix code style problems
45+
./gradlew spotlessApply
46+
```
47+
48+
## Architecture explanation
49+
50+
The code is composed of:
51+
52+
### Model classes
53+
54+
They are the data objects. They correspond to the formats of the objects contained in the API responses.
55+
56+
### Request classes
57+
58+
They are builders for API requests, and also contain methods to perform the calls.
59+
60+
### RequestData and RequestObject classes
61+
62+
They are data objects. They correspond to the formats of the API requests.
63+
64+
### Response classes
65+
66+
They are data objects. They correspond to the formats of the API responses.
67+
68+
### Service interfaces
69+
70+
They are the interfaces that define the API endpoints.
71+
72+
### The StreamServiceGenerator class
73+
74+
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.
75+
It also handles authentication and logging.
76+
77+
### The StreamResponse interface and related classes
78+
79+
StreamResponse is the interface that correspond to an API response. Most APIs responses are StreamResponseObject (mean they contain duration and rate limit data).
80+
81+
### The StreamRequest and StreamServiceHandler classes
82+
83+
StreamRequest is the generic Request class, that defines the `request` and `requestAsync` methods, which call the `StreamServiceHandler`.
84+
The `StreamServiceHandler` class defines the synchronous and asynchronous processing. It also enriched the Response object with rate limit data when available.
85+
86+
### Test classes
87+
88+
They are organized by model. Each endpoint has at least one test related.
89+
90+
## Code rules
91+
92+
- The code should be formatted using Google formatter.
93+
- All attributes, parameters and return values should be annotated with either `@Nullable` or `@NotNull`
94+
- New implementations should follow the same principles as the existing ones (see how to section below)
95+
- In Models, collections of submodel should be List (other collections and arrays are not supported by RequestObjectBuilder)
96+
- String that only can take a given set of values should be represented as enums, with an `UNKNOWN` value marked `@JsonEnumDefaultValue` to avoid problem if the list of possible values changes
97+
98+
## How to
99+
100+
### Enable logging
101+
102+
Logging is enabled by default in tests. If you want to create a main class and activate logging, you should do the following:
103+
104+
```java
105+
StreamServiceGenerator.logLevel = HttpLoggingInterceptor.Level.BODY;
106+
```
107+
108+
## Commit message convention
109+
110+
This repository follows a commit message convention in order to automatically generate the [CHANGELOG](./CHANGELOG.md). Make sure you follow the rules of [conventional commits](https://www.conventionalcommits.org/) when opening a pull request.
111+
112+
## Releasing a new version (for Stream developers)
113+
114+
In order to release new version you need to be a maintainer of the library.
115+
116+
- Kick off a job called `initiate_release` ([link](https://github.com/GetStream/stream-sdk-java/actions/workflows/initiate_release.yml)).
117+
118+
The job creates a pull request with the changelog. Check if it looks good.
119+
120+
- Merge the pull request.
121+
122+
Once the PR is merged, it automatically kicks off another job which will upload the Gem to RubyGems.org and creates a GitHub release.

0 commit comments

Comments
 (0)