From 29902364380731d7ceaea21af85f1a903e4aef49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Andr=C3=A9n?= Date: Wed, 22 May 2024 09:18:50 +0200 Subject: [PATCH] chore: Test all Scala samples on Scala 3 (#1165) --- .github/workflows/checks.yml | 18 ++++++++++++------ samples/grpc/iot-service-scala/build.sbt | 6 +++--- .../src/test/scala/iot/EdgeApp.scala | 2 +- .../grpc/local-drone-control-scala/build.sbt | 2 +- .../scala/local/drones/DeliveriesQueue.scala | 2 +- .../drones/DeliveriesQueueServiceImpl.scala | 2 +- .../build.sbt | 8 ++++---- .../project/plugins.sbt | 2 +- .../scala/central/DroneDeliveriesServer.scala | 2 +- .../shopping-analytics-service-scala/build.sbt | 2 +- .../grpc/shopping-cart-service-scala/build.sbt | 8 ++++---- .../scala/shopping/cart/ShoppingCart.scala | 4 ++-- .../cart/ShoppingCartServiceImpl.scala | 2 +- .../shopping-cart-service-scala/build.sbt | 12 ++++++------ .../project/plugins.sbt | 2 +- .../cart/ShoppingCartServiceImpl.scala | 6 +++--- 16 files changed, 43 insertions(+), 37 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 29f88b262..bd06ef4f6 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -166,17 +166,19 @@ jobs: - name: Publish artifacts locally run: |- - sbt "publishLocal; publishM2" + sbt "+publishLocal; publishM2" - - name: Compile Scala Projection gRPC sample Shopping Cart + - name: Test Scala Projection gRPC sample Shopping Cart run: |- cd samples/grpc/shopping-cart-service-scala sbt test -Dakka-projection.version=`cat ~/.version` + sbt "clean; ++3.3.3!; test;" -Dakka-projection.version=`cat ~/.version` - name: Compile Scala Projection gRPC sample Analytics run: |- cd samples/grpc/shopping-analytics-service-scala - sbt compile -Dakka-projection.version=`cat ~/.version` + sbt Test/compile -Dakka-projection.version=`cat ~/.version` + sbt "clean; ++3.3.3!; Test/compile;" - name: Compile Java Projection gRPC sample Shopping Cart run: |- @@ -191,7 +193,8 @@ jobs: - name: Compile Scala Replicated Event Sourcing over gRPC sample Shopping Cart run: |- cd samples/replicated/shopping-cart-service-scala - sbt compile -Dakka-projection.version=`cat ~/.version` + sbt Test/compile -Dakka-projection.version=`cat ~/.version` + sbt "clean; ++3.3.3!; Test/compile;" - name: Compile Java Replicated Event Sourcing over gRPC sample Shopping Cart run: |- @@ -201,12 +204,14 @@ jobs: - name: Compile Scala Projection gRPC Local Drone Control sample run: |- cd samples/grpc/local-drone-control-scala - sbt compile -Dakka-projection.version=`cat ~/.version` + sbt Test/compile -Dakka-projection.version=`cat ~/.version` + sbt "clean; ++3.3.3!; Test/compile;" -Dakka-projection.version=`cat ~/.version` - name: Compile Scala Projection gRPC Restaurant Drone Deliveries sample run: |- cd samples/grpc/restaurant-drone-deliveries-service-scala sbt compile -Dakka-projection.version=`cat ~/.version` + sbt "clean; ++3.3.3!; Test/compile;" -Dakka-projection.version=`cat ~/.version` - name: Compile Java Projection gRPC Local Drone Control sample run: |- @@ -218,10 +223,11 @@ jobs: cd samples/grpc/restaurant-drone-deliveries-service-java mvn compile -nsu -ntp -Dakka-projection.version=`cat ~/.version` - - name: Compile Scala Projection gRPC IoT service sample + - name: Test Scala Projection gRPC IoT service sample run: |- cd samples/grpc/iot-service-scala sbt test -Dakka-projection.version=`cat ~/.version` + sbt "clean; ++3.3.3!; test;" -Dakka-projection.version=`cat ~/.version` - name: Compile Java Projection gRPC IoT service sample run: |- diff --git a/samples/grpc/iot-service-scala/build.sbt b/samples/grpc/iot-service-scala/build.sbt index 7d8499071..df5ae4e2c 100644 --- a/samples/grpc/iot-service-scala/build.sbt +++ b/samples/grpc/iot-service-scala/build.sbt @@ -33,8 +33,8 @@ val AkkaHttpVersion = "10.6.3" val AkkaManagementVersion = "1.5.2" val AkkaPersistenceR2dbcVersion = "1.2.3" val AkkaProjectionVersion = - sys.props.getOrElse("akka-projection.version", "") -val AkkaDiagnosticsVersion = "2.1.0" + sys.props.getOrElse("akka-projection.version", "1.5.4") +val AkkaDiagnosticsVersion = "2.1.1" enablePlugins(AkkaGrpcPlugin) @@ -64,7 +64,7 @@ libraryDependencies ++= Seq( // Common dependencies for logging and testing "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion, "ch.qos.logback" % "logback-classic" % "1.2.13", - "org.scalatest" %% "scalatest" % "3.1.2" % Test, + "org.scalatest" %% "scalatest" % "3.2.18" % Test, // 2. Using Akka Persistence "com.typesafe.akka" %% "akka-persistence-typed" % AkkaVersion, "com.typesafe.akka" %% "akka-serialization-jackson" % AkkaVersion, diff --git a/samples/grpc/iot-service-scala/src/test/scala/iot/EdgeApp.scala b/samples/grpc/iot-service-scala/src/test/scala/iot/EdgeApp.scala index 2c8eb862d..3ea4c47e0 100644 --- a/samples/grpc/iot-service-scala/src/test/scala/iot/EdgeApp.scala +++ b/samples/grpc/iot-service-scala/src/test/scala/iot/EdgeApp.scala @@ -157,7 +157,7 @@ object EdgeApp { sealed trait Command - final case object Tick extends Command + case object Tick extends Command sealed trait Event extends CborSerializable diff --git a/samples/grpc/local-drone-control-scala/build.sbt b/samples/grpc/local-drone-control-scala/build.sbt index 6a3237c77..f9d9bd0bc 100644 --- a/samples/grpc/local-drone-control-scala/build.sbt +++ b/samples/grpc/local-drone-control-scala/build.sbt @@ -78,7 +78,7 @@ libraryDependencies ++= Seq( // Common dependencies for logging and testing "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion, "ch.qos.logback" % "logback-classic" % "1.2.13", - "org.scalatest" %% "scalatest" % "3.1.2" % Test, + "org.scalatest" %% "scalatest" % "3.2.18" % Test, // Prometheus client for custom metrics "io.prometheus" % "simpleclient" % "0.16.0", "io.prometheus" % "simpleclient_httpserver" % "0.16.0", diff --git a/samples/grpc/local-drone-control-scala/src/main/scala/local/drones/DeliveriesQueue.scala b/samples/grpc/local-drone-control-scala/src/main/scala/local/drones/DeliveriesQueue.scala index e38dca1ef..2c015609e 100644 --- a/samples/grpc/local-drone-control-scala/src/main/scala/local/drones/DeliveriesQueue.scala +++ b/samples/grpc/local-drone-control-scala/src/main/scala/local/drones/DeliveriesQueue.scala @@ -57,7 +57,7 @@ object DeliveriesQueue { // #state // Not really an entity, we just have one - val EntityKey = EntityTypeKey("RestaurantDeliveries") + val EntityKey = EntityTypeKey[Command]("RestaurantDeliveries") def apply(): Behavior[Command] = { Behaviors diff --git a/samples/grpc/local-drone-control-scala/src/main/scala/local/drones/DeliveriesQueueServiceImpl.scala b/samples/grpc/local-drone-control-scala/src/main/scala/local/drones/DeliveriesQueueServiceImpl.scala index 8af5b6914..75813d8a5 100644 --- a/samples/grpc/local-drone-control-scala/src/main/scala/local/drones/DeliveriesQueueServiceImpl.scala +++ b/samples/grpc/local-drone-control-scala/src/main/scala/local/drones/DeliveriesQueueServiceImpl.scala @@ -19,7 +19,7 @@ class DeliveriesQueueServiceImpl( override def getCurrentQueue( in: Empty): Future[proto.GetCurrentQueueResponse] = { - val reply = deliveriesQueue.ask(DeliveriesQueue.GetCurrentState(_)) + val reply = deliveriesQueue.ask(DeliveriesQueue.GetCurrentState.apply) reply.map { state => proto.GetCurrentQueueResponse( diff --git a/samples/grpc/restaurant-drone-deliveries-service-scala/build.sbt b/samples/grpc/restaurant-drone-deliveries-service-scala/build.sbt index e4083f96d..b6763aa52 100644 --- a/samples/grpc/restaurant-drone-deliveries-service-scala/build.sbt +++ b/samples/grpc/restaurant-drone-deliveries-service-scala/build.sbt @@ -30,11 +30,11 @@ Global / cancelable := false // ctrl-c val AkkaVersion = "2.9.3" val AkkaHttpVersion = "10.6.3" -val AkkaManagementVersion = "1.5.1" -val AkkaPersistenceR2dbcVersion = "1.2.3" +val AkkaManagementVersion = "1.5.2" +val AkkaPersistenceR2dbcVersion = "1.2.2" val AkkaProjectionVersion = sys.props.getOrElse("akka-projection.version", "1.5.4") -val AkkaDiagnosticsVersion = "2.1.0" +val AkkaDiagnosticsVersion = "2.1.1" enablePlugins(AkkaGrpcPlugin) @@ -65,7 +65,7 @@ libraryDependencies ++= Seq( // Common dependencies for logging and testing "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion, "ch.qos.logback" % "logback-classic" % "1.2.13", - "org.scalatest" %% "scalatest" % "3.1.2" % Test, + "org.scalatest" %% "scalatest" % "3.2.18" % Test, // 2. Using Akka Persistence "com.typesafe.akka" %% "akka-persistence-typed" % AkkaVersion, "com.typesafe.akka" %% "akka-serialization-jackson" % AkkaVersion, diff --git a/samples/grpc/restaurant-drone-deliveries-service-scala/project/plugins.sbt b/samples/grpc/restaurant-drone-deliveries-service-scala/project/plugins.sbt index 614d3e912..a2be489ed 100644 --- a/samples/grpc/restaurant-drone-deliveries-service-scala/project/plugins.sbt +++ b/samples/grpc/restaurant-drone-deliveries-service-scala/project/plugins.sbt @@ -1,6 +1,6 @@ resolvers += "Akka library repository".at("https://repo.akka.io/maven") -addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "2.4.2") +addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "2.4.3") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16") addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.0.1") diff --git a/samples/grpc/restaurant-drone-deliveries-service-scala/src/main/scala/central/DroneDeliveriesServer.scala b/samples/grpc/restaurant-drone-deliveries-service-scala/src/main/scala/central/DroneDeliveriesServer.scala index ea69d7b4c..22a715e7c 100644 --- a/samples/grpc/restaurant-drone-deliveries-service-scala/src/main/scala/central/DroneDeliveriesServer.scala +++ b/samples/grpc/restaurant-drone-deliveries-service-scala/src/main/scala/central/DroneDeliveriesServer.scala @@ -44,7 +44,7 @@ object DroneDeliveriesServer { RestaurantDeliveriesService, ChargingStationService))) - val bound = Http(system).newServerAt(interface, port).bind(service) + val bound = Http().newServerAt(interface, port).bind(service) // #composeAndBind bound.foreach(binding => logger.info( diff --git a/samples/grpc/shopping-analytics-service-scala/build.sbt b/samples/grpc/shopping-analytics-service-scala/build.sbt index a238e8150..be124df98 100644 --- a/samples/grpc/shopping-analytics-service-scala/build.sbt +++ b/samples/grpc/shopping-analytics-service-scala/build.sbt @@ -65,7 +65,7 @@ libraryDependencies ++= Seq( // Common dependencies for logging and testing "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion, "ch.qos.logback" % "logback-classic" % "1.2.13", - "org.scalatest" %% "scalatest" % "3.1.2" % Test, + "org.scalatest" %% "scalatest" % "3.2.18" % Test, // 2. Using Akka Persistence "com.typesafe.akka" %% "akka-persistence-typed" % AkkaVersion, "com.typesafe.akka" %% "akka-serialization-jackson" % AkkaVersion, diff --git a/samples/grpc/shopping-cart-service-scala/build.sbt b/samples/grpc/shopping-cart-service-scala/build.sbt index bc04c0d52..d2f05d62c 100644 --- a/samples/grpc/shopping-cart-service-scala/build.sbt +++ b/samples/grpc/shopping-cart-service-scala/build.sbt @@ -30,11 +30,11 @@ Global / cancelable := false // ctrl-c val AkkaVersion = "2.9.3" val AkkaHttpVersion = "10.6.3" -val AkkaManagementVersion = "1.5.1" +val AkkaManagementVersion = "1.5.2" val AkkaPersistenceR2dbcVersion = "1.2.3" val AkkaProjectionVersion = - sys.props.getOrElse("akka-projection.version", "") -val AkkaDiagnosticsVersion = "2.1.0" + sys.props.getOrElse("akka-projection.version", "1.5.4") +val AkkaDiagnosticsVersion = "2.1.1" enablePlugins(AkkaGrpcPlugin) @@ -65,7 +65,7 @@ libraryDependencies ++= Seq( // Common dependencies for logging and testing "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion, "ch.qos.logback" % "logback-classic" % "1.2.13", - "org.scalatest" %% "scalatest" % "3.1.2" % Test, + "org.scalatest" %% "scalatest" % "3.2.18" % Test, // 2. Using Akka Persistence "com.typesafe.akka" %% "akka-persistence-typed" % AkkaVersion, "com.typesafe.akka" %% "akka-serialization-jackson" % AkkaVersion, diff --git a/samples/grpc/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCart.scala b/samples/grpc/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCart.scala index 3d58a96ab..db4567b02 100644 --- a/samples/grpc/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCart.scala +++ b/samples/grpc/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCart.scala @@ -207,10 +207,10 @@ object ShoppingCart { command: Command): ReplyEffect[Event, State] = { command match { case AddItem(itemId, quantity, replyTo) => - if (quantity <= 0) + if (quantity <= 0) { Effect.reply(replyTo)( StatusReply.Error("Quantity must be greater than zero")) - else + } else Effect .persist(ItemUpdated(itemId, quantity)) .thenReply(replyTo) { updatedCart => diff --git a/samples/grpc/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCartServiceImpl.scala b/samples/grpc/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCartServiceImpl.scala index e23e4e3a6..7eb5f58b2 100644 --- a/samples/grpc/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCartServiceImpl.scala +++ b/samples/grpc/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCartServiceImpl.scala @@ -57,7 +57,7 @@ class ShoppingCartServiceImpl(system: ActorSystem[_]) logger.info("getCart {}", in.cartId) val entityRef = sharding.entityRefFor(ShoppingCart.EntityKey, in.cartId) val response = - entityRef.ask(ShoppingCart.Get).map { cart => + entityRef.ask(ShoppingCart.Get.apply).map { cart => if (cart.items.isEmpty) throw new GrpcServiceException( Status.NOT_FOUND.withDescription(s"Cart ${in.cartId} not found")) diff --git a/samples/replicated/shopping-cart-service-scala/build.sbt b/samples/replicated/shopping-cart-service-scala/build.sbt index ed17a794c..99c417768 100644 --- a/samples/replicated/shopping-cart-service-scala/build.sbt +++ b/samples/replicated/shopping-cart-service-scala/build.sbt @@ -29,13 +29,13 @@ run / javaOptions ++= sys.props .fold(Seq.empty[String])(res => Seq(s"-Dconfig.resource=$res")) Global / cancelable := false // ctrl-c -val AkkaVersion = sys.props.getOrElse("akka.version", "2.9.1") -val AkkaHttpVersion = "10.6.0" -val AkkaManagementVersion = "1.5.0" -val AkkaPersistenceR2dbcVersion = "1.2.2" +val AkkaVersion = sys.props.getOrElse("akka.version", "2.9.3") +val AkkaHttpVersion = "10.6.3" +val AkkaManagementVersion = "1.5.2" +val AkkaPersistenceR2dbcVersion = "1.2.4" val AkkaProjectionVersion = sys.props.getOrElse("akka-projection.version", "1.5.4") -val AkkaDiagnosticsVersion = "2.1.0" +val AkkaDiagnosticsVersion = "2.1.1" enablePlugins(AkkaGrpcPlugin) @@ -66,7 +66,7 @@ libraryDependencies ++= Seq( // Common dependencies for logging and testing "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion, "ch.qos.logback" % "logback-classic" % "1.2.13", - "org.scalatest" %% "scalatest" % "3.1.2" % Test, + "org.scalatest" %% "scalatest" % "3.2.18" % Test, // 2. Using Akka Persistence "com.typesafe.akka" %% "akka-persistence-typed" % AkkaVersion, "com.typesafe.akka" %% "akka-serialization-jackson" % AkkaVersion, diff --git a/samples/replicated/shopping-cart-service-scala/project/plugins.sbt b/samples/replicated/shopping-cart-service-scala/project/plugins.sbt index 614d3e912..a2be489ed 100644 --- a/samples/replicated/shopping-cart-service-scala/project/plugins.sbt +++ b/samples/replicated/shopping-cart-service-scala/project/plugins.sbt @@ -1,6 +1,6 @@ resolvers += "Akka library repository".at("https://repo.akka.io/maven") -addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "2.4.2") +addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "2.4.3") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16") addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.0.1") diff --git a/samples/replicated/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCartServiceImpl.scala b/samples/replicated/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCartServiceImpl.scala index 056733574..c32442d17 100644 --- a/samples/replicated/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCartServiceImpl.scala +++ b/samples/replicated/shopping-cart-service-scala/src/main/scala/shopping/cart/ShoppingCartServiceImpl.scala @@ -46,7 +46,7 @@ class ShoppingCartServiceImpl(system: ActorSystem[_], entityKey: EntityTypeKey[S logger.info("checkout {}", in.cartId) val entityRef = sharding.entityRefFor(entityKey, in.cartId) val reply: Future[ShoppingCart.Summary] = - entityRef.askWithStatus(ShoppingCart.Checkout) + entityRef.askWithStatus(ShoppingCart.Checkout.apply) val response = reply.map(cart => toProtoCart(cart)) convertError(response) } @@ -55,7 +55,7 @@ class ShoppingCartServiceImpl(system: ActorSystem[_], entityKey: EntityTypeKey[S logger.info("getCart {}", in.cartId) val entityRef = sharding.entityRefFor(entityKey, in.cartId) val response = - entityRef.ask(ShoppingCart.Get).map { cart => + entityRef.ask(ShoppingCart.Get.apply).map { cart => if (cart.items.isEmpty) throw new GrpcServiceException(Status.NOT_FOUND.withDescription(s"Cart ${in.cartId} not found")) else @@ -68,7 +68,7 @@ class ShoppingCartServiceImpl(system: ActorSystem[_], entityKey: EntityTypeKey[S logger.info("markCustomerVip {}", in.cartId) val entityRef = sharding.entityRefFor(entityKey, in.cartId) val reply: Future[ShoppingCart.Summary] = - entityRef.askWithStatus(ShoppingCart.MarkCustomerVip) + entityRef.askWithStatus(ShoppingCart.MarkCustomerVip.apply) val response = reply.map(cart => toProtoCart(cart)) convertError(response) }