Skip to content

Commit

Permalink
Merge pull request #33 from commercetools/publish-test-tools
Browse files Browse the repository at this point in the history
Add testing module
  • Loading branch information
satabin authored Sep 18, 2024
2 parents 49ca6ab + 54b1212 commit e4a23d6
Show file tree
Hide file tree
Showing 25 changed files with 446 additions and 232 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p circe/.jvm/target unidocs/target otel4s/.jvm/target aws/sqs/.jvm/target gcp/pubsub/.jvm/target core/.jvm/target azure/service-bus/.jvm/target testkit/.jvm/target project/target
run: mkdir -p testing/.jvm/target circe/.jvm/target unidocs/target otel4s/.jvm/target aws/sqs/.jvm/target gcp/pubsub/.jvm/target core/.jvm/target azure/service-bus/.jvm/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar circe/.jvm/target unidocs/target otel4s/.jvm/target aws/sqs/.jvm/target gcp/pubsub/.jvm/target core/.jvm/target azure/service-bus/.jvm/target testkit/.jvm/target project/target
run: tar cf targets.tar testing/.jvm/target circe/.jvm/target unidocs/target otel4s/.jvm/target aws/sqs/.jvm/target gcp/pubsub/.jvm/target core/.jvm/target azure/service-bus/.jvm/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import cats.effect.Async
import cats.syntax.functor._
import cats.syntax.monadError._
import cats.syntax.traverse._
import com.commercetools.queue.{QueuePusher, Serializer}
import com.commercetools.queue.{Serializer, UnsealedQueuePusher}
import software.amazon.awssdk.services.sqs.SqsAsyncClient
import software.amazon.awssdk.services.sqs.model.{MessageAttributeValue, SendMessageBatchRequest, SendMessageBatchRequestEntry, SendMessageRequest}

Expand All @@ -34,7 +34,7 @@ private class SQSPusher[F[_], T](
)(implicit
serializer: Serializer[T],
F: Async[F])
extends QueuePusher[F, T] {
extends UnsealedQueuePusher[F, T] {

override def push(message: T, metadata: Map[String, String], delay: Option[FiniteDuration]): F[Unit] =
F.fromCompletableFuture {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.commercetools.queue.azure.servicebus
import cats.effect.Async
import cats.syntax.all._
import com.azure.messaging.servicebus.{ServiceBusMessage, ServiceBusSenderClient}
import com.commercetools.queue.{QueuePusher, Serializer}
import com.commercetools.queue.{Serializer, UnsealedQueuePusher}

import java.time.ZoneOffset
import scala.concurrent.duration.FiniteDuration
Expand All @@ -31,7 +31,7 @@ private class ServiceBusPusher[F[_], Data](
)(implicit
serializer: Serializer[Data],
F: Async[F])
extends QueuePusher[F, Data] {
extends UnsealedQueuePusher[F, Data] {

override def push(message: Data, metadata: Map[String, String], delay: Option[FiniteDuration]): F[Unit] = {
val sbMessage = new ServiceBusMessage(serializer.serialize(message))
Expand Down
52 changes: 39 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sbtcrossproject.CrossProject
import com.typesafe.tools.mima.core._

import laika.config.PrettyURLs
Expand All @@ -20,16 +21,24 @@ ThisBuild / scalaVersion := Scala213
ThisBuild / tlSonatypeUseLegacyHost := true

lazy val root =
tlCrossRootProject.aggregate(core, azureServiceBus, awsSQS, awsSqsIt, gcpPubSub, gcpPubSubIt, circe, otel4s, unidocs)
tlCrossRootProject.aggregate(
core,
testing,
azureServiceBus,
awsSQS,
awsSqsIt,
gcpPubSub,
gcpPubSubIt,
circe,
otel4s,
unidocs)

ThisBuild / tlSitePublishBranch := Some("main")

val commonSettings = List(
libraryDependencies ++= Seq(
"co.fs2" %%% "fs2-core" % Versions.fs2,
"org.scalameta" %%% "munit" % Versions.munit % Test,
"org.typelevel" %%% "munit-cats-effect-3" % Versions.munitCatsEffect % Test,
"org.typelevel" %%% "cats-collections-core" % "0.9.8" % Test,
"org.typelevel" %%% "cats-effect-testkit" % "3.5.3" % Test
),
scalacOptions += (scalaVersion.value match {
Expand All @@ -38,25 +47,41 @@ val commonSettings = List(
})
)

lazy val core = crossProject(JVMPlatform)
lazy val core: CrossProject = crossProject(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("core"))
.settings(commonSettings)
.settings(
name := "fs2-queues-core"
name := "fs2-queues-core",
libraryDependencies ++= List(
"co.fs2" %%% "fs2-core" % Versions.fs2
)
)

lazy val testing = crossProject(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("testing"))
.settings(commonSettings)
.settings(
name := "fs2-queues-testing",
libraryDependencies ++= List(
"org.typelevel" %%% "cats-collections-core" % "0.9.8"
),
tlVersionIntroduced := Map("3" -> "0.4.0", "2.13" -> "0.4.0")
)
.dependsOn(core)

lazy val testkit = crossProject(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("testkit"))
.enablePlugins(NoPublishPlugin)
.settings(commonSettings)
.settings(
name := "fs2-queues-testkit",
libraryDependencies ++= List(
"org.scalameta" %%% "munit" % Versions.munit,
"org.typelevel" %%% "munit-cats-effect-3" % Versions.munitCatsEffect
),
tlVersionIntroduced := Map("3" -> "0.2.0", "2.13" -> "0.2.0")
)
)
.dependsOn(core)

Expand Down Expand Up @@ -87,7 +112,7 @@ lazy val otel4s = crossProject(JVMPlatform)
"org.typelevel" %%% "otel4s-core" % "0.9.0"
)
)
.dependsOn(core % "compile->compile;test->test")
.dependsOn(core, testing % Test)

lazy val circe = crossProject(JVMPlatform)
.crossType(CrossType.Pure)
Expand Down Expand Up @@ -140,8 +165,7 @@ lazy val gcpPubSub = crossProject(JVMPlatform)
libraryDependencies ++= List(
"com.google.cloud" % "google-cloud-pubsub" % "1.129.3",
"com.google.cloud" % "google-cloud-monitoring" % "3.47.0"
),
tlVersionIntroduced := Map("3" -> "0.2.0", "2.13" -> "0.2.0")
)
)
.dependsOn(core)

Expand Down Expand Up @@ -169,10 +193,11 @@ lazy val docs = project
laikaExtensions += PrettyURLs,
tlFatalWarnings := false,
libraryDependencies ++= List(
"com.azure" % "azure-identity" % "1.11.1"
"com.azure" % "azure-identity" % "1.11.1",
"org.typelevel" %% "cats-effect-testkit" % "3.5.4"
)
)
.dependsOn(circe.jvm, azureServiceBus.jvm, awsSQS.jvm, gcpPubSub.jvm, otel4s.jvm, testkit.jvm)
.dependsOn(circe.jvm, azureServiceBus.jvm, awsSQS.jvm, gcpPubSub.jvm, otel4s.jvm, testing.jvm)

lazy val unidocs = project
.in(file("unidocs"))
Expand All @@ -185,5 +210,6 @@ lazy val unidocs = project
azureServiceBus.jvm,
awsSQS.jvm,
gcpPubSub.jvm,
otel4s.jvm)
otel4s.jvm,
testing.jvm)
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import scala.concurrent.duration.FiniteDuration
* A queue pusher allows for pushing elements into a queue either on at a time
* or in batch.
*/
trait QueuePusher[F[_], T] {
sealed trait QueuePusher[F[_], T] {

/** The queue name to which this pusher is pushing. */
def queueName: String
Expand Down Expand Up @@ -52,3 +52,5 @@ object QueuePusher {
override def push(messages: List[(T, Map[String, String])], delay: Option[FiniteDuration]): F[Unit] = F.unit
}
}

private[queue] trait UnsealedQueuePusher[F[_], T] extends QueuePusher[F, T]

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions docs/getting-started/directory.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ laika.navigationOrder = [
stats.md
administration.md
serialization.md
testing.md
]
Loading

0 comments on commit e4a23d6

Please sign in to comment.