Skip to content

Commit

Permalink
Template rust (#178)
Browse files Browse the repository at this point in the history
* First Rust template

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>

* Add Rust infra for examples

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>

---------

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
  • Loading branch information
slinkydeveloper authored Aug 19, 2024
1 parent 764e469 commit f576c48
Show file tree
Hide file tree
Showing 10 changed files with 1,654 additions and 2 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ on:
description: 'sdk-python version (without prepending v). Leave empty if you do not want to update it.'
required: false
type: string
sdkRustVersion:
description: 'sdk-rust version (without 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."
required: false
Expand Down Expand Up @@ -101,11 +105,25 @@ jobs:
if: github.event.inputs.sdkGoVersion != ''
run: ./.tools/run_go_tests.sh

# Bump Rust SDK
- name: Install Rust toolchain
if: github.event.inputs.sdkRustVersion != ''
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
rustflags: ""
- name: Bump sdk-rust
if: github.event.inputs.sdkRustVersion != ''
run: ./.tools/update_rust_examples.sh ${{ inputs.sdkRustVersion }}
- name: Run Rust tests
if: github.event.inputs.sdkRustVersion != ''
run: ./.tools/run_rust_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) }}${{ 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) }}"
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) }}${{ inputs.sdkRustVersion != '' && format('SDK-Rust {0} ', inputs.sdkRustVersion) }}"
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) }}${{ inputs.sdkGoVersion != '' && format('SDK-Go {0} ', inputs.sdkGoVersion) }}${{ inputs.sdkRustVersion != '' && format('SDK-Rust {0} ', inputs.sdkRustVersion) }}"
add-paths: |
**/package.json
**/package-lock.json
Expand All @@ -114,3 +132,5 @@ jobs:
**/requirements.txt
**/go.mod
**/go.sum
**/Cargo.lock
**/Cargo.toml
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
typescript-cloudflare-worker-hello-world.zip
typescript-deno-hello-world.zip
go-hello-world.zip
rust-hello-world.zip
kotlin-hello-world-lambda-cdk.zip
go-tour-of-restate.zip
java-tour-of-restate.zip
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ on:
branches: [main]

jobs:
build-rust:
# prevent from running on forks
if: github.repository_owner == 'restatedev'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
rustflags: ""
- name: Run tests
run: ./.tools/run_rust_tests.sh

build-jvm:
# prevent from running on forks
if: github.repository_owner == 'restatedev'
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 @@ -24,6 +24,7 @@ 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/rust rust-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
12 changes: 12 additions & 0 deletions .tools/run_rust_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

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

function cargo_build_check() {
pushd $1
cargo clippy
popd
}

cargo_build_check $PROJECT_ROOT/templates/rust
13 changes: 13 additions & 0 deletions .tools/update_rust_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

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

function bump_rust_sdk() {
pushd $1
cargo update restate-sdk@$NEW_VERSION
popd
}

bump_rust_sdk $PROJECT_ROOT/templates/rust
11 changes: 11 additions & 0 deletions templates/rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

Loading

0 comments on commit f576c48

Please sign in to comment.