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

Cross-Platform Docker Testing #39

Merged
merged 7 commits into from
Jan 5, 2022
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
2 changes: 1 addition & 1 deletion .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.14, 2.13.6, 3.0.0]
scala: [2.12.14, 2.13.6, 3.1.0]
java: [adopt@1.8, adopt@1.11]
runs-on: ${{ matrix.os }}
steps:
Expand Down
13 changes: 9 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ val catsEffectV = "3.2.0"
// val fs2V = "3.0.6"
val fs2V = "3.1.0"

val munitCatsEffectV = "1.0.5"
val munitCatsEffectV = "1.0.7"

ThisBuild / crossScalaVersions := Seq("2.12.14","2.13.6", "3.0.0")
ThisBuild / crossScalaVersions := Seq("2.12.14","2.13.6", "3.1.0")
ThisBuild / scalaVersion := "2.13.6"

// Projects
Expand Down Expand Up @@ -36,8 +36,13 @@ lazy val core = crossProject(JVMPlatform, JSPlatform)
"org.typelevel" %%% "keypool" % "0.4.6",

"org.typelevel" %%% "munit-cats-effect-3" % munitCatsEffectV % Test,
"org.scalameta" %%% "munit-scalacheck" % "0.7.27" % Test
"io.chrisdavenport" %%% "whale-tail-manager" % "0.0.8" % Test,
"org.scalameta" %%% "munit-scalacheck" % "0.7.27" % Test,
)
).jsSettings(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule)}
).jvmSettings(
libraryDependencies += "com.github.jnr" % "jnr-unixsocket" % "0.38.15" % Test,
)

lazy val examples = crossProject(JVMPlatform, JSPlatform)
Expand All @@ -57,7 +62,7 @@ lazy val examples = crossProject(JVMPlatform, JSPlatform)
),
Compile / mainClass := Some("BasicExample"),
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule)},
scalaJSStage in Global := FullOptStage,
scalaJSStage := FullOptStage,
)
lazy val examplesJVM = examples.jvm
lazy val examplesJS = examples.js
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.chrisdavenport.rediculous

import cats.syntax.all._
import cats.effect._
import munit.CatsEffectSuite
import scala.concurrent.duration._
import io.chrisdavenport.whaletail.Docker
import io.chrisdavenport.whaletail.manager._
import com.comcast.ip4s.Host
import com.comcast.ip4s.Port

class RedisCommandsSpec extends CatsEffectSuite {
val resource = Docker.default[IO].flatMap(client =>
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
)
)
).flatMap(container =>
for {
t <- Resource.eval(
container.ports.get(6379).liftTo[IO](new Throwable("Missing Port"))
)
(hostS, portI) = t
host <- Resource.eval(Host.fromString(hostS).liftTo[IO](new Throwable("Invalid Host")))
port <- Resource.eval(Port.fromInt(portI).liftTo[IO](new Throwable("Invalid Port")))
connection <- RedisConnection.pool[IO].withHost(host).withPort(port).build
} yield connection

)
// Not available on scala.js
val redisConnection = UnsafeResourceSuiteLocalDeferredFixture(
"redisconnection",
resource
)
override def munitFixtures: Seq[Fixture[_]] = Seq(
redisConnection
)
test("set a value"){ //connection =>
redisConnection().flatMap{connection =>
val key = "foo"
val value = "bar"
val action = RedisCommands.set[RedisIO](key, value) >> RedisCommands.get[RedisIO](key)
action.run(connection)
}.map{
assertEquals(_, Some("bar"))
}
}
}
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16")
addSbtPlugin("io.chrisdavenport" % "sbt-davenverse" % "0.1.0")
addSbtPlugin("io.chrisdavenport" % "sbt-davenverse" % "0.1.4")