From c8207a0682b9926176abb5b9bf52434977f81ab2 Mon Sep 17 00:00:00 2001 From: Giselle van Dongen Date: Tue, 23 Apr 2024 14:09:55 +0200 Subject: [PATCH] Add kotlin github action checks, and make Kotlin code snippets build (#356) --- .github/workflows/pre-release.yml | 12 ++++++++++++ .github/workflows/test-build.yml | 9 ++++++++- .../kotlin/src/main/kotlin/develop/Greeter.kt | 1 - .../src/main/kotlin/develop/ServingVirtualThreads.kt | 6 +++--- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 599ccc37..b6769da1 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -114,6 +114,18 @@ jobs: arguments: check build-root-directory: code_snippets/java + # Upgrade Kotlin code snippets if new version is provided + - name: Find and replace restateVersion in build.gradle.kts for Kotlin code snippets + if: github.event.inputs.sdkJavaVersion != '' + run: sed -i 's/val restateVersion = "[0-9A-Z.-]*"/val restateVersion = "${{ inputs.sdkJavaVersion }}"/' code_snippets/kotlin/build.gradle.kts + + # Check Kotlin code snippets + - name: Test Kotlin code snippets + uses: gradle/gradle-build-action@v2 + with: + arguments: check + build-root-directory: code_snippets/kotlin + - name: Create Pull Request uses: peter-evans/create-pull-request@v5 with: diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 019d224c..3ef391f4 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -52,4 +52,11 @@ jobs: uses: gradle/gradle-build-action@v2 with: arguments: check - build-root-directory: code_snippets/java \ No newline at end of file + build-root-directory: code_snippets/java + + # Check Java code snippets + - name: Test Kotlin code snippets + uses: gradle/gradle-build-action@v2 + with: + arguments: check + build-root-directory: code_snippets/kotlin \ No newline at end of file diff --git a/code_snippets/kotlin/src/main/kotlin/develop/Greeter.kt b/code_snippets/kotlin/src/main/kotlin/develop/Greeter.kt index 3071953c..80ce832f 100644 --- a/code_snippets/kotlin/src/main/kotlin/develop/Greeter.kt +++ b/code_snippets/kotlin/src/main/kotlin/develop/Greeter.kt @@ -29,6 +29,5 @@ fun main() { RestateHttpEndpointBuilder .builder() .bind(Greeter()) - // Start the Restate Endpoint HTTP Server .buildAndListen() } diff --git a/code_snippets/kotlin/src/main/kotlin/develop/ServingVirtualThreads.kt b/code_snippets/kotlin/src/main/kotlin/develop/ServingVirtualThreads.kt index d8e96f79..5c1ff6c3 100644 --- a/code_snippets/kotlin/src/main/kotlin/develop/ServingVirtualThreads.kt +++ b/code_snippets/kotlin/src/main/kotlin/develop/ServingVirtualThreads.kt @@ -1,7 +1,7 @@ package develop import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder -import dev.restate.sdk.kotlin.Component +import dev.restate.sdk.kotlin.Service import java.util.concurrent.Executors import kotlinx.coroutines.asCoroutineDispatcher @@ -10,9 +10,9 @@ class ServingVirtualThreads { // builder.bind( // This is the class generated by the annotation processor - GreeterBindableComponent( + GreeterBindableService( Greeter(), - Component.Options( + Service.Options( coroutineContext = Executors.newVirtualThreadPerTaskExecutor().asCoroutineDispatcher() ) )