Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into add-bun-deno-wrangler…
Browse files Browse the repository at this point in the history
…-tests
  • Loading branch information
pcholakov committed Jul 23, 2024
2 parents be9d55e + ece080e commit c40f4da
Show file tree
Hide file tree
Showing 12 changed files with 159 additions and 9 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ on:
workflow_dispatch:
inputs:
restateVersion:
description: 'Restate runtime version (without prepending v). Leave empty if you do not want to update it.'
description: "Restate runtime version (without prepending v). Leave empty if you do not want to update it."
required: false
type: string
sdkTypescriptVersion:
description: 'sdk-typescript version (without prepending v). Leave empty if you do not want to update it.'
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.'
description: "sdk-java version (without prepending v). Leave empty if you do not want to update it."
required: false
type: string
sdkGoVersion:
description: "sdk-go version (WITH the prepending v). Leave empty if you do not want to update it."
required: false
type: string
cdkVersion:
description: 'cdk version (without prepending v). Leave empty if you do not want to update it.'
description: "cdk version (without prepending v). Leave empty if you do not want to update it."
required: false
type: string

Expand All @@ -40,7 +44,7 @@ jobs:
if: github.event.inputs.sdkTypescriptVersion != ''
with:
node-version: "19.x"
registry-url: 'https://registry.npmjs.org'
registry-url: "https://registry.npmjs.org"
- name: Bump sdk-typescript
if: github.event.inputs.sdkTypescriptVersion != ''
run: ./.tools/update_node_examples.sh ${{ inputs.sdkTypescriptVersion }}
Expand All @@ -55,8 +59,8 @@ jobs:
- uses: actions/setup-java@v3
if: github.event.inputs.sdkJavaVersion != ''
with:
distribution: 'temurin'
java-version: '17'
distribution: "temurin"
java-version: "17"
- name: Setup Gradle
if: github.event.inputs.sdkJavaVersion != ''
uses: gradle/actions/setup-gradle@v3
Expand All @@ -67,13 +71,27 @@ jobs:
if: github.event.inputs.sdkJavaVersion != ''
run: ./.tools/run_jvm_tests.sh

# Bump Go SDK
- uses: actions/setup-go@v5
if: github.event.inputs.sdkGoVersion != ''
with:
go-version: "1.22"
- name: Bump sdk-go
if: github.event.inputs.sdkGoVersion != ''
run: ./.tools/update_go_examples.sh ${{ inputs.sdkGoVersion }}
- name: Run Go tests
if: github.event.inputs.sdkGoVersion != ''
run: ./.tools/run_go_tests.sh

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
title: "[GithubActions] Update Restate ${{ inputs.restateVersion != '' && format('Runtime {0} ', inputs.restateVersion) }}${{ inputs.sdkTypescriptVersion != '' && format('SDK-Typescript {0} ', inputs.sdkTypescriptVersion) }}${{ inputs.sdkJavaVersion != '' && format('SDK-Java {0} ', inputs.sdkJavaVersion) }}${{ inputs.cdkVersion != '' && format('CDK {0} ', inputs.cdkVersion) }}"
title: "[GithubActions] Update Restate ${{ inputs.restateVersion != '' && format('Runtime {0} ', inputs.restateVersion) }}${{ inputs.sdkTypescriptVersion != '' && format('SDK-Typescript {0} ', inputs.sdkTypescriptVersion) }}${{ inputs.sdkJavaVersion != '' && format('SDK-Java {0} ', inputs.sdkJavaVersion) }}${{ inputs.cdkVersion != '' && format('CDK {0} ', inputs.cdkVersion) }}${{ inputs.sdkGoVersion != '' && format('SDK-Go {0} ', inputs.sdkGoVersion) }}"
commit-message: "[GithubActions] Update Restate ${{ inputs.restateVersion != '' && format('Runtime {0} ', inputs.restateVersion) }}${{ inputs.sdkTypescriptVersion != '' && format('SDK-Typescript {0} ', inputs.sdkTypescriptVersion) }}${{ inputs.sdkJavaVersion != '' && format('SDK-Java {0} ', inputs.sdkJavaVersion) }}${{ inputs.cdkVersion != '' && format('CDK {0} ', inputs.cdkVersion) }}"
add-paths: |
**/package.json
**/package-lock.json
**/build.gradle.kts
**/pom.xml
**/go.mod
**/go.sum
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
typescript-bun-hello-world.zip
typescript-cloudflare-worker-hello-world.zip
typescript-deno-hello-world.zip
go-hello-world.zip
kotlin-hello-world-lambda-cdk.zip
java-tour-of-restate.zip
typescript-tour-of-restate.zip
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,32 @@ jobs:
- name: Run tests
run: ./.tools/run_altjs_tests.sh

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

steps:
- uses: actions/checkout@v3

- name: Use Go ${{ matrix.go-version }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Run tests
run: ./.tools/run_go_tests.sh

build-py:
# prevent from running on forks
if: github.repository_owner == 'restatedev'
runs-on: ubuntu-latest
strategy:
matrix:
python: [ "3.12" ]
python: ["3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .tools/prepare_release_zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ create_release_zip templates/typescript typescript-hello-world
create_release_zip templates/bun typescript-bun-hello-world
create_release_zip templates/cloudflare-worker typescript-cloudflare-worker-hello-world
create_release_zip templates/deno typescript-deno-hello-world
create_release_zip templates/go go-hello-world
create_release_zip templates/typescript-lambda-cdk typescript-hello-world-lambda-cdk
create_release_zip templates/kotlin-gradle-lambda-cdk kotlin-hello-world-lambda-cdk
create_release_zip templates/python python-hello-world
Expand Down
13 changes: 13 additions & 0 deletions .tools/run_go_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

SELF_PATH=${BASH_SOURCE[0]:-"$(command -v -- "$0")"}
PROJECT_ROOT="$(dirname "$SELF_PATH")/.."

function go_build_check() {
pushd $1
go build -o /dev/null .
go vet ./...
popd
}

go_build_check $PROJECT_ROOT/templates/go
14 changes: 14 additions & 0 deletions .tools/update_go_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

NEW_VERSION=$1
SELF_PATH=${BASH_SOURCE[0]:-"$(command -v -- "$0")"}
PROJECT_ROOT="$(dirname "$SELF_PATH")/.."

function bump_go_sdk() {
pushd $1
go get github.com/restatedev/sdk-go@$NEW_VERSION
go mod tidy
popd
}

bump_go_sdk $PROJECT_ROOT/templates/go
1 change: 1 addition & 0 deletions templates/go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go
9 changes: 9 additions & 0 deletions templates/go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Hello world - Go example

Sample project configuration of a Restate service using the Go SDK.

You can run locally with `go run .` and register to Restate with
`restate dep add http://localhost:9080`. Then you can invoke with `curl localhost:8080/Greeter/Greet --json '"hello"'`.

You can build a docker image using [ko](https://github.com/ko-build/ko):
`ko build --platform=all`
14 changes: 14 additions & 0 deletions templates/go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module github.com/restatedev/examples/templates/go

go 1.22.5

require github.com/restatedev/sdk-go v0.9.1

require (
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
)
26 changes: 26 additions & 0 deletions templates/go/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/restatedev/sdk-go v0.9.1 h1:IWn+f3t8ow996U47nnMcFQwP7Yn8X35IAIdKHHZC504=
github.com/restatedev/sdk-go v0.9.1/go.mod h1:wv6BuURHPiFOe5lomBGA6VETSWvAv8iLIKWBY7JUFSU=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14 changes: 14 additions & 0 deletions templates/go/greeter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"fmt"

restate "github.com/restatedev/sdk-go"
)

// Greeter is a struct which represents a Restate service; reflection will turn exported methods into service handlers
type Greeter struct{}

func (Greeter) Greet(ctx restate.Context, greeting string) (string, error) {
return fmt.Sprintf("%s!", greeting), nil
}
20 changes: 20 additions & 0 deletions templates/go/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"context"
"log/slog"
"os"

restate "github.com/restatedev/sdk-go"
"github.com/restatedev/sdk-go/server"
)

func main() {
server := server.NewRestate().
Bind(restate.Service(Greeter{}))

if err := server.Start(context.Background(), ":9080"); err != nil {
slog.Error("application exited unexpectedly", "err", err.Error())
os.Exit(1)
}
}

0 comments on commit c40f4da

Please sign in to comment.