diff --git a/.github/workflows/gradle-main.yml b/.github/workflows/gradle-main.yml index a9664d656..de72755c1 100644 --- a/.github/workflows/gradle-main.yml +++ b/.github/workflows/gradle-main.yml @@ -13,8 +13,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ macos-latest ] - target: [ macosX64, iosX64, tvosX64, watchosX86 ] + os: [ macos-11 ] + target: [ macosX64, iosX64, tvosX64, watchosX64 ] jvm: [ 11 ] include: - os: windows-latest @@ -99,7 +99,7 @@ jobs: build: strategy: matrix: - os: [ macos-latest, ubuntu-latest, windows-latest ] + os: [ macos-11, ubuntu-latest, windows-latest ] fail-fast: false runs-on: ${{ matrix.os }} @@ -130,7 +130,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] + os: [ ubuntu-latest, macos-11, windows-latest ] fail-fast: false steps: diff --git a/.github/workflows/gradle-pr.yml b/.github/workflows/gradle-pr.yml index 34b370f16..0432b7119 100644 --- a/.github/workflows/gradle-pr.yml +++ b/.github/workflows/gradle-pr.yml @@ -8,8 +8,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ macos-latest ] - target: [ macosX64, iosX64, tvosX64, watchosX86 ] + os: [ macos-11 ] + target: [ macosX64, iosX64, tvosX64, watchosX64 ] jvm: [ 11 ] include: - os: windows-latest @@ -94,7 +94,7 @@ jobs: build: strategy: matrix: - os: [ macos-latest, ubuntu-latest, windows-latest ] + os: [ macos-11, ubuntu-latest, windows-latest ] fail-fast: false runs-on: ${{ matrix.os }} diff --git a/.github/workflows/gradle-release.yml b/.github/workflows/gradle-release.yml index 597f56034..b6500cd08 100644 --- a/.github/workflows/gradle-release.yml +++ b/.github/workflows/gradle-release.yml @@ -11,7 +11,7 @@ jobs: build: strategy: matrix: - os: [ macos-latest, ubuntu-latest, windows-latest ] + os: [ macos-11, ubuntu-latest, windows-latest ] fail-fast: false runs-on: ${{ matrix.os }} @@ -42,7 +42,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] + os: [ ubuntu-latest, macos-11, windows-latest ] fail-fast: false steps: diff --git a/.github/workflows/publish-branch.yml b/.github/workflows/publish-branch.yml index 443774a15..a14a7a5e0 100644 --- a/.github/workflows/publish-branch.yml +++ b/.github/workflows/publish-branch.yml @@ -6,7 +6,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] + os: [ ubuntu-latest, macos-11, windows-latest ] fail-fast: false steps: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 9f9ddc1b4..efc4e55a1 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -7,8 +7,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ macos-latest ] - target: [ macosX64, iosX64, tvosX64, watchosX86 ] + os: [ macos-11 ] + target: [ macosX64, iosX64, tvosX64, watchosX64 ] jvm: [ 11 ] include: - os: windows-latest diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts index 51c55826a..13914a342 100644 --- a/benchmarks/build.gradle.kts +++ b/benchmarks/build.gradle.kts @@ -14,6 +14,8 @@ * limitations under the License. */ +import kotlinx.benchmark.gradle.* +import org.gradle.kotlin.dsl.benchmark import org.jetbrains.kotlin.gradle.plugin.mpp.* plugins { @@ -26,6 +28,8 @@ val rsocketJavaVersion: String by rootProject val kotlinxCoroutinesVersion: String by rootProject val kotlinxBenchmarkVersion: String by rootProject +val jmhVersionOverride: String by rootProject + kotlin { val jvm = jvm() //common jvm source set val kotlinJvm = jvm("kotlin") //kotlin benchmark @@ -70,6 +74,8 @@ benchmark { register("kotlin") register("java") } + + targets.withType { jmhVersion = jmhVersionOverride } } tasks.register("jmhProfilers") { diff --git a/benchmarks/src/jvmMain/kotlin/io/rsocket/kotlin/benchmarks/RSocketBenchmark.kt b/benchmarks/src/jvmMain/kotlin/io/rsocket/kotlin/benchmarks/RSocketBenchmark.kt index 25ee84459..dfb5800de 100644 --- a/benchmarks/src/jvmMain/kotlin/io/rsocket/kotlin/benchmarks/RSocketBenchmark.kt +++ b/benchmarks/src/jvmMain/kotlin/io/rsocket/kotlin/benchmarks/RSocketBenchmark.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:OptIn(DelicateCoroutinesApi::class) + package io.rsocket.kotlin.benchmarks import kotlinx.coroutines.* diff --git a/build.gradle.kts b/build.gradle.kts index bd73ed7c3..03a63cfc1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -57,6 +57,7 @@ val Project.publicationNames: Array subprojects { tasks.whenTaskAdded { if (name.endsWith("test", ignoreCase = true)) onlyIf { !rootProject.hasProperty("skipTests") } + if (name.startsWith("link", ignoreCase = true)) onlyIf { !rootProject.hasProperty("skipLink") } } plugins.withId("org.jetbrains.kotlin.multiplatform") { @@ -67,7 +68,9 @@ subprojects { project.name == "rsocket-transport-ktor-server" || //server is jvm only project.name == "rsocket-test-server" //windows target isn't supported by ktor-network - val supportMingw = project.name != "rsocket-transport-ktor" && project.name != "rsocket-transport-ktor-client" + val supportMingw = + project.name != "rsocket-transport-ktor" && + project.name != "rsocket-transport-ktor-client" if (!isAutoConfigurable) return@configure @@ -105,12 +108,15 @@ subprojects { } //native targets configuration - val hostTargets = listOfNotNull(linuxX64(), macosX64(), if (supportMingw) mingwX64() else null) - - val iosTargets = listOf(iosArm32(), iosArm64(), iosX64()) - val tvosTargets = listOf(tvosArm64(), tvosX64()) - val watchosTargets = listOf(watchosArm32(), watchosArm64(), watchosX86()) - val nativeTargets = hostTargets + iosTargets + tvosTargets + watchosTargets + val linuxTargets = listOf(linuxX64()) + val mingwTargets = if (supportMingw) listOf(mingwX64()) else emptyList() + val macosTargets = listOf(macosX64(), macosArm64()) + val iosTargets = listOf(iosArm32(), iosArm64(), iosX64(), iosSimulatorArm64()) + val tvosTargets = listOf(tvosArm64(), tvosX64(), tvosSimulatorArm64()) + val watchosTargets = + listOf(watchosArm32(), watchosArm64(), watchosX86(), watchosX64(), watchosSimulatorArm64()) + val darwinTargets = macosTargets + iosTargets + tvosTargets + watchosTargets + val nativeTargets = darwinTargets + linuxTargets + mingwTargets val nativeMain by sourceSets.creating { dependsOn(sourceSets["commonMain"]) @@ -149,8 +155,6 @@ subprojects { sourceSets.all { languageSettings.apply { progressiveMode = true - languageVersion = "1.5" - apiVersion = "1.5" optIn("kotlin.RequiresOptIn") diff --git a/gradle.properties b/gradle.properties index d4936647f..5514b3e6d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,44 +13,29 @@ # See the License for the specific language governing permissions and # limitations under the License. # - #Project group=io.rsocket.kotlin version=0.14.0 - #Versions -kotlinVersion=1.5.31 -ktorVersion=1.6.4 +kotlinVersion=1.6.0 +ktorVersion=1.6.7 kotlinxCoroutinesVersion=1.5.2-native-mt -kotlinxAtomicfuVersion=0.16.3 -kotlinxSerializationVersion=1.3.0 -kotlinxBenchmarkVersion=0.3.1 +kotlinxAtomicfuVersion=0.17.0 +kotlinxSerializationVersion=1.3.1 +kotlinxBenchmarkVersion=0.4.0 kotlinxNodejsVersion=0.0.7 rsocketJavaVersion=1.1.1 -turbineVersion=0.6.1 -artifactoryVersion=4.24.20 +turbineVersion=0.7.0 +artifactoryVersion=4.25.1 versionUpdatesVersion=0.39.0 gradleEnterpriseVersion=3.4.1 - +jmhVersionOverride=1.33 #Kotlin -#kotlin.code.style=official -kotlin.caching.enabled=true -kotlin.incremental=true -kotlin.incremental.multiplatform=true +kotlin.js.compiler=both kotlin.mpp.stability.nowarn=true - -#HMPP support kotlin.mpp.enableGranularSourceSetsMetadata=true -kotlin.mpp.enableCompatibilityMetadataVariant=true - -#JS and Native flags -kotlin.js.compiler=both kotlin.native.enableDependencyPropagation=false kotlin.native.ignoreIncorrectDependencies=true -kotlin.native.ignoreDisabledTargets=true -kotlin.native.distribution.type=prebuilt - - #Gradle org.gradle.parallel=true org.gradle.caching=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a254..84d1f85fd 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/rsocket-core/src/commonMain/kotlin/io/rsocket/kotlin/keepalive/KeepAlive.kt b/rsocket-core/src/commonMain/kotlin/io/rsocket/kotlin/keepalive/KeepAlive.kt index 59198fde5..9c17fc1b9 100644 --- a/rsocket-core/src/commonMain/kotlin/io/rsocket/kotlin/keepalive/KeepAlive.kt +++ b/rsocket-core/src/commonMain/kotlin/io/rsocket/kotlin/keepalive/KeepAlive.kt @@ -18,11 +18,11 @@ package io.rsocket.kotlin.keepalive import kotlin.native.concurrent.* import kotlin.time.* +import kotlin.time.Duration.Companion.seconds -@ExperimentalTime public fun KeepAlive( - interval: Duration = Duration.seconds(20), - maxLifetime: Duration = Duration.seconds(90) + interval: Duration = 20.seconds, + maxLifetime: Duration = 90.seconds ): KeepAlive = KeepAlive( intervalMillis = interval.toInt(DurationUnit.MILLISECONDS), maxLifetimeMillis = maxLifetime.toInt(DurationUnit.MILLISECONDS) diff --git a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/core/RSocketTest.kt b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/core/RSocketTest.kt index d2209a2b4..548c975ee 100644 --- a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/core/RSocketTest.kt +++ b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/core/RSocketTest.kt @@ -28,7 +28,7 @@ import kotlinx.coroutines.* import kotlinx.coroutines.channels.* import kotlinx.coroutines.flow.* import kotlin.test.* -import kotlin.time.* +import kotlin.time.Duration.Companion.seconds class RSocketTest : SuspendTest, TestWithLeakCheck { @@ -63,7 +63,7 @@ class RSocketTest : SuspendTest, TestWithLeakCheck { return RSocketConnector { loggerFactory = LoggerFactory { PrintLogger.withLevel(LoggingLevel.DEBUG).logger("CLIENT |$it") } connectionConfig { - keepAlive = KeepAlive(Duration.seconds(1000), Duration.seconds(1000)) + keepAlive = KeepAlive(1000.seconds, 1000.seconds) } }.connect(localServer) } @@ -144,7 +144,7 @@ class RSocketTest : SuspendTest, TestWithLeakCheck { requester.requestStream(payload("HELLO")) .flowOn(PrefetchStrategy(10, 0)) .withIndex() - .onEach { if (it.index == 23) throw error("oops") } + .onEach { if (it.index == 23) error("oops") } .map { it.value } .test { repeat(23) { diff --git a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/frame/SetupFrameTest.kt b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/frame/SetupFrameTest.kt index 4533be2a0..53e1dc8ac 100644 --- a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/frame/SetupFrameTest.kt +++ b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/frame/SetupFrameTest.kt @@ -23,12 +23,12 @@ import io.rsocket.kotlin.keepalive.* import io.rsocket.kotlin.payload.* import io.rsocket.kotlin.test.* import kotlin.test.* -import kotlin.time.* +import kotlin.time.Duration.Companion.seconds class SetupFrameTest : TestWithLeakCheck { private val version = Version.Current - private val keepAlive = KeepAlive(Duration.seconds(10), Duration.seconds(500)) + private val keepAlive = KeepAlive(10.seconds, 500.seconds) private val payloadMimeType = PayloadMimeType(WellKnownMimeType.ApplicationOctetStream, CustomMimeType("mime")) @Test diff --git a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt index ffb872aa1..367c1b43f 100644 --- a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt +++ b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt @@ -26,7 +26,7 @@ import kotlinx.coroutines.* import kotlinx.coroutines.channels.* import kotlinx.coroutines.flow.* import kotlin.test.* -import kotlin.time.* +import kotlin.time.Duration.Companion.seconds class RSocketRequesterTest : TestWithConnection(), TestWithLeakCheck { private lateinit var requester: RSocket @@ -40,7 +40,7 @@ class RSocketRequesterTest : TestWithConnection(), TestWithLeakCheck { maxFragmentSize = 0, interceptors = InterceptorsBuilder().build(), connectionConfig = ConnectionConfig( - keepAlive = KeepAlive(Duration.seconds(1000), Duration.seconds(1000)), + keepAlive = KeepAlive(1000.seconds, 1000.seconds), payloadMimeType = DefaultPayloadMimeType, setupPayload = Payload.Empty ) diff --git a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/keepalive/KeepAliveTest.kt b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/keepalive/KeepAliveTest.kt index a9bd24727..c34562411 100644 --- a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/keepalive/KeepAliveTest.kt +++ b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/keepalive/KeepAliveTest.kt @@ -25,12 +25,13 @@ import io.rsocket.kotlin.payload.* import io.rsocket.kotlin.test.* import kotlinx.coroutines.* import kotlin.test.* -import kotlin.time.* +import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.seconds class KeepAliveTest : TestWithConnection(), TestWithLeakCheck { private suspend fun requester( - keepAlive: KeepAlive = KeepAlive(Duration.milliseconds(100), Duration.seconds(1)) + keepAlive: KeepAlive = KeepAlive(100.milliseconds, 1.seconds) ): RSocket = connect( connection = connection, isServer = false, @@ -54,14 +55,14 @@ class KeepAliveTest : TestWithConnection(), TestWithLeakCheck { @Test fun rSocketNotCanceledOnPresentKeepAliveTicks() = test { - val rSocket = requester(KeepAlive(Duration.seconds(100), Duration.seconds(100))) + val rSocket = requester(KeepAlive(100.seconds, 100.seconds)) connection.launch { repeat(50) { - delay(Duration.milliseconds(100)) + delay(100.milliseconds) connection.sendToReceiver(KeepAliveFrame(true, 0, ByteReadPacket.Empty)) } } - delay(Duration.seconds(1.5)) + delay(1.5.seconds) assertTrue(rSocket.isActive) connection.test { repeat(50) { @@ -72,10 +73,10 @@ class KeepAliveTest : TestWithConnection(), TestWithLeakCheck { @Test fun requesterRespondsToKeepAlive() = test { - requester(KeepAlive(Duration.seconds(100), Duration.seconds(100))) + requester(KeepAlive(100.seconds, 100.seconds)) connection.launch { while (isActive) { - delay(Duration.milliseconds(100)) + delay(100.milliseconds) connection.sendToReceiver(KeepAliveFrame(true, 0, ByteReadPacket.Empty)) } } diff --git a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/metadata/CompositeMetadataTest.kt b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/metadata/CompositeMetadataTest.kt index c55ed6760..d861811c0 100644 --- a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/metadata/CompositeMetadataTest.kt +++ b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/metadata/CompositeMetadataTest.kt @@ -173,7 +173,7 @@ class CompositeMetadataTest : TestWithLeakCheck { assertFails { buildCompositeMetadata { add(WellKnownMimeType.ApplicationAvro, packet) - throw error("") + error("") } } assertTrue(packet.isEmpty) diff --git a/rsocket-test/src/commonMain/kotlin/io/rsocket/kotlin/test/SuspendTest.kt b/rsocket-test/src/commonMain/kotlin/io/rsocket/kotlin/test/SuspendTest.kt index aabca398c..eb09252c8 100644 --- a/rsocket-test/src/commonMain/kotlin/io/rsocket/kotlin/test/SuspendTest.kt +++ b/rsocket-test/src/commonMain/kotlin/io/rsocket/kotlin/test/SuspendTest.kt @@ -19,12 +19,14 @@ package io.rsocket.kotlin.test import kotlinx.coroutines.* import kotlin.coroutines.* import kotlin.time.* +import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.seconds interface SuspendTest { - val testTimeout: Duration get() = Duration.minutes(1) + val testTimeout: Duration get() = 1.minutes - val beforeTimeout: Duration get() = Duration.seconds(10) - val afterTimeout: Duration get() = Duration.seconds(10) + val beforeTimeout: Duration get() = 10.seconds + val afterTimeout: Duration get() = 10.seconds val debug: Boolean get() = true //change to turn off debug logs locally (useful for CI) diff --git a/rsocket-test/src/commonMain/kotlin/io/rsocket/kotlin/test/TransportTest.kt b/rsocket-test/src/commonMain/kotlin/io/rsocket/kotlin/test/TransportTest.kt index 03c2059db..ceb61be94 100644 --- a/rsocket-test/src/commonMain/kotlin/io/rsocket/kotlin/test/TransportTest.kt +++ b/rsocket-test/src/commonMain/kotlin/io/rsocket/kotlin/test/TransportTest.kt @@ -25,9 +25,11 @@ import kotlinx.coroutines.* import kotlinx.coroutines.flow.* import kotlin.test.* import kotlin.time.* +import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.seconds abstract class TransportTest : SuspendTest, TestWithLeakCheck { - override val testTimeout: Duration = Duration.minutes(2) + override val testTimeout: Duration = 2.minutes lateinit var client: RSocket //should be assigned in `before` @@ -56,13 +58,13 @@ abstract class TransportTest : SuspendTest, TestWithLeakCheck { } @Test - fun requestChannel0() = test(Duration.seconds(10)) { + fun requestChannel0() = test(10.seconds) { val list = client.requestChannel(payload(0), emptyFlow()).toList() assertTrue(list.isEmpty()) } @Test - fun requestChannel1() = test(Duration.seconds(10)) { + fun requestChannel1() = test(10.seconds) { val list = client.requestChannel(payload(0), flowOf(payload(0))).onEach { it.close() }.toList() assertEquals(1, list.size) } @@ -72,7 +74,8 @@ abstract class TransportTest : SuspendTest, TestWithLeakCheck { val request = flow { repeat(3) { emit(payload(it)) } } - val list = client.requestChannel(payload(0), request).flowOn(PrefetchStrategy(3, 0)).onEach { it.close() }.toList() + val list = + client.requestChannel(payload(0), request).flowOn(PrefetchStrategy(3, 0)).onEach { it.close() }.toList() assertEquals(3, list.size) } @@ -106,7 +109,8 @@ abstract class TransportTest : SuspendTest, TestWithLeakCheck { val request = flow { repeat(200_000) { emit(payload(it)) } } - val list = client.requestChannel(payload(0), request).flowOn(PrefetchStrategy(10000, 0)).onEach { it.close() }.toList() + val list = + client.requestChannel(payload(0), request).flowOn(PrefetchStrategy(10000, 0)).onEach { it.close() }.toList() assertEquals(200_000, list.size) } @@ -189,7 +193,8 @@ abstract class TransportTest : SuspendTest, TestWithLeakCheck { @Test fun requestStream5() = test { - val list = client.requestStream(payload(3)).flowOn(PrefetchStrategy(5, 0)).take(5).onEach { checkPayload(it) }.toList() + val list = + client.requestStream(payload(3)).flowOn(PrefetchStrategy(5, 0)).take(5).onEach { checkPayload(it) }.toList() assertEquals(5, list.size) } @@ -221,7 +226,7 @@ abstract class TransportTest : SuspendTest, TestWithLeakCheck { loggerFactory = NoopLogger connectionConfig { - keepAlive = KeepAlive(Duration.minutes(10), Duration.minutes(100)) + keepAlive = KeepAlive(10.minutes, 100.minutes) } }