From 89e0d5f7af5b2e0b3982c27e85ced8d36dc3c408 Mon Sep 17 00:00:00 2001 From: Andrea Marcolin Date: Thu, 26 Aug 2021 15:52:36 +0200 Subject: [PATCH] Cross-publish for Scala 3, update Scala and dependencies versions (#327) * Cross-publish for Scala 3, update Scala and dependencies versions * Update kind-projector syntax in docs --- build.sbt | 49 ++++++++++--------- .../test/scala/retry/PackageObjectSpec.scala | 2 +- .../test/scala/retry/RetryPoliciesSpec.scala | 19 +++---- .../scala/retry/RetryPolicyLawsSpec.scala | 4 +- .../test/scala/retry/RetryPolicySpec.scala | 2 +- .../src/test/scala/retry/SyntaxSpec.scala | 2 +- modules/docs/src/main/mdoc/docs/policies.md | 2 +- project/build.properties | 2 +- 8 files changed, 44 insertions(+), 38 deletions(-) diff --git a/build.sbt b/build.sbt index afcfc827..b913cc50 100644 --- a/build.sbt +++ b/build.sbt @@ -1,10 +1,11 @@ import sbtcrossproject.CrossPlugin.autoImport.crossProject -lazy val scalaVersion213 = "2.13.3" -lazy val scalaVersion212 = "2.12.12" -lazy val scalaVersions = List(scalaVersion213, scalaVersion212) +lazy val scalaVersion212 = "2.12.14" +lazy val scalaVersion213 = "2.13.6" +lazy val scalaVersion3 = "3.0.1" +lazy val scalaVersions = List(scalaVersion212, scalaVersion213, scalaVersion3) -ThisBuild / scalaVersion := scalaVersion212 +ThisBuild / scalaVersion := scalaVersion213 val commonSettings = Seq( organization := "com.github.cb372", @@ -38,31 +39,35 @@ val commonSettings = Seq( val moduleSettings = commonSettings ++ Seq( scalacOptions ++= Seq( - "-Xfuture", - "-Ywarn-dead-code", - "-Ywarn-unused", "-deprecation", "-encoding", "UTF-8", "-language:higherKinds", "-unchecked" ), - scalacOptions in (Test, compile) ++= { + Test / compile / scalacOptions ++= { if (scalaVersion.value.startsWith("2.13")) - Nil - else - List("-Ypartial-unification") + List("-Ywarn-dead-code", "-Ywarn-unused") + else if (scalaVersion.value.startsWith("2.12")) + List( + "-Ywarn-dead-code", + "-Ywarn-unused", + "-Ypartial-unification", + "-Xfuture" + ) + else // scala 3.x + List("-language:implicitConversions") }, scalafmtOnCompile := true ) -val catsVersion = "2.5.0" -val catsEffectVersion = "3.1.0" -val catsMtlVersion = "1.2.0" -val scalatestVersion = "3.2.3" -val scalaTestPlusVersion = "3.2.2.0" -val scalacheckVersion = "1.15.2" -val disciplineVersion = "2.1.1" +val catsVersion = "2.6.1" +val catsEffectVersion = "3.1.1" +val catsMtlVersion = "1.2.1" +val scalatestVersion = "3.2.9" +val scalaTestPlusVersion = "3.2.9.0" +val scalacheckVersion = "1.15.4" +val disciplineVersion = "2.1.5" val core = crossProject(JVMPlatform, JSPlatform) .in(file("modules/core")) @@ -76,7 +81,7 @@ val core = crossProject(JVMPlatform, JSPlatform) "org.scalatest" %%% "scalatest" % scalatestVersion % Test, "org.scalacheck" %%% "scalacheck" % scalacheckVersion % Test, "org.typelevel" %%% "cats-laws" % catsVersion % Test, - "org.scalatestplus" %%% "scalacheck-1-14" % scalaTestPlusVersion % Test, + "org.scalatestplus" %%% "scalacheck-1-15" % scalaTestPlusVersion % Test, "org.typelevel" %%% "discipline-scalatest" % disciplineVersion % Test ), mimaPreviousArtifacts := Set.empty @@ -96,7 +101,7 @@ val alleycatsRetry = crossProject(JVMPlatform, JSPlatform) "org.scalatest" %%% "scalatest" % scalatestVersion % Test, "org.scalacheck" %%% "scalacheck" % scalacheckVersion % Test, "org.typelevel" %%% "cats-laws" % catsVersion % Test, - "org.scalatestplus" %%% "scalacheck-1-14" % scalaTestPlusVersion % Test, + "org.scalatestplus" %%% "scalacheck-1-15" % scalaTestPlusVersion % Test, "org.typelevel" %%% "discipline-scalatest" % disciplineVersion % Test ), mimaPreviousArtifacts := Set.empty @@ -131,7 +136,7 @@ val docs = project scalacOptions -= "-Ywarn-unused", scalacOptions += "-Ydelambdafy:inline", addCompilerPlugin( - "org.typelevel" %% "kind-projector" % "0.11.0" cross CrossVersion.full + "org.typelevel" %% "kind-projector" % "0.13.0" cross CrossVersion.full ), crossScalaVersions := Nil, buildInfoPackage := "retry", @@ -147,7 +152,7 @@ val docs = project micrositeGitterChannel := true, micrositeGitterChannelUrl := "typelevel/cats-retry", micrositeTwitterCreator := "@cbirchall", - mdocIn := (sourceDirectory in Compile).value / "mdoc", + mdocIn := (Compile / sourceDirectory).value / "mdoc", micrositeShareOnSocial := true, micrositePushSiteWith := GitHub4s, micrositeGithubToken := sys.env.get("GITHUB_TOKEN") diff --git a/modules/core/shared/src/test/scala/retry/PackageObjectSpec.scala b/modules/core/shared/src/test/scala/retry/PackageObjectSpec.scala index 48c6354d..50e47667 100644 --- a/modules/core/shared/src/test/scala/retry/PackageObjectSpec.scala +++ b/modules/core/shared/src/test/scala/retry/PackageObjectSpec.scala @@ -1,6 +1,6 @@ package retry -import cats.Id +import cats.{Id, catsInstancesForId} import org.scalatest.flatspec.AnyFlatSpec import scala.collection.mutable.ArrayBuffer diff --git a/modules/core/shared/src/test/scala/retry/RetryPoliciesSpec.scala b/modules/core/shared/src/test/scala/retry/RetryPoliciesSpec.scala index 929d4c13..b4dfc5c0 100644 --- a/modules/core/shared/src/test/scala/retry/RetryPoliciesSpec.scala +++ b/modules/core/shared/src/test/scala/retry/RetryPoliciesSpec.scala @@ -3,7 +3,7 @@ package retry import java.util.concurrent.TimeUnit import retry.RetryPolicies._ -import cats.Id +import cats.{Id, catsInstancesForId} import org.scalacheck.{Arbitrary, Gen} import org.scalatest.flatspec.AnyFlatSpec import org.scalatestplus.scalacheck.Checkers @@ -74,9 +74,10 @@ class RetryPoliciesSpec extends AnyFlatSpec with Checkers { behavior of "constantDelay" - it should "always retry with the same delay" in check { status: RetryStatus => - constantDelay[Id](1.second) - .decideNextRetry(status) == PolicyDecision.DelayAndRetry(1.second) + it should "always retry with the same delay" in check { + (status: RetryStatus) => + constantDelay[Id](1.second) + .decideNextRetry(status) == PolicyDecision.DelayAndRetry(1.second) } behavior of "exponentialBackoff" @@ -172,7 +173,7 @@ class RetryPoliciesSpec extends AnyFlatSpec with Checkers { behavior of "limitRetries" it should "retry with no delay until the limit is reached" in check { - status: RetryStatus => + (status: RetryStatus) => val limit = 500 val verdict = limitRetries[Id](limit).decideNextRetry(status) @@ -186,12 +187,12 @@ class RetryPoliciesSpec extends AnyFlatSpec with Checkers { behavior of "capDelay" it should "cap the delay" in { - check { status: RetryStatus => + check { (status: RetryStatus) => capDelay(100.milliseconds, constantDelay[Id](101.milliseconds)) .decideNextRetry(status) == DelayAndRetry(100.milliseconds) } - check { status: RetryStatus => + check { (status: RetryStatus) => capDelay(100.milliseconds, constantDelay[Id](99.milliseconds)) .decideNextRetry(status) == DelayAndRetry(99.milliseconds) } @@ -200,12 +201,12 @@ class RetryPoliciesSpec extends AnyFlatSpec with Checkers { behavior of "limitRetriesByDelay" it should "give up if the underlying policy chooses a delay greater than the threshold" in { - check { status: RetryStatus => + check { (status: RetryStatus) => limitRetriesByDelay(100.milliseconds, constantDelay[Id](101.milliseconds)) .decideNextRetry(status) == GiveUp } - check { status: RetryStatus => + check { (status: RetryStatus) => limitRetriesByDelay(100.milliseconds, constantDelay[Id](99.milliseconds)) .decideNextRetry(status) == DelayAndRetry(99.milliseconds) } diff --git a/modules/core/shared/src/test/scala/retry/RetryPolicyLawsSpec.scala b/modules/core/shared/src/test/scala/retry/RetryPolicyLawsSpec.scala index f544081d..a5bc50a2 100644 --- a/modules/core/shared/src/test/scala/retry/RetryPolicyLawsSpec.scala +++ b/modules/core/shared/src/test/scala/retry/RetryPolicyLawsSpec.scala @@ -1,7 +1,7 @@ package retry import cats.instances.all._ -import cats.{Eq, Monoid, Id} +import cats.{Eq, Monoid, Id, catsInstancesForId} import cats.kernel.laws.discipline.BoundedSemilatticeTests import org.scalacheck.{Arbitrary, Cogen, Gen} import org.scalatest.funsuite.AnyFunSuite @@ -30,7 +30,7 @@ class RetryPolicyLawsSpec implicit val arbitraryPolicyDecision: Arbitrary[PolicyDecision] = Arbitrary(for { - delay <- Gen.choose(0, Long.MaxValue).map(Duration.fromNanos) + delay <- Gen.choose(0L, Long.MaxValue).map(Duration.fromNanos) decision <- Gen .oneOf(PolicyDecision.GiveUp, PolicyDecision.DelayAndRetry(delay)) } yield decision) diff --git a/modules/core/shared/src/test/scala/retry/RetryPolicySpec.scala b/modules/core/shared/src/test/scala/retry/RetryPolicySpec.scala index 680f995c..504af1a1 100644 --- a/modules/core/shared/src/test/scala/retry/RetryPolicySpec.scala +++ b/modules/core/shared/src/test/scala/retry/RetryPolicySpec.scala @@ -1,6 +1,6 @@ package retry -import cats.Id +import cats.{Id, catsInstancesForId} import cats.syntax.semigroup._ import org.scalatest.flatspec.AnyFlatSpec diff --git a/modules/core/shared/src/test/scala/retry/SyntaxSpec.scala b/modules/core/shared/src/test/scala/retry/SyntaxSpec.scala index 697bfb39..4b52348d 100644 --- a/modules/core/shared/src/test/scala/retry/SyntaxSpec.scala +++ b/modules/core/shared/src/test/scala/retry/SyntaxSpec.scala @@ -1,6 +1,6 @@ package retry -import cats.Id +import cats.{Id, catsInstancesForId} import org.scalatest.flatspec.AnyFlatSpec import retry.syntax.all._ diff --git a/modules/docs/src/main/mdoc/docs/policies.md b/modules/docs/src/main/mdoc/docs/policies.md index f167c7ba..bcdc0b58 100644 --- a/modules/docs/src/main/mdoc/docs/policies.md +++ b/modules/docs/src/main/mdoc/docs/policies.md @@ -160,7 +160,7 @@ import cats.data.Kleisli val customPolicy: RetryPolicy[IO] = limitRetries[IO](5).join(constantDelay[IO](100.milliseconds)) -customPolicy.mapK[Kleisli[IO, String, ?]](LiftIO.liftK[Kleisli[IO, String, ?]]) +customPolicy.mapK[Kleisli[IO, String, *]](LiftIO.liftK[Kleisli[IO, String, *]]) ``` diff --git a/project/build.properties b/project/build.properties index d91c272d..10fd9eee 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.6 +sbt.version=1.5.5