From 54ee2d4877eee7751e46a98ee54f5c4c30fd80cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mareks=20Ramp=C4=81ns?= <8796159+mr-git@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:51:20 +0300 Subject: [PATCH 1/2] drop Scala 2.12 support and update build infrastructure --- .github/workflows/ci.yml | 5 ++--- build.sbt | 13 +++++++++---- project/Dependencies.scala | 2 +- project/plugins.sbt | 4 ++-- .../cluster/sharding/AdaptiveStrategy.scala | 14 +++++++------- .../cluster/sharding/AddressOf.scala | 4 ++-- .../cluster/sharding/AlwaysRebalanceStrategy.scala | 2 +- .../cluster/sharding/LeastShardsStrategy.scala | 2 +- .../cluster/sharding/MappedStrategy.scala | 10 +++++----- .../cluster/sharding/RebalanceAllStrategy.scala | 2 +- .../cluster/sharding/RemoteNodeStrategy.scala | 2 +- .../cluster/sharding/ShardingStrategy.scala | 4 ++-- .../cluster/sharding/ShardingStrategyProxy.scala | 2 +- .../cluster/sharding/SingleNodeStrategy.scala | 2 +- .../cluster/sharding/AbsoluteAddressSpec.scala | 4 ++-- .../cluster/sharding/AdaptiveStrategySpec.scala | 2 +- .../sharding/AllocationStrategyProxySpec.scala | 6 +++--- .../sharding/AlwaysRebalanceStrategySpec.scala | 4 ++-- .../evolutiongaming/cluster/sharding/IOSuite.scala | 2 +- .../cluster/sharding/LoggingStrategySpec.scala | 2 +- .../cluster/sharding/MappedStrategySpec.scala | 3 ++- .../cluster/sharding/RegionOf.scala | 4 ++-- .../cluster/sharding/SingleNodeStrategySpec.scala | 2 +- 23 files changed, 51 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bce160e..2129ccc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,7 @@ jobs: strategy: matrix: scala: - - 2.13.10 - - 2.12.17 + - 2.13.13 steps: - uses: actions/checkout@v2 @@ -21,7 +20,7 @@ jobs: - name: scala uses: olafurpg/setup-scala@v10 with: - java-version: openjdk@1.11 + java-version: openjdk@1.17 - name: build ${{ matrix.scala }} run: sbt ++${{ matrix.scala }} clean coverage test diff --git a/build.sbt b/build.sbt index 8083511..9e5bf3f 100644 --- a/build.sbt +++ b/build.sbt @@ -4,19 +4,24 @@ name := "sharding-strategy" organization := "com.evolutiongaming" -homepage := Some(new URL("http://github.com/evolution-gaming/sharding-strategy")) +homepage := Some(url("https://github.com/evolution-gaming/sharding-strategy")) startYear := Some(2018) organizationName := "Evolution" -organizationHomepage := Some(url("http://evolution.com")) +organizationHomepage := Some(url("https://evolution.com")) scalaVersion := crossScalaVersions.value.head -crossScalaVersions := Seq("2.13.10", "2.12.17") +crossScalaVersions := Seq("2.13.13") -scalacOptions -= "-Ywarn-unused:params" +scalacOptions := Seq( + "-release:17", + "-Xsource:3", +) + +//scalacOptions -= "-Ywarn-unused:params" publishTo := Some(Resolver.evolutionReleases) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 78ad112..3b937b8 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -2,7 +2,7 @@ import sbt._ object Dependencies { - val scalatest = "org.scalatest" %% "scalatest" % "3.2.9" + val scalatest = "org.scalatest" %% "scalatest" % "3.2.11" val `executor-tools` = "com.evolutiongaming" %% "executor-tools" % "1.0.2" val `cats-helper` = "com.evolutiongaming" %% "cats-helper" % "3.6.0" val `ddata-tools` = "com.evolutiongaming" %% "ddata-tools" % "4.0.0" diff --git a/project/plugins.sbt b/project/plugins.sbt index 6341eb5..dc78e46 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,8 +1,8 @@ addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.11") -addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7") +addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.11") -addSbtPlugin("com.github.sbt" % "sbt-release" % "1.0.15") +addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0") addSbtPlugin("com.evolution" % "sbt-scalac-opts-plugin" % "0.0.9") diff --git a/src/main/scala/com/evolutiongaming/cluster/sharding/AdaptiveStrategy.scala b/src/main/scala/com/evolutiongaming/cluster/sharding/AdaptiveStrategy.scala index d93abf1..b4623ec 100644 --- a/src/main/scala/com/evolutiongaming/cluster/sharding/AdaptiveStrategy.scala +++ b/src/main/scala/com/evolutiongaming/cluster/sharding/AdaptiveStrategy.scala @@ -1,19 +1,19 @@ package com.evolutiongaming.cluster.sharding -import akka.actor._ +import akka.actor.* import akka.cluster.ddata.Replicator.{WriteConsistency, WriteLocal} -import akka.cluster.ddata._ +import akka.cluster.ddata.* import akka.cluster.sharding.ShardRegion import akka.cluster.sharding.ShardRegion.ExtractShardId -import cats.effect.syntax.resource._ +import cats.effect.syntax.resource.* import cats.effect.{Ref, Resource, Sync} -import cats.implicits._ +import cats.implicits.* import cats.{Applicative, FlatMap, Monad, Parallel, ~>} -import com.evolutiongaming.catshelper._ +import com.evolutiongaming.catshelper.* import com.evolutiongaming.cluster.ddata.SafeReplicator import com.evolutiongaming.cluster.sharding.AdaptiveStrategy.Counters -import scala.concurrent.duration._ +import scala.concurrent.duration.* import scala.concurrent.{ExecutionContext, Future} /** @@ -361,7 +361,7 @@ object AdaptiveStrategy { object Ext extends ExtensionId[Ext] { - def createExtension(system: ExtendedActorSystem) = new Ext { + def createExtension(system: ExtendedActorSystem): Ext = new Ext { val replicatorRef = { val settings = ReplicatorSettings(system) val props = Replicator.props(settings) diff --git a/src/main/scala/com/evolutiongaming/cluster/sharding/AddressOf.scala b/src/main/scala/com/evolutiongaming/cluster/sharding/AddressOf.scala index b9f5236..26e61ca 100644 --- a/src/main/scala/com/evolutiongaming/cluster/sharding/AddressOf.scala +++ b/src/main/scala/com/evolutiongaming/cluster/sharding/AddressOf.scala @@ -10,11 +10,11 @@ object AddressOf { def apply(actorSystem: ActorSystem): AddressOf = { val absoluteAddress = AbsoluteAddress(actorSystem) - region: Region => absoluteAddress(region.path.address) + (region: Region) => absoluteAddress(region.path.address) } def const(address: Address): AddressOf = new AddressOf { - def apply(region: Region) = address + def apply(region: Region): Address = address } } diff --git a/src/main/scala/com/evolutiongaming/cluster/sharding/AlwaysRebalanceStrategy.scala b/src/main/scala/com/evolutiongaming/cluster/sharding/AlwaysRebalanceStrategy.scala index 556898f..ad2132b 100644 --- a/src/main/scala/com/evolutiongaming/cluster/sharding/AlwaysRebalanceStrategy.scala +++ b/src/main/scala/com/evolutiongaming/cluster/sharding/AlwaysRebalanceStrategy.scala @@ -2,7 +2,7 @@ package com.evolutiongaming.cluster.sharding import akka.actor.ActorRef import cats.effect.Sync -import cats.implicits._ +import cats.implicits.* import scala.util.Random diff --git a/src/main/scala/com/evolutiongaming/cluster/sharding/LeastShardsStrategy.scala b/src/main/scala/com/evolutiongaming/cluster/sharding/LeastShardsStrategy.scala index b9bf383..eecaee3 100644 --- a/src/main/scala/com/evolutiongaming/cluster/sharding/LeastShardsStrategy.scala +++ b/src/main/scala/com/evolutiongaming/cluster/sharding/LeastShardsStrategy.scala @@ -1,7 +1,7 @@ package com.evolutiongaming.cluster.sharding import cats.Applicative -import cats.implicits._ +import cats.implicits.* object LeastShardsStrategy { diff --git a/src/main/scala/com/evolutiongaming/cluster/sharding/MappedStrategy.scala b/src/main/scala/com/evolutiongaming/cluster/sharding/MappedStrategy.scala index c72bb5b..1c5c76b 100644 --- a/src/main/scala/com/evolutiongaming/cluster/sharding/MappedStrategy.scala +++ b/src/main/scala/com/evolutiongaming/cluster/sharding/MappedStrategy.scala @@ -3,17 +3,17 @@ package com.evolutiongaming.cluster.sharding import akka.actor.{ActorRef, ActorRefFactory, ActorSystem, Address, ExtendedActorSystem, Extension, ExtensionId} import akka.cluster.ddata.Replicator.{ReadConsistency, ReadLocal, WriteConsistency, WriteLocal} -import akka.cluster.ddata._ +import akka.cluster.ddata.* import cats.effect.kernel.Ref import cats.effect.{Resource, Sync} -import cats.implicits._ -import cats.effect.syntax.resource._ +import cats.implicits.* +import cats.effect.syntax.resource.* import cats.{FlatMap, Parallel, ~>} import com.evolutiongaming.catshelper.{FromFuture, ToFuture} import com.evolutiongaming.cluster.ddata.SafeReplicator import scala.concurrent.ExecutionContext -import scala.concurrent.duration._ +import scala.concurrent.duration.* import scala.util.control.NoStackTrace @@ -196,7 +196,7 @@ object MappedStrategy { object Ext extends ExtensionId[Ext] { - def createExtension(system: ExtendedActorSystem) = new Ext { + def createExtension(system: ExtendedActorSystem): Ext = new Ext { val replicatorRef = { val settings = ReplicatorSettings(system) val props = Replicator.props(settings) diff --git a/src/main/scala/com/evolutiongaming/cluster/sharding/RebalanceAllStrategy.scala b/src/main/scala/com/evolutiongaming/cluster/sharding/RebalanceAllStrategy.scala index ebefe6c..0be73df 100644 --- a/src/main/scala/com/evolutiongaming/cluster/sharding/RebalanceAllStrategy.scala +++ b/src/main/scala/com/evolutiongaming/cluster/sharding/RebalanceAllStrategy.scala @@ -1,7 +1,7 @@ package com.evolutiongaming.cluster.sharding import cats.Applicative -import cats.implicits._ +import cats.implicits.* object RebalanceAllStrategy { diff --git a/src/main/scala/com/evolutiongaming/cluster/sharding/RemoteNodeStrategy.scala b/src/main/scala/com/evolutiongaming/cluster/sharding/RemoteNodeStrategy.scala index 03634bb..eec0f1f 100644 --- a/src/main/scala/com/evolutiongaming/cluster/sharding/RemoteNodeStrategy.scala +++ b/src/main/scala/com/evolutiongaming/cluster/sharding/RemoteNodeStrategy.scala @@ -2,7 +2,7 @@ package com.evolutiongaming.cluster.sharding import akka.actor.ActorRef import cats.Applicative -import cats.implicits._ +import cats.implicits.* object RemoteNodeStrategy { diff --git a/src/main/scala/com/evolutiongaming/cluster/sharding/ShardingStrategy.scala b/src/main/scala/com/evolutiongaming/cluster/sharding/ShardingStrategy.scala index f055120..1c964f1 100644 --- a/src/main/scala/com/evolutiongaming/cluster/sharding/ShardingStrategy.scala +++ b/src/main/scala/com/evolutiongaming/cluster/sharding/ShardingStrategy.scala @@ -2,9 +2,9 @@ package com.evolutiongaming.cluster.sharding import akka.cluster.sharding.ShardCoordinator.ShardAllocationStrategy import cats.effect.{Clock, Ref, Sync} -import cats.implicits._ +import cats.implicits.* import cats.{Applicative, FlatMap, Monad, ~>} -import com.evolutiongaming.catshelper.ClockHelper._ +import com.evolutiongaming.catshelper.ClockHelper.* import com.evolutiongaming.catshelper.ToFuture import scala.concurrent.duration.FiniteDuration diff --git a/src/main/scala/com/evolutiongaming/cluster/sharding/ShardingStrategyProxy.scala b/src/main/scala/com/evolutiongaming/cluster/sharding/ShardingStrategyProxy.scala index 65f8a59..b42d143 100644 --- a/src/main/scala/com/evolutiongaming/cluster/sharding/ShardingStrategyProxy.scala +++ b/src/main/scala/com/evolutiongaming/cluster/sharding/ShardingStrategyProxy.scala @@ -2,7 +2,7 @@ package com.evolutiongaming.cluster.sharding import akka.cluster.sharding.ShardCoordinator.ShardAllocationStrategy import cats.FlatMap -import cats.implicits._ +import cats.implicits.* import com.evolutiongaming.catshelper.FromFuture object ShardingStrategyProxy { diff --git a/src/main/scala/com/evolutiongaming/cluster/sharding/SingleNodeStrategy.scala b/src/main/scala/com/evolutiongaming/cluster/sharding/SingleNodeStrategy.scala index b4c0d71..1c15466 100644 --- a/src/main/scala/com/evolutiongaming/cluster/sharding/SingleNodeStrategy.scala +++ b/src/main/scala/com/evolutiongaming/cluster/sharding/SingleNodeStrategy.scala @@ -2,7 +2,7 @@ package com.evolutiongaming.cluster.sharding import akka.actor.Address import cats.Applicative -import cats.implicits._ +import cats.implicits.* object SingleNodeStrategy { diff --git a/src/test/scala/com/evolutiongaming/cluster/sharding/AbsoluteAddressSpec.scala b/src/test/scala/com/evolutiongaming/cluster/sharding/AbsoluteAddressSpec.scala index 56227fa..c88f777 100644 --- a/src/test/scala/com/evolutiongaming/cluster/sharding/AbsoluteAddressSpec.scala +++ b/src/test/scala/com/evolutiongaming/cluster/sharding/AbsoluteAddressSpec.scala @@ -8,8 +8,8 @@ class AbsoluteAddressSpec extends AnyFunSuite with ActorSpec with Matchers { test("AbsoluteAddress") { - def actor() = new Actor { - def receive = PartialFunction.empty + def actor(): Actor = new Actor { + def receive: Actor.Receive = PartialFunction.empty } val props = Props(actor()) diff --git a/src/test/scala/com/evolutiongaming/cluster/sharding/AdaptiveStrategySpec.scala b/src/test/scala/com/evolutiongaming/cluster/sharding/AdaptiveStrategySpec.scala index 7cfc716..401d639 100644 --- a/src/test/scala/com/evolutiongaming/cluster/sharding/AdaptiveStrategySpec.scala +++ b/src/test/scala/com/evolutiongaming/cluster/sharding/AdaptiveStrategySpec.scala @@ -4,7 +4,7 @@ import akka.actor.Address import cats.arrow.FunctionK import cats.effect.{IO, Ref} import com.evolutiongaming.cluster.sharding.AdaptiveStrategy.Counters -import com.evolutiongaming.cluster.sharding.IOSuite._ +import com.evolutiongaming.cluster.sharding.IOSuite.* import org.scalatest.funsuite.AsyncFunSuite import org.scalatest.matchers.should.Matchers import scala.collection.immutable.IndexedSeq diff --git a/src/test/scala/com/evolutiongaming/cluster/sharding/AllocationStrategyProxySpec.scala b/src/test/scala/com/evolutiongaming/cluster/sharding/AllocationStrategyProxySpec.scala index 2b3e05c..57b3b14 100644 --- a/src/test/scala/com/evolutiongaming/cluster/sharding/AllocationStrategyProxySpec.scala +++ b/src/test/scala/com/evolutiongaming/cluster/sharding/AllocationStrategyProxySpec.scala @@ -2,14 +2,14 @@ package com.evolutiongaming.cluster.sharding import cats.effect.IO import com.evolutiongaming.catshelper.FromFuture -import com.evolutiongaming.cluster.sharding.AllocationStrategyHelper._ -import com.evolutiongaming.cluster.sharding.IOSuite._ +import com.evolutiongaming.cluster.sharding.AllocationStrategyHelper.* +import com.evolutiongaming.cluster.sharding.IOSuite.* import org.scalatest.funsuite.AsyncFunSuite import org.scalatest.matchers.should.Matchers import scala.collection.immutable.IndexedSeq import cats.effect.unsafe.implicits.global -import scala.concurrent.duration._ +import scala.concurrent.duration.* class AllocationStrategyProxySpec extends AsyncFunSuite with ActorSpec with Matchers { diff --git a/src/test/scala/com/evolutiongaming/cluster/sharding/AlwaysRebalanceStrategySpec.scala b/src/test/scala/com/evolutiongaming/cluster/sharding/AlwaysRebalanceStrategySpec.scala index dcf578c..ed2df05 100644 --- a/src/test/scala/com/evolutiongaming/cluster/sharding/AlwaysRebalanceStrategySpec.scala +++ b/src/test/scala/com/evolutiongaming/cluster/sharding/AlwaysRebalanceStrategySpec.scala @@ -1,8 +1,8 @@ package com.evolutiongaming.cluster.sharding import cats.effect.IO -import cats.implicits._ -import com.evolutiongaming.cluster.sharding.IOSuite._ +import cats.implicits.* +import com.evolutiongaming.cluster.sharding.IOSuite.* import scala.collection.immutable.IndexedSeq import org.scalatest.funsuite.AsyncFunSuite diff --git a/src/test/scala/com/evolutiongaming/cluster/sharding/IOSuite.scala b/src/test/scala/com/evolutiongaming/cluster/sharding/IOSuite.scala index 4ea49d0..3358d2b 100644 --- a/src/test/scala/com/evolutiongaming/cluster/sharding/IOSuite.scala +++ b/src/test/scala/com/evolutiongaming/cluster/sharding/IOSuite.scala @@ -5,7 +5,7 @@ import cats.effect.unsafe.implicits.global import com.evolutiongaming.catshelper.FromFuture import org.scalatest.Succeeded -import scala.concurrent.duration._ +import scala.concurrent.duration.* import scala.concurrent.{ExecutionContext, ExecutionContextExecutor, Future} object IOSuite { diff --git a/src/test/scala/com/evolutiongaming/cluster/sharding/LoggingStrategySpec.scala b/src/test/scala/com/evolutiongaming/cluster/sharding/LoggingStrategySpec.scala index 9f68d2b..aeb68e8 100644 --- a/src/test/scala/com/evolutiongaming/cluster/sharding/LoggingStrategySpec.scala +++ b/src/test/scala/com/evolutiongaming/cluster/sharding/LoggingStrategySpec.scala @@ -1,7 +1,7 @@ package com.evolutiongaming.cluster.sharding import akka.actor.Address -import cats.implicits._ +import cats.implicits.* import scala.collection.immutable.IndexedSeq import org.scalatest.funsuite.AnyFunSuite diff --git a/src/test/scala/com/evolutiongaming/cluster/sharding/MappedStrategySpec.scala b/src/test/scala/com/evolutiongaming/cluster/sharding/MappedStrategySpec.scala index 1d7b5f6..3c5ac06 100644 --- a/src/test/scala/com/evolutiongaming/cluster/sharding/MappedStrategySpec.scala +++ b/src/test/scala/com/evolutiongaming/cluster/sharding/MappedStrategySpec.scala @@ -2,7 +2,8 @@ package com.evolutiongaming.cluster.sharding import akka.actor.Address import cats.Id -import cats.implicits._ +import cats.implicits.* +import cats.catsParallelForId import scala.collection.immutable.IndexedSeq import org.scalatest.funsuite.AnyFunSuite diff --git a/src/test/scala/com/evolutiongaming/cluster/sharding/RegionOf.scala b/src/test/scala/com/evolutiongaming/cluster/sharding/RegionOf.scala index 7d56f9a..b383cf9 100644 --- a/src/test/scala/com/evolutiongaming/cluster/sharding/RegionOf.scala +++ b/src/test/scala/com/evolutiongaming/cluster/sharding/RegionOf.scala @@ -5,8 +5,8 @@ import akka.actor.{Actor, ActorRef, ActorSystem, Props} object RegionOf { def apply(actorSystem: ActorSystem): ActorRef = { - def actor() = new Actor { - def receive = PartialFunction.empty + def actor(): Actor = new Actor { + def receive: Actor.Receive = PartialFunction.empty } val props = Props(actor()) diff --git a/src/test/scala/com/evolutiongaming/cluster/sharding/SingleNodeStrategySpec.scala b/src/test/scala/com/evolutiongaming/cluster/sharding/SingleNodeStrategySpec.scala index 417857a..ecc7bcf 100644 --- a/src/test/scala/com/evolutiongaming/cluster/sharding/SingleNodeStrategySpec.scala +++ b/src/test/scala/com/evolutiongaming/cluster/sharding/SingleNodeStrategySpec.scala @@ -2,7 +2,7 @@ package com.evolutiongaming.cluster.sharding import akka.actor.Address import cats.Id -import cats.implicits._ +import cats.implicits.* import scala.collection.immutable.IndexedSeq import org.scalatest.funsuite.AnyFunSuite From e0cf2ca45ece9888bdee8872f4e1862caa72f767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mareks=20Ramp=C4=81ns?= <8796159+mr-git@users.noreply.github.com> Date: Tue, 23 Apr 2024 15:58:02 +0300 Subject: [PATCH 2/2] rearrange settings --- build.sbt | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/build.sbt b/build.sbt index 9e5bf3f..0f7e846 100644 --- a/build.sbt +++ b/build.sbt @@ -3,26 +3,18 @@ import Dependencies._ name := "sharding-strategy" organization := "com.evolutiongaming" - -homepage := Some(url("https://github.com/evolution-gaming/sharding-strategy")) - -startYear := Some(2018) - organizationName := "Evolution" - organizationHomepage := Some(url("https://evolution.com")) - -scalaVersion := crossScalaVersions.value.head +homepage := Some(url("https://github.com/evolution-gaming/sharding-strategy")) +startYear := Some(2018) crossScalaVersions := Seq("2.13.13") - +scalaVersion := crossScalaVersions.value.head scalacOptions := Seq( "-release:17", - "-Xsource:3", + "-Xsource:3-cross", ) - -//scalacOptions -= "-Ywarn-unused:params" - +releaseCrossBuild := true publishTo := Some(Resolver.evolutionReleases) libraryDependencies ++= Seq( @@ -40,4 +32,4 @@ libraryDependencies ++= Seq( licenses := Seq(("MIT", url("https://opensource.org/licenses/MIT"))) -releaseCrossBuild := true \ No newline at end of file +addCommandAlias("build", "all compile test")