Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java templates and release #47

Merged
merged 9 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
88 changes: 88 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Pre-release updates

on:
workflow_dispatch:
inputs:
sdkTypescriptVersion:
description: 'sdk-typescript version (without prepending v). Leave empty if you do not want to update it.'
required: false
type: string
sdkJavaVersion:
description: 'sdk-java version (without prepending v). Leave empty if you do not want to update it.'
required: false
type: string

jobs:
updates:
# prevent from running on forks
if: github.repository_owner == 'restatedev'
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Checkout
uses: actions/checkout@v3

# Setup node
- uses: actions/setup-node@v3
if: github.event.inputs.sdkTypescriptVersion != ''
with:
node-version: "19.x"
registry-url: 'https://registry.npmjs.org'

# Bump sdk version in node examples and run checks
- name: Run npm updates
if: github.event.inputs.sdkTypescriptVersion != ''
run: npm --prefix typescript install @restatedev/restate-sdk@^${{ inputs.sdkTypescriptVersion }} --workspaces
- name: Check npm examples compile correctly
if: github.event.inputs.sdkTypescriptVersion != ''
run: npm --prefix typescript run verify --workspaces

# Setup Java
- uses: actions/setup-java@v3
if: github.event.inputs.sdkJavaVersion != ''
with:
distribution: 'temurin'
java-version: '17'

# Bump sdk version in java examples and run checks
- name: Find and replace restateVersion in build.gradle.kts for java templates
if: github.event.inputs.sdkJavaVersion != ''
run: for jvmDir in hello-world-http hello-world-lambda; do sed -i 's/val restateVersion = "[0-9A-Z.-]*"/val restateVersion = "${{ inputs.sdkJavaVersion }}"/' java/$jvmDir/build.gradle.kts; done
- name: Find and replace restateVersion in build.gradle.kts for kotlin templates
if: github.event.inputs.sdkJavaVersion != ''
run: for jvmDir in hello-world-http hello-world-lambda; do sed -i 's/val restateVersion = "[0-9A-Z.-]*"/val restateVersion = "${{ inputs.sdkJavaVersion }}"/' kotlin/$jvmDir/build.gradle.kts; done
- name: Test java/hello-world-http
if: github.event.inputs.sdkJavaVersion != ''
uses: gradle/gradle-build-action@v2
with:
arguments: check
build-root-directory: java/hello-world-http
- name: Test java/hello-world-lambda
if: github.event.inputs.sdkJavaVersion != ''
uses: gradle/gradle-build-action@v2
with:
arguments: check
build-root-directory: java/hello-world-lambda
- name: Test kotlin/hello-world-http
if: github.event.inputs.sdkJavaVersion != ''
uses: gradle/gradle-build-action@v2
with:
arguments: check
build-root-directory: kotlin/hello-world-http
- name: Test kotlin/hello-world-lambda
if: github.event.inputs.sdkJavaVersion != ''
uses: gradle/gradle-build-action@v2
with:
arguments: check
build-root-directory: kotlin/hello-world-lambda

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
title: "[GithubActions] Update Restate SDK-Typescript '${{ inputs.sdkTypescriptVersion }}' SDK-Java '${{ inputs.sdkJavaVersion }}'"
commit-message: "[GithubActions] Update Restate SDK-Typescript '${{ inputs.sdkTypescriptVersion }}' SDK-Java '${{ inputs.sdkJavaVersion }}'"
slinkydeveloper marked this conversation as resolved.
Show resolved Hide resolved
add-paths: |
**/package.json
**/package-lock.json
**/build.gradle.kts
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Create new release

on:
push:
tags:
- v**

jobs:
publish-release:
# prevent from running on forks
if: github.repository_owner == 'restatedev'
name: Publish release
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Prepare zip files
run: ./scripts/prepare_release_zip.sh

- name: Create release
uses: softprops/action-gh-release@v1
with:
# create a draft release which needs manual approval
draft: true
files: |
typescript-lambda-greeter.zip
jvm-hello-world-java-http.zip
jvm-hello-world-java-lambda.zip
jvm-hello-world-kotlin-http.zip
jvm-hello-world-kotlin-lambda.zip
41 changes: 40 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,44 @@ on:
branches: [ main ]

jobs:
build:
build-jvm:
# prevent from running on forks
if: github.repository_owner == 'restatedev'
runs-on: ubuntu-latest
strategy:
matrix:
jvm-version: [ 17 ]

steps:
- uses: actions/checkout@v3

- name: Use JVM ${{ matrix.jvm-version }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.jvm-version }}

- name: Test java/hello-world-http
uses: gradle/gradle-build-action@v2
with:
arguments: check
build-root-directory: java/hello-world-http
- name: Test java/hello-world-lambda
uses: gradle/gradle-build-action@v2
with:
arguments: check
build-root-directory: java/hello-world-lambda
- name: Test kotlin/hello-world-http
uses: gradle/gradle-build-action@v2
with:
arguments: check
build-root-directory: kotlin/hello-world-http
- name: Test kotlin/hello-world-lambda
uses: gradle/gradle-build-action@v2
with:
arguments: check
build-root-directory: kotlin/hello-world-lambda
slinkydeveloper marked this conversation as resolved.
Show resolved Hide resolved
build-ts:
# prevent from running on forks
if: github.repository_owner == 'restatedev'
runs-on: ubuntu-latest
Expand All @@ -17,11 +54,13 @@ jobs:

steps:
- uses: actions/checkout@v3

- uses: bufbuild/buf-setup-action@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'

- run: npm ci --prefix typescript
- run: npm run --prefix typescript -ws verify
97 changes: 66 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,75 @@

Browse this repository to see how easy distributed applications development becomes with Restate.

## Typescript examples
## Starters

### Starter examples
![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white)

* [Lambda greeter](typescript/lambda-greeter): A simple example of how you can run a Restate service on AWS Lambda.
* [Payment api](typescript/payment-api/): Example API for payments, inspired by the Stripe API.
* [Food ordering](typescript/food-ordering): See how to integrate Restate with external services using Awakeables and side effects.
[Hello world on AWS Lambda](typescript/hello-world-lambda)
```shell
# Download the example
EXAMPLE=typescript-hello-world-lambda; wget https://github.com/restatedev/examples/releases/latest/download/$EXAMPLE.zip && unzip $EXAMPLE.zip -d $EXAMPLE && rm $EXAMPLE.zip
slinkydeveloper marked this conversation as resolved.
Show resolved Hide resolved
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a good idea but each entry feels still a bit verbose in terms of what is being written in the overview readme.


![Java](https://img.shields.io/badge/java-%23ED8B00.svg?style=for-the-badge&logo=openjdk&logoColor=white)

[Hello World HTTP](java/hello-world-http)
```shell
# Download the example
EXAMPLE=java-hello-world-http; wget https://github.com/restatedev/examples/releases/latest/download/$EXAMPLE.zip && unzip $EXAMPLE.zip -d $EXAMPLE && rm $EXAMPLE.zip
```

[Hello world on AWS Lambda](java/hello-world-lambda)
```shell
# Download the example
EXAMPLE=java-hello-world-lambda; wget https://github.com/restatedev/examples/releases/latest/download/$EXAMPLE.zip && unzip $EXAMPLE.zip -d $EXAMPLE && rm $EXAMPLE.zip
```

![Kotlin](https://img.shields.io/badge/kotlin-%237F52FF.svg?style=for-the-badge&logo=kotlin&logoColor=white)

[Hello World HTTP](java/hello-world-kotlin-http)
```shell
# Download the example
EXAMPLE=kotlin-hello-world-http; wget https://github.com/restatedev/examples/releases/latest/download/$EXAMPLE.zip && unzip $EXAMPLE.zip -d $EXAMPLE && rm $EXAMPLE.zip
```

[Hello world on AWS Lambda](java/hello-world-kotlin-lambda)
```shell
# Download the example
EXAMPLE=kotlin-hello-world-lambda; wget https://github.com/restatedev/examples/releases/latest/download/$EXAMPLE.zip && unzip $EXAMPLE.zip -d $EXAMPLE && rm $EXAMPLE.zip
```

## Patterns

![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white)

[Payment api](typescript/payment-api): Example API for payments, inspired by the Stripe API
```shell
# Download the example
EXAMPLE=typescript-payment-api; wget https://github.com/restatedev/examples/releases/latest/download/$EXAMPLE.zip && unzip $EXAMPLE.zip -d $EXAMPLE && rm $EXAMPLE.zip
```

### Intermediate examples
## Applications

* [Ticket reservation](typescript/ticket-reservation): An example to illustrate how Restate's keyed-sharding and concurrency guarantees simplify microservice architectures.
![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white)

### Advanced examples
[Food ordering](typescript/food-ordering): Integrate Restate with external services
```shell
# Download the example
EXAMPLE=typescript-food-ordering; wget https://github.com/restatedev/examples/releases/latest/download/$EXAMPLE.zip && unzip $EXAMPLE.zip -d $EXAMPLE && rm $EXAMPLE.zip
```

[Ticket reservation](typescript/ticket-reservation): Example showing Restate's keyed-sharding and concurrency guarantees
```shell
# Download the example
EXAMPLE=typescript-ticket-reservation; wget https://github.com/restatedev/examples/releases/latest/download/$EXAMPLE.zip && unzip $EXAMPLE.zip -d $EXAMPLE && rm $EXAMPLE.zip
```

- [Ecommerce store](typescript/ecommerce-store): A sophisticated example on how to build an ecommerce store based on Restate using the grpc-based Typescript SDK.
[Ecommerce store](typescript/ecommerce-store): An ecommerce store completely built on top of Restate
```shell
# Download the example
EXAMPLE=typescript-ecommerce-store; wget https://github.com/restatedev/examples/releases/latest/download/$EXAMPLE.zip && unzip $EXAMPLE.zip -d $EXAMPLE && rm $EXAMPLE.zip
```

## Joining the community

Expand Down Expand Up @@ -80,27 +134,8 @@ This should give you the following output in case of the ticket reservation exam

## Releasing (for Restate developers)

In order to create a new release, push a tag of the form `vX.Y.Z`.
Then [create a release via GitHub](https://github.com/restatedev/example-lambda-ts-greeter/releases).

### Upgrading the SDK dependency (for Restate developers)

In order to upgrade/update the SDK dependency you have to run:
Before releasing, trigger the "pre-release" workflow to update sdk versions. This automatically creates a pull request, which must be manually merged.

**Major version** change:
Once the repo is ready for the release, push a tag of the form `vX.Y.Z`.

```shell
npm --prefix typescript install @restatedev/restate-sdk@^Z.Y.X --workspaces
```

**Minor/patch version** change:

```shell
npm --prefix typescript update @restatedev/restate-sdk --workspaces
```

Now check whether the examples are still building:

```shell
npm --prefix typescript run verify --workspaces
```
This triggers a workflow that [creates a draft release](https://github.com/restatedev/examples/releases) on Github, which you need to approve to finalize it.
35 changes: 35 additions & 0 deletions java/hello-world-http/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build

.idea
*.iml

# Unignore the gradle wrapper
!gradle/wrapper/gradle-wrapper.jar
35 changes: 35 additions & 0 deletions java/hello-world-http/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Hello world - Java HTTP example

Sample project configuration of a Restate service using the Java interface and HTTP server. It contains:

* [`build.gradle.kts`](build.gradle.kts)
* [Service interface definition `greeter.proto`](src/main/proto/greeter.proto)
* [Service class implementation `Greeter`](src/main/java/dev/restate/sdk/examples/Greeter.java)
* [Test `GreeterTest`](src/test/java/dev/restate/sdk/examples/GreeterTest.java)
* [Logging configuration](src/main/resources/log4j2.properties)

## Download the example

```shell
EXAMPLE=java-hello-world-http; wget https://github.com/restatedev/examples/releases/latest/download/$EXAMPLE.zip && unzip $EXAMPLE.zip -d $EXAMPLE && rm $EXAMPLE.zip
slinkydeveloper marked this conversation as resolved.
Show resolved Hide resolved
```

## Running the example

You can run the Java greeter service via:

```shell
./gradlew run
```

Or from the IDE UI.
slinkydeveloper marked this conversation as resolved.
Show resolved Hide resolved

## Running the tests

You can run the tests either via:

```shell
./gradlew check
```

Or from the IDE UI.
Loading
Loading