Skip to content

Commit

Permalink
Merge pull request #189 from davenverse/testing
Browse files Browse the repository at this point in the history
Manager
  • Loading branch information
ChristopherDavenport authored Dec 24, 2021
2 parents 24cf742 + 6069ce6 commit 5486c30
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 251 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.15, 2.13.7]
scala: [2.12.15, 2.13.7, 3.1.0]
java: [[email protected], [email protected]]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.7]
scala: [3.1.0]
java: [[email protected]]
runs-on: ${{ matrix.os }}
steps:
Expand Down
66 changes: 41 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,47 @@ val fs2V = "3.2.3"
val http4sV = "0.23.7"
val circeV = "0.14.1"
val log4catsV = "2.1.1"
val specs2V = "4.13.1"

ThisBuild / crossScalaVersions := Seq("2.12.15", "2.13.7")
ThisBuild / crossScalaVersions := Seq("2.12.15", "2.13.7", "3.1.0")


// Projects
lazy val `whale-tail` = project.in(file("."))
.disablePlugins(MimaPlugin)
.enablePlugins(NoPublishPlugin)
.aggregate(core, examples)
.aggregate(core.jvm, core.js, manager.jvm, manager.js, examples)

lazy val core = project.in(file("core"))
lazy val core = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("core"))
.settings(commonSettings)
.settings(
name := "whale-tail"
)
.jvmSettings(
libraryDependencies += "com.github.jnr" % "jnr-unixsocket" % "0.38.15" % Test,
)
.jsSettings(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule)},
)

lazy val manager = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.dependsOn(core)
.in(file("manager"))
.settings(name := "whale-tail-manager")
.jvmSettings(
libraryDependencies += "com.github.jnr" % "jnr-unixsocket" % "0.38.15" % Test,
)
.jsSettings(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule)},
)

lazy val examples = project.in(file("examples"))
.disablePlugins(MimaPlugin)
.enablePlugins(NoPublishPlugin)
.settings(commonSettings)
.dependsOn(core)
.dependsOn(core.jvm, manager.jvm)
.settings(
name := "whale-tail-examples",
libraryDependencies ++= Seq(
Expand All @@ -42,7 +61,7 @@ lazy val site = project.in(file("site"))
.disablePlugins(MimaPlugin)
.enablePlugins(DavenverseMicrositePlugin)
.settings(commonSettings)
.dependsOn(core)
.dependsOn(core.jvm)
.settings{
import microsites._
Seq(
Expand All @@ -55,30 +74,27 @@ lazy val commonSettings = Seq(

libraryDependencies ++= Seq(
// "com.github.jnr" % "jnr-unixsocket" % "0.33",
"org.typelevel" %% "cats-core" % catsV,

"org.typelevel" %% "cats-effect" % catsEffectV,
"org.typelevel" %%% "cats-core" % catsV,

"co.fs2" %% "fs2-core" % fs2V,
"co.fs2" %% "fs2-io" % fs2V,
"org.typelevel" %%% "cats-effect" % catsEffectV,

"org.http4s" %% "http4s-dsl" % http4sV,
"org.http4s" %% "http4s-ember-core" % http4sV,
"org.http4s" %% "http4s-client" % http4sV,
"org.http4s" %% "http4s-circe" % http4sV,
"org.http4s" %% "http4s-ember-client" % http4sV,
"co.fs2" %%% "fs2-core" % fs2V,
"co.fs2" %%% "fs2-io" % fs2V,

"io.circe" %% "circe-core" % circeV,
"io.circe" %% "circe-generic" % circeV,
"io.circe" %% "circe-parser" % circeV,
"org.http4s" %%% "http4s-dsl" % http4sV,
"org.http4s" %%% "http4s-ember-core" % http4sV,
"org.http4s" %%% "http4s-client" % http4sV,
"org.http4s" %%% "http4s-circe" % http4sV,
"org.http4s" %%% "http4s-ember-client" % http4sV,

"org.typelevel" %% "log4cats-core" % log4catsV,
"org.typelevel" %% "log4cats-testing" % log4catsV % Test,
"com.github.jnr" % "jnr-unixsocket" % "0.38.15" % Test,
"io.circe" %%% "circe-core" % circeV,
"io.circe" %%% "circe-generic" % circeV,
"io.circe" %%% "circe-parser" % circeV,

"org.typelevel" %% "cats-effect-testing-specs2" % "1.4.0" % Test,
"org.typelevel" %%% "log4cats-core" % log4catsV,
"org.typelevel" %%% "log4cats-testing" % log4catsV % Test,


"org.specs2" %% "specs2-core" % specs2V % Test,
"org.specs2" %% "specs2-scalacheck" % specs2V % Test
"org.typelevel" %%% "cats-effect-testing-specs2" % "1.4.0" % Test,
)
)
202 changes: 0 additions & 202 deletions core/src/main/scala/io/chrisdavenport/whaletail/UnixSocket.scala

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion examples/src/main/scala/ContainerExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object ContainersExample extends IOApp {
Images.Operations.createFromImage(client, "redis", "latest".some).logInfo("createFromImage")
)
created <- Resource.eval(
Containers.Operations.create(client, "redis:latest", Map(6379 -> None)).logInfo("create")
Containers.Operations.create(client, "redis:latest", Map(6379 -> None), labels = Map("whale-identity" -> "whale-tail")).logInfo("create")
)
_ <- Resource.make(
Containers.Operations.start(client, created.id).logInfo("start")
Expand Down
34 changes: 34 additions & 0 deletions examples/src/main/scala/ManagerExample.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

import cats.implicits._
import cats.effect._
import org.typelevel.log4cats.slf4j.Slf4jLogger
import io.chrisdavenport.whaletail.{
Docker,
Containers,
Images
}
import scala.concurrent.duration._
import io.chrisdavenport.whaletail.manager._

object TestingExample extends IOApp {

def run(args: List[String]): IO[ExitCode] = {
val logger = Slf4jLogger.getLogger[IO]
implicit class LogAll[A](fa: IO[A]){
def logInfo(tag: String) = fa.flatTap(a => logger.info(tag ++ ": " ++ a.toString()))
}
for {
client <- Docker.client[IO]
container <- WhaleTailContainer.build(client, "redis", "latest".some, Map(6379 -> None), Map.empty, Map.empty)
.evalTap(ReadinessStrategy.checkReadiness(
client,
_,
ReadinessStrategy.LogRegex(".*Ready to accept connections.*\\s".r),
30.seconds
))
_ <- Resource.eval(logger.info(s"$container"))
} yield ()


}.use(_ => IO.pure(ExitCode.Success))
}
Loading

0 comments on commit 5486c30

Please sign in to comment.