Skip to content

Commit

Permalink
Cross-build for 2.13; bump cats, cats-effect to 2.0.0-M4, cats-mtl to…
Browse files Browse the repository at this point in the history
… 0.6.0, fs2 to 1.1.0-M1 (#17)

* Cross-build for 2.13; bump cats, cats-effect to 2.0.0-M4, cats-mtl to 0.6.0, fs2 to 1.1.0-M1

* Update build.sbt
  • Loading branch information
neko-kai authored Jul 16, 2019
1 parent a8cb061 commit 9e7cda6
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 93 deletions.
47 changes: 47 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,37 @@ jobs:
- "~/.sbt"
- "~/.m2"

test213_jvm_jdk8:
machine:
image: ubuntu-1604:201903-01
steps:
- checkout
- restore_cache:
key: sbt-cache-machine
- run: sbt ++2.13.0! testJVM
- run: sbt ++2.13.0! package packageSrc publishLocal
- save_cache:
key: sbt-cache-machine
paths:
- "~/.ivy2/cache"
- "~/.sbt"
- "~/.m2"

test213_js_jdk8:
machine:
image: ubuntu-1604:201903-01
steps:
- checkout
- restore_cache:
key: sbt-cache-machine
- run: sbt ++2.13.0! testJS
- save_cache:
key: sbt-cache-machine
paths:
- "~/.ivy2/cache"
- "~/.sbt"
- "~/.m2"

release:
docker:
- image: hseeberger/scala-sbt:8u181_2.12.8_1.2.8
Expand All @@ -89,8 +120,10 @@ jobs:
- run: echo -n "${PGP_SECRET}" | base64 -d > /tmp/secret.asc
- run: sbt ++2.11.12! interopCatsJVM/releaseEarly
- run: sbt ++2.12.8! interopCatsJVM/releaseEarly
- run: sbt ++2.13.0! interopCatsJVM/releaseEarly
- run: sbt ++2.11.12! interopCatsJS/releaseEarly
- run: sbt ++2.12.8! interopCatsJS/releaseEarly
- run: sbt ++2.13.0! interopCatsJS/releaseEarly

workflows:
version: 2
Expand Down Expand Up @@ -124,13 +157,27 @@ workflows:
filters:
tags:
only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
- test213_jvm_jdk8:
requires:
- lint212_jdk8
filters:
tags:
only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
- test213_js_jdk8:
requires:
- lint212_jdk8
filters:
tags:
only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
- release:
context: Sonatype
requires:
- test211_jvm_jdk8
- test211_js_jdk8
- test212_jvm_jdk8
- test212_js_jdk8
- test213_jvm_jdk8
- test213_js_jdk8
filters:
branches:
ignore: /.*/
Expand Down
55 changes: 10 additions & 45 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -47,60 +47,25 @@ lazy val interopCats = crossProject(JSPlatform, JVMPlatform)
.settings(buildInfoSettings)
.settings(
libraryDependencies ++= Seq(
"dev.zio" %%% "zio" % "1.0.0-RC9-4",
"org.typelevel" %%% "cats-effect" % "1.3.1" % Optional,
"org.typelevel" %%% "cats-mtl-core" % "0.5.0" % Optional,
"co.fs2" %%% "fs2-core" % "1.0.5" % Test,
"dev.zio" %%% "zio" % "1.0.0-RC9-4" % Test classifier "tests",
"dev.zio" %%% "zio" % "1.0.0-RC10-1",
"org.typelevel" %%% "cats-effect" % "2.0.0-M4" % Optional,
"org.typelevel" %%% "cats-mtl-core" % "0.6.0" % Optional,
"co.fs2" %%% "fs2-core" % "1.1.0-M1" % Test,
"dev.zio" %%% "zio" % "1.0.0-RC10-1" % Test classifier "tests",
"org.specs2" %%% "specs2-core" % "4.6.0" % Test,
"org.specs2" %%% "specs2-scalacheck" % "4.6.0" % Test,
"org.specs2" %%% "specs2-matcher-extra" % "4.6.0" % Test
)
)

val CatsScalaCheckVersion = Def.setting {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
"1.13"
case _ =>
"1.14"
}
}

val ScalaCheckVersion = Def.setting {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
"1.13.5"
case _ =>
"1.14.0"
}
}

def majorMinor(version: String) = version.split('.').take(2).mkString(".")

val CatsScalaCheckShapelessVersion = Def.setting {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
"1.1.8"
case _ =>
"1.2.0-1+7-a4ed6f38-SNAPSHOT" // TODO: Stable version
}
}

// Below is for the cats law spec
// Separated due to binary incompatibility in scalacheck 1.13 vs 1.14
// TODO remove it when https://github.com/typelevel/discipline/issues/52 is closed
lazy val interopCatsJVM = interopCats.jvm
.settings(
// TODO: Remove once scalacheck-shapeless has a stable version for 2.13.0-M5
resolvers += Resolver.sonatypeRepo("snapshots"),
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect-laws" % "1.3.1" % Test,
"org.typelevel" %% "cats-testkit" % "1.6.1" % Test,
"org.typelevel" %% "cats-mtl-laws" % "0.5.0" % Test,
"com.github.alexarchambault" %% s"scalacheck-shapeless_${majorMinor(CatsScalaCheckVersion.value)}" % CatsScalaCheckShapelessVersion.value % Test
),
dependencyOverrides += "org.scalacheck" %% "scalacheck" % ScalaCheckVersion.value % Test
"org.typelevel" %% "cats-effect-laws" % "2.0.0-M4" % Test,
"org.typelevel" %% "cats-testkit" % "2.0.0-M4" % Test,
"org.typelevel" %% "cats-mtl-laws" % "0.6.0" % Test,
"com.github.alexarchambault" %% s"scalacheck-shapeless_1.14" % "1.2.3" % Test
)
)

lazy val interopCatsJS = interopCats.js
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package zio.interop

import catalysts.Platform
import cats.kernel.laws.discipline.catsLawsIsEqToProp
import cats.{ Eq, Monad }
import org.scalacheck.{ Arbitrary, Prop }
Expand All @@ -18,9 +17,7 @@ trait ExtraMonadTests[F[_]] extends Laws {
def bases: Seq[(String, RuleSet)] = Nil
def parents: Seq[RuleSet] = Nil
def props: Seq[(String, Prop)] =
if (Platform.isJvm)
Seq[(String, Prop)]("tailRecM construction stack safety" -> Prop.lzy(laws.tailRecMConstructionStackSafety))
else Seq.empty
Seq[(String, Prop)]("tailRecM construction stack safety" -> Prop.lzy(laws.tailRecMConstructionStackSafety))
}
}

Expand Down
7 changes: 4 additions & 3 deletions interop-cats/jvm/src/test/scala/zio/interop/catzMtlSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import cats.mtl.laws.discipline.{
FunctorRaiseTests
}
import org.scalacheck.{ Arbitrary, Cogen }
import org.scalatest.prop.Checkers
import org.scalatest.{ BeforeAndAfterAll, FunSuite, Matchers }
import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.scalacheck.Checkers
import org.scalatest.{ BeforeAndAfterAll, Matchers }
import org.typelevel.discipline.scalatest.Discipline
import zio.blocking.Blocking
import zio.clock.Clock
Expand All @@ -23,7 +24,7 @@ import zio.interop.catz.mtl._
import zio.random.Random
import zio.system.System

class catzMtlSpec extends FunSuite with BeforeAndAfterAll with Matchers with Checkers with Discipline with GenIO {
class catzMtlSpec extends AnyFunSuite with BeforeAndAfterAll with Matchers with Checkers with Discipline with GenIO {

type Env = Clock with Console with System with Random with Blocking

Expand Down
43 changes: 8 additions & 35 deletions interop-cats/jvm/src/test/scala/zio/interop/catzSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ package zio
package interop

import cats.Eq
import cats.effect.concurrent.Deferred
import cats.effect.{ ConcurrentEffect, ContextShift }
import cats.effect.laws.ConcurrentEffectLaws
import cats.effect.laws.discipline.arbitrary._
import cats.effect.laws.discipline.{ ConcurrentEffectTests, ConcurrentTests, EffectTests, Parameters }
import cats.effect.laws.util.{ TestContext, TestInstances }
import cats.implicits._
import cats.laws._
import cats.laws.discipline.MonadTests
import cats.laws.discipline.{ AlternativeTests, BifunctorTests, MonadErrorTests, ParallelTests, SemigroupKTests }
import org.scalacheck.{ Arbitrary, Cogen }
import org.scalatest.prop.Checkers
import org.scalatest.{ BeforeAndAfterAll, FunSuite, Matchers }
import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.scalacheck.Checkers
import org.scalatest.{ BeforeAndAfterAll, Matchers }
import org.typelevel.discipline.Laws
import org.typelevel.discipline.scalatest.Discipline
import zio.blocking.Blocking
Expand All @@ -25,45 +24,19 @@ import zio.interop.catz._
import zio.random.Random
import zio.system.System

trait ConcurrentEffectLawsOverrides[F[_]] extends ConcurrentEffectLaws[F] {

import cats.effect.IO
import scala.concurrent.Promise

override final def runCancelableIsSynchronous[A](fa: F[A]) = {
val lh = Deferred.uncancelable[F, Unit].flatMap { release =>
val latch = Promise[Unit]()
// Never ending task
val ff = F.cancelable[A] { _ =>
// F.runAsync(started.complete(()))(_ => IO.unit).unsafeRunSync()
latch.success(()); release.complete(())
}
// Execute, then cancel after the effect has started
val token = for {
canceler <- F.delay(F.runCancelable(ff)(_ => IO.unit).unsafeRunSync())
_ <- F.liftIO(IO.fromFuture(IO.pure(latch.future)))
_ <- canceler
} yield ()

F.liftIO(F.runAsync(token)(_ => IO.unit).toIO) *> release.get
}
lh <-> F.unit
}
}

object IOConcurrentEffectTests {
def apply()(implicit ce: ConcurrentEffect[Task], cs: ContextShift[Task]): ConcurrentEffectTests[Task] =
new ConcurrentEffectTests[Task] {
def laws =
new ConcurrentEffectLaws[Task] with ConcurrentEffectLawsOverrides[Task] {
new ConcurrentEffectLaws[Task] {
override val F: ConcurrentEffect[Task] = ce
override val contextShift: ContextShift[Task] = cs
}
}
}

class catzSpec
extends FunSuite
extends AnyFunSuite
with BeforeAndAfterAll
with Matchers
with Checkers
Expand Down Expand Up @@ -175,11 +148,11 @@ class catzSpec
import zio.duration._

def eqv(io1: IO[E, A], io2: IO[E, A]): Boolean = {
val v1 = rts.unsafeRunSync(io1.timeout(20.seconds)).map(_.get)
val v2 = rts.unsafeRunSync(io2.timeout(20.seconds)).map(_.get)
val v1 = rts.unsafeRunSync(io1.timeoutFail("Test timed out")(20.seconds))
val v2 = rts.unsafeRunSync(io2.timeoutFail("Test timed out")(20.seconds))
val res = v1 === v2
if (!res) {
println(s"Mismatch: $v1 != $v2")
println(s"Mismatch: ${v1.fold(_.prettyPrint, _.toString)} != ${v2.fold(_.prettyPrint, _.toString)}")
}
res
}
Expand Down
16 changes: 10 additions & 6 deletions project/ScalazBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ object ScalazBuild {
"-language:existentials",
"-explaintypes",
"-Yrangepos",
"-Xfuture",
"-Xsource:2.13",
"-Xlint:_,-type-parameter-shadow",
"-Ywarn-numeric-widen",
Expand All @@ -37,25 +36,30 @@ object ScalazBuild {
buildInfoObject := "BuildInfo"
)

val optimizerOptions = {
Seq(
"-opt:l:inline",
"-opt-inline-from:zio.internal.**"
)
}

def extraOptions(scalaVersion: String) =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, 13)) =>
std2xOptions
std2xOptions ++ optimizerOptions
case Some((2, 12)) =>
Seq(
"-opt-warnings",
"-Ywarn-extra-implicit",
"-Ywarn-unused:_,imports",
"-Ywarn-unused:imports",
"-opt:l:inline",
"-opt-inline-from:zio.internal.**",
"-Ypartial-unification",
"-Yno-adapted-args",
"-Ywarn-inaccessible",
"-Ywarn-infer-any",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit"
) ++ std2xOptions
) ++ std2xOptions ++ optimizerOptions
case Some((2, 11)) =>
Seq(
"-Ypartial-unification",
Expand All @@ -73,7 +77,7 @@ object ScalazBuild {
def stdSettings(prjName: String) = Seq(
name := s"$prjName",
scalacOptions := stdOptions,
crossScalaVersions := Seq("2.12.8", "2.11.12"),
crossScalaVersions := Seq("2.13.0", "2.12.8", "2.11.12"),
scalaVersion in ThisBuild := crossScalaVersions.value.head,
scalacOptions := stdOptions ++ extraOptions(scalaVersion.value),
libraryDependencies ++= compileOnlyDeps ++ testDeps ++ Seq(
Expand Down

0 comments on commit 9e7cda6

Please sign in to comment.