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

chore: Test all Scala samples on Scala 3 #1165

Merged
merged 2 commits into from
May 22, 2024
Merged
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
18 changes: 12 additions & 6 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is preferable to adding 3.3.3 to cross scala versions and just running +test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was thinking that we want to keep the sample builds as simple as possible, a real user project would likely never have cross versions but be building for a specific Scala 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: |-
Expand All @@ -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: |-
Expand All @@ -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: |-
Expand All @@ -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: |-
Expand Down
6 changes: 3 additions & 3 deletions samples/grpc/iot-service-scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion samples/grpc/local-drone-control-scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion samples/grpc/shopping-analytics-service-scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions samples/grpc/shopping-cart-service-scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
12 changes: 6 additions & 6 deletions samples/replicated/shopping-cart-service-scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Expand All @@ -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)
}
Expand Down
Loading