Skip to content

Commit

Permalink
Cross-publish for Scala 3, update Scala and dependencies versions (#327)
Browse files Browse the repository at this point in the history
* Cross-publish for Scala 3, update Scala and dependencies versions

* Update kind-projector syntax in docs
  • Loading branch information
andreamarcolin authored Aug 26, 2021
1 parent 37612f4 commit 89e0d5f
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 38 deletions.
49 changes: 27 additions & 22 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"))
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package retry

import cats.Id
import cats.{Id, catsInstancesForId}
import org.scalatest.flatspec.AnyFlatSpec

import scala.collection.mutable.ArrayBuffer
Expand Down
19 changes: 10 additions & 9 deletions modules/core/shared/src/test/scala/retry/RetryPoliciesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package retry

import cats.Id
import cats.{Id, catsInstancesForId}
import cats.syntax.semigroup._
import org.scalatest.flatspec.AnyFlatSpec

Expand Down
2 changes: 1 addition & 1 deletion modules/core/shared/src/test/scala/retry/SyntaxSpec.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package retry

import cats.Id
import cats.{Id, catsInstancesForId}
import org.scalatest.flatspec.AnyFlatSpec
import retry.syntax.all._

Expand Down
2 changes: 1 addition & 1 deletion modules/docs/src/main/mdoc/docs/policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, *]])
```


Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.4.6
sbt.version=1.5.5

0 comments on commit 89e0d5f

Please sign in to comment.