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

Support all K/N targets and Wasm #281

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 1 addition & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
fail-fast: false
matrix:
os: [ 'ubuntu-latest' ]
target: [ 'jvm', 'jvm11', 'jvm17', 'jvm21', 'js', 'native' ]
target: [ 'jvm', 'jvm11', 'jvm17', 'jvm21', 'web', 'native' ]
include:
- os: 'macos-latest'
target: 'macos'
Expand All @@ -50,7 +50,6 @@ jobs:
- uses: ./.github/actions/setup-gradle

- run: ./gradlew ${{ matrix.target }}Test --continue
timeout-minutes: 30

- if: always() && !cancelled()
uses: actions/upload-artifact@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024 the original author or authors.
* Copyright 2015-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.gradle.*
import org.jetbrains.kotlin.gradle.plugin.*
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import org.jetbrains.kotlin.gradle.targets.js.ir.*
import org.jetbrains.kotlin.gradle.targets.js.testing.*
import org.jetbrains.kotlin.gradle.targets.jvm.*
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.*
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
Expand All @@ -32,15 +33,30 @@ plugins {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
compilerOptions {
// because of INVISIBLE_REFERENCE suppression - will be removed after migration to kotlinx.io
if (project.name != "rsocket-test") {
allWarningsAsErrors.set(true)
}
allWarningsAsErrors.set(true)
progressiveMode.set(true)
freeCompilerArgs.add("-Xrender-internal-diagnostic-names")
optIn.addAll(OptIns.ExperimentalSubclassOptIn)
}

applyDefaultHierarchyTemplate {
common {
group("nonJvm") {
group("nonConcurrent")
group("native")
}
group("concurrent") {
withJvm()
group("native")
}
group("nonConcurrent") {
withJs()
withWasmJs()
withWasmWasi()
}
}
}

sourceSets.configureEach {
languageSettings {
if (name.contains("test", ignoreCase = true)) {
Expand Down Expand Up @@ -103,6 +119,12 @@ registerTestAggregationTask(
targetFilter = { it.platformType == KotlinPlatformType.jvm }
)

registerTestAggregationTask(
name = "webTest",
taskDependencies = { tasks.withType<KotlinJsTest>() },
targetFilter = { it.platformType == KotlinPlatformType.js || it.platformType == KotlinPlatformType.wasm }
)

registerTestAggregationTask(
name = "nativeTest",
taskDependencies = { tasks.withType<KotlinNativeTest>().matching { it.enabled } },
Expand Down
53 changes: 37 additions & 16 deletions build-logic/src/main/kotlin/rsocketbuild/targets.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024 the original author or authors.
* Copyright 2015-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,9 +18,21 @@ package rsocketbuild

import org.gradle.jvm.toolchain.*
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.*
import org.jetbrains.kotlin.gradle.dsl.*

fun KotlinMultiplatformExtension.appleTargets() {
fun KotlinMultiplatformExtension.allTargets(
supportsWasi: Boolean = true,
supportsBrowser: Boolean = true,
) {
jvmTarget()
jsTarget(supportsBrowser = supportsBrowser)
wasmJsTarget(supportsBrowser = supportsBrowser)
if (supportsWasi) wasmWasiTarget()
nativeTargets()
}

fun KotlinMultiplatformExtension.nativeTargets() {
macosX64()
macosArm64()

Expand All @@ -32,29 +44,20 @@ fun KotlinMultiplatformExtension.appleTargets() {
watchosArm32()
watchosArm64()
watchosSimulatorArm64()
// https://youtrack.jetbrains.com/issue/KTOR-6368, supported by kotlinx-io
// watchosDeviceArm64()
watchosDeviceArm64()

tvosX64()
tvosArm64()
tvosSimulatorArm64()
}

fun KotlinMultiplatformExtension.nixTargets() {
appleTargets()
linuxX64()
linuxArm64()
}

fun KotlinMultiplatformExtension.nativeTargets() {
nixTargets()
mingwX64()

// not supported by ktor, supported by kotlinx-io
// androidNativeX64()
// androidNativeX86()
// androidNativeArm64()
// androidNativeArm32()
androidNativeX64()
androidNativeX86()
androidNativeArm64()
androidNativeArm32()
}

fun KotlinMultiplatformExtension.jsTarget(
Expand All @@ -67,6 +70,24 @@ fun KotlinMultiplatformExtension.jsTarget(
}
}

@OptIn(ExperimentalWasmDsl::class)
fun KotlinMultiplatformExtension.wasmJsTarget(
supportsNode: Boolean = true,
supportsBrowser: Boolean = true,
) {
wasmJs {
if (supportsNode) nodejs()
if (supportsBrowser) browser()
}
}

@OptIn(ExperimentalWasmDsl::class)
fun KotlinMultiplatformExtension.wasmWasiTarget() {
wasmWasi {
nodejs()
}
}

fun KotlinMultiplatformExtension.jvmTarget(
jdkVersion: Int = 8,
jdkAdditionalTestVersions: Set<Int> = setOf(11, 17, 21),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024 the original author or authors.
* Copyright 2015-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@ pluginManagement {

dependencyResolutionManagement {
repositories {
maven("https://maven.pkg.jetbrains.space/public/p/ktor/eap")
mavenCentral()
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ kotlinx-coroutines = "1.10.1"
kotlinx-benchmark = "0.4.8"
kotlinx-bcv = "0.17.0"

ktor = "3.0.3"
ktor = "3.1.0-eap-1227"

netty = "4.1.117.Final"
netty-quic = "0.0.70.Final"
Expand Down
8 changes: 4 additions & 4 deletions ktor-plugins/ktor-client-rsocket/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024 the original author or authors.
* Copyright 2015-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,9 +23,9 @@ plugins {
description = "rsocket-kotlin ktor client plugin"

kotlin {
jvmTarget()
jsTarget()
nativeTargets()
allTargets(
supportsWasi = false,
)

sourceSets {
commonMain.dependencies {
Expand Down
6 changes: 4 additions & 2 deletions ktor-plugins/ktor-server-rsocket/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ plugins {
description = "rsocket-kotlin ktor server plugin"

kotlin {
jvmTarget()
nixTargets()
allTargets(
supportsWasi = false,
supportsBrowser = false
)

sourceSets {
commonMain.dependencies {
Expand Down
6 changes: 4 additions & 2 deletions ktor-plugins/ktor-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ plugins {
}

kotlin {
jvmTarget()
nixTargets()
allTargets(
supportsWasi = false,
supportsBrowser = false
)

sourceSets {
commonTest.dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ class WebSocketConnectionTest : SuspendTest {
}

override suspend fun before() {
server.start()
server.startSuspend()
delay(1000)
}

override suspend fun after() {
server.stop()
server.stopSuspend()
client.coroutineContext.job.cancelAndJoin()
}

Expand Down
8 changes: 4 additions & 4 deletions ktor-plugins/rsocket-ktor-client/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024 the original author or authors.
* Copyright 2015-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,9 +23,9 @@ plugins {
description = "OLD ARTIFACT - migrate to ktor-client-rsocket"

kotlin {
jvmTarget()
jsTarget()
nativeTargets()
allTargets(
supportsWasi = false,
)

sourceSets {
commonMain.dependencies {
Expand Down
8 changes: 5 additions & 3 deletions ktor-plugins/rsocket-ktor-server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024 the original author or authors.
* Copyright 2015-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,8 +23,10 @@ plugins {
description = "OLD ARTIFACT - migrate to ktor-server-rsocket"

kotlin {
jvmTarget()
nixTargets()
allTargets(
supportsWasi = false,
supportsBrowser = false
)

sourceSets {
commonMain.dependencies {
Expand Down
6 changes: 2 additions & 4 deletions rsocket-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024 the original author or authors.
* Copyright 2015-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,9 +24,7 @@ plugins {
description = "rsocket-kotlin core functionality"

kotlin {
jvmTarget()
jsTarget()
nativeTargets()
allTargets()

sourceSets {
commonMain.dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024 the original author or authors.
* Copyright 2015-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,7 @@ package io.rsocket.kotlin.internal

import io.rsocket.kotlin.*
import io.rsocket.kotlin.frame.*
import io.rsocket.kotlin.internal.io.*
import io.rsocket.kotlin.keepalive.*
import io.rsocket.kotlin.payload.*
import io.rsocket.kotlin.test.*
Expand Down Expand Up @@ -102,7 +103,7 @@ class RSocketRequesterTest : TestWithConnection() {
val flow = requester.requestStream(Payload.Empty).take(2).flowOn(PrefetchStrategy(1, 0))

expectNoEventsIn(200)
flow.launchIn(connection + anotherDispatcher)
flow.launchIn(connection + Dispatchers.IoCompatible)

awaitFrame { frame ->
assertTrue(frame is RequestFrame)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024 the original author or authors.
* Copyright 2015-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@

package io.rsocket.kotlin.transport.internal

import io.rsocket.kotlin.internal.io.*
import io.rsocket.kotlin.test.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
Expand Down Expand Up @@ -62,7 +63,7 @@ class PrioritizationFrameQueueTest : SuspendTest {
@Test
fun testAsyncReceive() = test {
val deferred = CompletableDeferred<Source?>()
launch(anotherDispatcher) {
launch(Dispatchers.IoCompatible) {
deferred.complete(queue.dequeueFrame())
}
delay(100)
Expand Down
Loading
Loading