Skip to content

Commit

Permalink
Updated to Scala 2.13.10 and 3.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
djspiewak committed Nov 13, 2022
1 parent 5ad4380 commit 66d30c4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 45 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
scala: [3.2.0, 2.12.17, 2.13.8]
scala: [3.2.1, 2.12.17, 2.13.10]
java: [temurin@8, temurin@11, temurin@17, graalvm@11]
ci: [ciJVM, ciNative, ciJS, ciFirefox, ciChrome]
exclude:
- scala: 3.2.0
- scala: 3.2.1
java: temurin@11
- scala: 2.12.17
java: temurin@11
Expand All @@ -36,17 +36,17 @@ jobs:
- scala: 2.12.17
java: graalvm@11
- os: windows-latest
scala: 3.2.0
scala: 3.2.1
- os: macos-latest
scala: 3.2.0
scala: 3.2.1
- os: windows-latest
scala: 2.12.17
- os: macos-latest
scala: 2.12.17
- ci: ciFirefox
scala: 3.2.0
scala: 3.2.1
- ci: ciChrome
scala: 3.2.0
scala: 3.2.1
- ci: ciFirefox
scala: 2.12.17
- ci: ciChrome
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
scala: 2.12.17
- os: macos-latest
ci: ciNative
scala: 3.2.0
scala: 3.2.1
- os: windows-latest
java: graalvm@11
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -203,17 +203,17 @@ jobs:

- name: Check that workflows are up to date
shell: bash
run: sbt '++${{ matrix.scala }}' 'project /' githubWorkflowCheck
run: sbt githubWorkflowCheck

- name: Check that scalafix has been run
if: matrix.scala != '3.2.0' && matrix.os != 'windows-latest'
if: matrix.scala != '3.2.1' && matrix.os != 'windows-latest'
shell: bash
run: sbt '++${{ matrix.scala }}' 'root/scalafixAll --check'

- shell: bash
run: sbt '++${{ matrix.scala }}' '${{ matrix.ci }}'

- if: (matrix.scala == '2.13.8' || matrix.scala == '3.2.0') && matrix.ci == 'ciJVM'
- if: (matrix.scala == '2.13.10' || matrix.scala == '3.2.1') && matrix.ci == 'ciJVM'
shell: bash
run: sbt '++${{ matrix.scala }}' docs/mdoc

Expand All @@ -228,7 +228,7 @@ jobs:
run: example/test-js.sh ${{ matrix.scala }}

- name: Test GraalVM Native Image
if: matrix.scala == '2.13.8' && matrix.java == 'graalvm@11' && matrix.os == 'ubuntu-latest'
if: matrix.scala == '2.13.10' && matrix.java == 'graalvm@11' && matrix.os == 'ubuntu-latest'
shell: bash
run: sbt '++${{ matrix.scala }}' graalVMExample/nativeImage graalVMExample/nativeImageRun

Expand All @@ -238,7 +238,7 @@ jobs:
run: example/test-native.sh ${{ matrix.scala }}

- name: Scalafix tests
if: matrix.scala == '2.13.8' && matrix.ci == 'ciJVM' && matrix.os == 'ubuntu-latest'
if: matrix.scala == '2.13.10' && matrix.ci == 'ciJVM' && matrix.os == 'ubuntu-latest'
shell: bash
run: |
cd scalafix
Expand All @@ -250,7 +250,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.8]
scala: [2.13.10]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down
6 changes: 4 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ val Windows = "windows-latest"
val MacOS = "macos-latest"

val Scala212 = "2.12.17"
val Scala213 = "2.13.8"
val Scala3 = "3.2.0"
val Scala213 = "2.13.10"
val Scala3 = "3.2.1"

ThisBuild / crossScalaVersions := Seq(Scala3, Scala212, Scala213)
ThisBuild / tlVersionIntroduced := Map("3" -> "3.1.1")
Expand Down Expand Up @@ -767,6 +767,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
} else Seq()
}
)
.nativeSettings(tlFatalWarnings := false)

/**
* Test support for the core project, providing various helpful instances like ScalaCheck
Expand Down Expand Up @@ -882,6 +883,7 @@ lazy val std = crossProject(JSPlatform, JVMPlatform, NativePlatform)
ProblemFilters.exclude[MissingClassProblem]("cats.effect.std.JavaSecureRandom$")
)
)
.nativeSettings(tlFatalWarnings := false)

/**
* A trivial pair of trivial example apps primarily used to show that IOApp works as a practical
Expand Down
5 changes: 3 additions & 2 deletions core/shared/src/main/scala/cats/effect/IO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ sealed abstract class IO[+A] private () extends IOPlatform[A] {
Resource.make(startOn(ec))(_.cancel).map(_.join)

def forceR[B](that: IO[B]): IO[B] =
handleError(_ => ()).productR(that)
// cast is needed here to trick the compiler into avoiding the IO[Any]
asInstanceOf[IO[Unit]].handleError(_ => ()).productR(that)

/**
* Monadic bind on `IO`, used for sequentially composing two `IO` actions, where the value
Expand Down Expand Up @@ -1957,7 +1958,7 @@ private object SyncStep {
case Left(io) => Left(io.attempt)
case Right((a, limit)) => Right((a.asRight[Throwable], limit))
}
.handleError(t => Right((t.asLeft[IO[B]], limit - 1)))
.handleError(t => (t.asLeft, limit - 1).asRight)

case IO.HandleErrorWith(ioe, f, _) =>
interpret(ioe, limit - 1)
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1"

addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.5.0-M5")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.5.0-M6")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
Expand Down
19 changes: 6 additions & 13 deletions tests/shared/src/test/scala/cats/effect/std/DispatcherSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DispatcherSpec extends BaseSpec {
0.until(length) foreach { i =>
runner.unsafeRunAndForget(results.update(_ :+ i).guarantee(gate.release))
}
} *> gate.await.timeoutTo(2.seconds, IO(false must beTrue))
} *> gate.await
}

vec <- results.get
Expand Down Expand Up @@ -142,7 +142,7 @@ class DispatcherSpec extends BaseSpec {
_ <- rec.use(_ => gate1.acquireN(2)).start

// if both are not run in parallel, then this will hang
_ <- gate2.acquireN(2).timeoutTo(2.seconds, IO(false must beTrue))
_ <- gate2.acquireN(2)
} yield ok
}
}
Expand All @@ -165,9 +165,7 @@ class DispatcherSpec extends BaseSpec {
_ <- {
val rec = dispatcher flatMap { runner =>
Resource eval {
subjects
.parTraverse_(act => IO(runner.unsafeRunAndForget(act)))
.timeoutTo(2.seconds, IO(false must beTrue))
subjects.parTraverse_(act => IO(runner.unsafeRunAndForget(act)))
}
}

Expand All @@ -188,7 +186,7 @@ class DispatcherSpec extends BaseSpec {
0.until(length) foreach { i =>
runner.unsafeRunAndForget(results.update(_ :+ i).guarantee(gate.release))
}
} *> gate.await.timeoutTo(2.seconds, IO(false must beTrue))
} *> gate.await
}

vec <- results.get
Expand Down Expand Up @@ -296,9 +294,7 @@ class DispatcherSpec extends BaseSpec {
_ <- cdl.await // make sure the execution of fiber has started
} yield ()
}.start
_ <- releaseInner
.await
.timeoutTo(2.seconds, IO(false must beTrue)) // release process has started
_ <- releaseInner.await // release process has started
released1 <- fiber.join.as(true).timeoutTo(200.millis, IO(false))
_ <- fiberLatch.release
released2 <- fiber.join.as(true).timeoutTo(200.millis, IO(false))
Expand All @@ -323,10 +319,7 @@ class DispatcherSpec extends BaseSpec {
} yield ()
}

test.handleError(_ => ()) >> canceled
.get
.as(ok)
.timeoutTo(2.seconds, IO(false must beTrue))
test.handleError(_ => ()) >> canceled.get.as(ok)
}
}
}
Expand Down
22 changes: 8 additions & 14 deletions tests/shared/src/test/scala/cats/effect/std/QueueSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ class BoundedQueueSpec extends BaseSpec with QueueTests[Queue] with DetectPlatfo
// with the bug, this will timeout since both will block
// with the bug fix, either the join will return immediately, or it will
// be unblocked by the offer
_ <- IO
.race(taker.joinWithNever, q.offer(()).delayBy(500.millis))
.timeoutTo(5.seconds, IO(false must beTrue))
_ <- IO.race(taker.joinWithNever, q.offer(()).delayBy(500.millis))
} yield ()

test.parReplicateA(if (isJS || isNative) 1 else 1000).as(ok)
Expand Down Expand Up @@ -272,18 +270,14 @@ class BoundedQueueSpec extends BaseSpec with QueueTests[Queue] with DetectPlatfo
offerers &> takers
}

action.as(ok).timeoutTo(8.seconds, IO(false must beTrue))
action.as(ok)
}

"offer/take with a single consumer and high contention" in real {
constructor(8) flatMap { q =>
val offerer = List.fill(8)(List.fill(8)(0)).parTraverse_(_.traverse(q.offer(_)))

(offerer &> 0
.until(8 * 8)
.toList
.traverse_(_ => q.take)
.timeoutTo(8.seconds, IO(false must beTrue))).replicateA_(1000) *>
(offerer &> 0.until(8 * 8).toList.traverse_(_ => q.take)).replicateA_(1000) *>
q.size.flatMap(s => IO(s mustEqual 0))
}
}
Expand All @@ -306,7 +300,7 @@ class BoundedQueueSpec extends BaseSpec with QueueTests[Queue] with DetectPlatfo
}
}

(offerer &> taker(0).timeoutTo(8.seconds, IO(false must beTrue))).replicateA_(1000) *>
(offerer &> taker(0)).replicateA_(1000) *>
q.size.flatMap(s => IO(s mustEqual 0))
}
}
Expand Down Expand Up @@ -535,7 +529,7 @@ trait QueueTests[Q[_[_], _]] { self: BaseSpec =>

_ <-
if (results.nonEmpty)
expected.await.timeoutTo(2.seconds, IO(false must beTrue))
expected.await
else
IO(skipped("did not take any results"))
} yield ok
Expand All @@ -558,7 +552,7 @@ trait QueueTests[Q[_[_], _]] { self: BaseSpec =>

// release whatever we didn't receive
_ <- expected.release.replicateA_(5 - results.length)
_ <- expected.await.timeoutTo(2.seconds, IO(false must beTrue))
_ <- expected.await
} yield ()

test.parReplicateA(10).as(ok)
Expand Down Expand Up @@ -679,7 +673,7 @@ trait QueueTests[Q[_[_], _]] { self: BaseSpec =>
offer2.cancel
else
// if neither offerer resumed, then we'll be false from offer1 and offer2.join will hang
offer2.join.timeoutTo(2.seconds, IO(false must beTrue))
offer2.join
} yield ()

test.parReplicateA(16).as(ok)
Expand Down Expand Up @@ -826,7 +820,7 @@ trait QueueTests[Q[_[_], _]] { self: BaseSpec =>
case Some(_) => take2.cancel

// if neither taker got the element, then we'll be None from take1 and take2.join will hang
case None => take2.join.timeoutTo(2.seconds, IO(false must beTrue))
case None => take2.join
}
} yield ()

Expand Down

0 comments on commit 66d30c4

Please sign in to comment.