diff --git a/.circleci/config.yml b/.circleci/config.yml index b8458bdb..7f33174f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -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 @@ -124,6 +157,18 @@ 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: @@ -131,6 +176,8 @@ workflows: - test211_js_jdk8 - test212_jvm_jdk8 - test212_js_jdk8 + - test213_jvm_jdk8 + - test213_js_jdk8 filters: branches: ignore: /.*/ diff --git a/build.sbt b/build.sbt index ab08eb04..8bd1cbbb 100644 --- a/build.sbt +++ b/build.sbt @@ -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 diff --git a/interop-cats/jvm/src/test/scala/zio/interop/ExtraMonadTests.scala b/interop-cats/jvm/src/test/scala/zio/interop/ExtraMonadTests.scala index ec888a8b..34779571 100644 --- a/interop-cats/jvm/src/test/scala/zio/interop/ExtraMonadTests.scala +++ b/interop-cats/jvm/src/test/scala/zio/interop/ExtraMonadTests.scala @@ -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 } @@ -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)) } } diff --git a/interop-cats/jvm/src/test/scala/zio/interop/catzMtlSpec.scala b/interop-cats/jvm/src/test/scala/zio/interop/catzMtlSpec.scala index a74da43e..6bb1f1cd 100644 --- a/interop-cats/jvm/src/test/scala/zio/interop/catzMtlSpec.scala +++ b/interop-cats/jvm/src/test/scala/zio/interop/catzMtlSpec.scala @@ -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 @@ -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 diff --git a/interop-cats/jvm/src/test/scala/zio/interop/catzSpec.scala b/interop-cats/jvm/src/test/scala/zio/interop/catzSpec.scala index d07b451e..a4e528ce 100644 --- a/interop-cats/jvm/src/test/scala/zio/interop/catzSpec.scala +++ b/interop-cats/jvm/src/test/scala/zio/interop/catzSpec.scala @@ -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 @@ -25,37 +24,11 @@ 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 } @@ -63,7 +36,7 @@ object IOConcurrentEffectTests { } class catzSpec - extends FunSuite + extends AnyFunSuite with BeforeAndAfterAll with Matchers with Checkers @@ -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 } diff --git a/project/ScalazBuild.scala b/project/ScalazBuild.scala index 2011da8d..e9b2783c 100644 --- a/project/ScalazBuild.scala +++ b/project/ScalazBuild.scala @@ -24,7 +24,6 @@ object ScalazBuild { "-language:existentials", "-explaintypes", "-Yrangepos", - "-Xfuture", "-Xsource:2.13", "-Xlint:_,-type-parameter-shadow", "-Ywarn-numeric-widen", @@ -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", @@ -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(