Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,3 @@ jvm_highcore_task:
script: sbt '++ 2.13' testsJVM/test ioAppTestsJVM/test
- name: JVM high-core-count 3
script: sbt '++ 3' testsJVM/test ioAppTestsJVM/test

native_highcore_task:
only_if: $CIRRUS_TAG != '' || $CIRRUS_PR != ''
required_pr_labels: Cirrus Native
container:
dockerfile: .cirrus/Dockerfile
cpu: 8
memory: 16G
matrix:
- name: Native high-core-count 2.13
script: sbt '++ 2.13' testsNative/test ioAppTestsNative/test
- name: Native high-core-count 3
script: sbt '++ 3' testsNative/test ioAppTestsNative/test
9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
java: temurin@11
- scala: 3.3.5
java: temurin@21
- scala: 3.3.5
java: graalvm@21
- scala: 2.12.20
java: temurin@11
- scala: 2.12.20
Expand Down Expand Up @@ -323,11 +325,6 @@ jobs:
shell: bash
run: example/test-native.sh ${{ matrix.scala }}

- name: Test GraalVM Native Image
if: (matrix.scala == '2.13.16' || matrix.scala == '3.3.5') && matrix.java == 'graalvm@21' && matrix.os == 'ubuntu-latest'
shell: bash
run: sbt '++ ${{ matrix.scala }}' graalVMExample/nativeImage graalVMExample/nativeImageRun

- name: Scalafix tests
if: matrix.scala == '2.13.16' && matrix.ci == 'ciJVM' && matrix.os == 'ubuntu-latest'
shell: bash
Expand Down Expand Up @@ -670,5 +667,5 @@ jobs:
- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
modules-ignore: cats-effect-benchmarks_3 cats-effect-benchmarks_2.12 cats-effect-benchmarks_2.13 cats-effect_3 cats-effect_2.12 cats-effect_2.13 cats-effect-example_sjs1_3 cats-effect-example_sjs1_2.12 cats-effect-example_sjs1_2.13 rootjs_3 rootjs_2.12 rootjs_2.13 ioapptestsnative_3 ioapptestsnative_2.12 ioapptestsnative_2.13 cats-effect-graalvm-example_3 cats-effect-graalvm-example_2.12 cats-effect-graalvm-example_2.13 cats-effect-tests_sjs1_3 cats-effect-tests_sjs1_2.12 cats-effect-tests_sjs1_2.13 rootjvm_3 rootjvm_2.12 rootjvm_2.13 rootnative_3 rootnative_2.12 rootnative_2.13 cats-effect-example_native0.5_3 cats-effect-example_native0.5_2.12 cats-effect-example_native0.5_2.13 cats-effect-example_3 cats-effect-example_2.12 cats-effect-example_2.13 cats-effect-tests_3 cats-effect-tests_2.12 cats-effect-tests_2.13 ioapptestsjvm_3 ioapptestsjvm_2.12 ioapptestsjvm_2.13 ioapptestsjs_3 ioapptestsjs_2.12 ioapptestsjs_2.13 cats-effect-tests_native0.5_3 cats-effect-tests_native0.5_2.12 cats-effect-tests_native0.5_2.13
modules-ignore: cats-effect-benchmarks_3 cats-effect-benchmarks_2.12 cats-effect-benchmarks_2.13 cats-effect_3 cats-effect_2.12 cats-effect_2.13 cats-effect-example_sjs1_3 cats-effect-example_sjs1_2.12 cats-effect-example_sjs1_2.13 rootjs_3 rootjs_2.12 rootjs_2.13 ioapptestsnative_3 ioapptestsnative_2.12 ioapptestsnative_2.13 cats-effect-graalvm-example_3 cats-effect-graalvm-example_2.12 cats-effect-graalvm-example_2.13 cats-effect-tests_sjs1_3 cats-effect-tests_sjs1_2.12 cats-effect-tests_sjs1_2.13 rootjvm_3 rootjvm_2.12 rootjvm_2.13 rootnative_3 rootnative_2.12 rootnative_2.13 cats-effect-example_native0.4_3 cats-effect-example_native0.4_2.12 cats-effect-example_native0.4_2.13 cats-effect-example_3 cats-effect-example_2.12 cats-effect-example_2.13 cats-effect-tests_3 cats-effect-tests_2.12 cats-effect-tests_2.13 ioapptestsjvm_3 ioapptestsjvm_2.12 ioapptestsjvm_2.13 ioapptestsjs_3 ioapptestsjs_2.12 ioapptestsjs_2.13 cats-effect-tests_native0.4_3 cats-effect-tests_native0.4_2.12 cats-effect-tests_native0.4_2.13
configs-ignore: test scala-tool scala-doc-tool test-internal
125 changes: 57 additions & 68 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@
*/

import java.io.File
import java.util.concurrent.TimeUnit

import com.typesafe.tools.mima.core._
import com.github.sbt.git.SbtGit.GitKeys._
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.firefox.{FirefoxOptions, FirefoxProfile}
import org.scalajs.jsenv.nodejs.NodeJSEnv
import org.scalajs.jsenv.selenium.SeleniumJSEnv
import org.scalajs.linker.interface.OutputPatterns
import sbtcrossproject.CrossProject
import scala.scalanative.build._

import JSEnv._

lazy val inCI = Option(System.getenv("CI")).contains("true")

// sbt-git workarounds
ThisBuild / useConsoleForROGit := !inCI
ThisBuild / useConsoleForROGit := !Option(System.getenv("CI")).contains("true")

ThisBuild / git.gitUncommittedChanges := {
if ((ThisBuild / githubIsWorkflowBuild).value) {
Expand All @@ -43,11 +42,12 @@ ThisBuild / git.gitUncommittedChanges := {
}
}

ThisBuild / tlBaseVersion := "3.7"
ThisBuild / tlBaseVersion := "3.6"
ThisBuild / tlUntaggedAreSnapshots := false

ThisBuild / organization := "org.typelevel"
ThisBuild / organizationName := "Typelevel"
ThisBuild / tlSonatypeUseLegacyHost := false

ThisBuild / startYear := Some(2020)

Expand Down Expand Up @@ -204,12 +204,6 @@ ThisBuild / githubWorkflowBuild := Seq("JVM", "JS", "Native").map { platform =>
name = Some("Test Example Native App Using Binary"),
cond = Some(s"matrix.ci == 'ciNative' && matrix.os == '$PrimaryOS'")
),
WorkflowStep.Sbt(
List("graalVMExample/nativeImage", "graalVMExample/nativeImageRun"),
name = Some("Test GraalVM Native Image"),
cond = Some(
s"(matrix.scala == '$Scala213' || matrix.scala == '$Scala3') && matrix.java == '${GraalVM.render}' && matrix.os == '$PrimaryOS'")
),
WorkflowStep.Run(
List("cd scalafix", "sbt test"),
name = Some("Scalafix tests"),
Expand All @@ -233,7 +227,7 @@ ThisBuild / githubWorkflowBuildMatrixExclusions := {
val scalaJavaFilters = for {
scala <- (ThisBuild / githubWorkflowScalaVersions).value.filterNot(Set(Scala213))
java <- (ThisBuild / githubWorkflowJavaVersions).value.filterNot(Set(OldGuardJava))
if !(scala == Scala3 && (java == LatestJava || java == GraalVM))
if !(scala == Scala3 && java == LatestJava)
} yield MatrixExclude(Map("scala" -> scala, "java" -> java.render))

val armFilters =
Expand Down Expand Up @@ -295,6 +289,14 @@ lazy val useJSEnv =
settingKey[JSEnv]("Use Node.js or a headless browser for running Scala.js tests")
Global / useJSEnv := NodeJS

lazy val nodeJSWasmEnv = new NodeJSEnv(
NodeJSEnv
.Config()
.withArgs(List("--experimental-wasm-exnref"))
.withEnv(Map("WASM_MODE" -> "true"))
.withSourceMap(true)
)

ThisBuild / jsEnv := {
useJSEnv.value match {
case NodeJS => new NodeJSEnv(NodeJSEnv.Config().withSourceMap(true))
Expand All @@ -309,6 +311,8 @@ ThisBuild / jsEnv := {
val options = new ChromeOptions()
options.setHeadless(true)
new SeleniumJSEnv(options)
case WASM =>
nodeJSWasmEnv
}
}

Expand All @@ -325,52 +329,28 @@ ThisBuild / autoAPIMappings := true

ThisBuild / Test / testOptions += Tests.Argument("+l")

val CatsVersion = "2.13.0"
val CatsMtlVersion = "1.5.0"
val ScalaCheckVersion = "1.18.1"
val CoopVersion = "1.3.0"
val MUnitVersion = "1.1.0"
val MUnitScalaCheckVersion = "1.1.0"
val DisciplineMUnitVersion = "2.0.0"
val CatsVersion = "2.11.0"
val CatsMtlVersion = "1.3.1"
val ScalaCheckVersion = "1.17.1"
val CoopVersion = "1.2.0"
val MUnitVersion = "1.0.0-M11"
val MUnitScalaCheckVersion = "1.0.0-M11"
val DisciplineMUnitVersion = "2.0.0-M3"

val MacrotaskExecutorVersion = "1.1.1"

Global / tlCommandAliases ++= Map(
CI.JVM.commandAlias,
CI.Native.commandAlias,
CI.JS.commandAlias,
CI.Firefox.commandAlias,
CI.Chrome.commandAlias
)

Global / tlCommandAliases ++= Map(
"ci" -> CI.AllCIs.flatMap(_.commands)
)

Global / tlCommandAliases ++= Map(
"release" -> List("tlRelease")
)
tlReplaceCommandAlias("ci", CI.AllCIs.map(_.toString).mkString)
addCommandAlias("release", "tlRelease")

Global / tlCommandAliases ++= Map(
"prePR" -> List(
"root/clean",
"+root/headerCreate",
"root/scalafixAll",
"scalafmtSbt",
"+root/scalafmtAll"
)
)
addCommandAlias(CI.JVM.command, CI.JVM.toString)
addCommandAlias(CI.Native.command, CI.Native.toString)
addCommandAlias(CI.JS.command, CI.JS.toString)
addCommandAlias(CI.Firefox.command, CI.Firefox.toString)
addCommandAlias(CI.Chrome.command, CI.Chrome.toString)

lazy val nativeTestSettings = Seq(
nativeConfig ~= { c => // TODO: remove this when it seems to work
c.withSourceLevelDebuggingConfig(_.enableAll) // enable generation of debug information
.withOptimize(false) // disable Scala Native optimizer
.withMode(Mode.debug) // compile using LLVM without optimizations
.withCompileOptions(c.compileOptions ++ Seq("-gdwarf-4"))
},
envVars ++= { if (inCI) Map("GC_MAXIMUM_HEAP_SIZE" -> "8g") else Map.empty[String, String] },
parallelExecution := !inCI
)
tlReplaceCommandAlias(
"prePR",
"; root/clean; +root/headerCreate; root/scalafixAll; scalafmtSbt; +root/scalafmtAll")

val jsProjects: Seq[ProjectReference] =
Seq(
Expand Down Expand Up @@ -455,7 +435,7 @@ lazy val kernel = crossProject(JSPlatform, JVMPlatform, NativePlatform)
libraryDependencies += "org.scala-js" %%% "scala-js-macrotask-executor" % MacrotaskExecutorVersion % Test
)
.nativeSettings(
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.6.0"
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.5.0"
)

/**
Expand Down Expand Up @@ -901,12 +881,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
ProblemFilters.exclude[MissingClassProblem](
"cats.effect.metrics.JsCpuStarvationMetrics"),
ProblemFilters.exclude[MissingClassProblem](
"cats.effect.metrics.JsCpuStarvationMetrics$"),
// all package-private classes; introduced when we made Native multithreaded
ProblemFilters.exclude[MissingClassProblem]("cats.effect.unsafe.FiberExecutor"),
ProblemFilters.exclude[IncompatibleMethTypeProblem](
"cats.effect.unsafe.FiberMonitorImpl.this"),
ProblemFilters.exclude[MissingClassProblem]("cats.effect.unsafe.FiberMonitorPlatform")
"cats.effect.metrics.JsCpuStarvationMetrics$")
)
},
mimaBinaryIssueFilters ++= {
Expand Down Expand Up @@ -963,12 +938,11 @@ lazy val testkit = crossProject(JSPlatform, JVMPlatform, NativePlatform)
"org.scalacheck" %%% "scalacheck" % ScalaCheckVersion
)
)
.nativeSettings(nativeTestSettings)

/**
* Unit tests for the core project, utilizing the support provided by testkit.
*/
lazy val tests: CrossProject = crossProject(JSPlatform, JVMPlatform, NativePlatform)
lazy val tests = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.in(file("tests"))
.dependsOn(core, laws % Test, kernelTestkit % Test, testkit % Test)
.enablePlugins(NoPublishPlugin)
Expand All @@ -985,18 +959,33 @@ lazy val tests: CrossProject = crossProject(JSPlatform, JVMPlatform, NativePlatf
githubWorkflowArtifactUpload := false
)
.jsSettings(
Compile / scalaJSUseMainModuleInitializer := true,
Compile / mainClass := Some("catseffect.examples.JSRunner"),
// The default configured mapSourceURI is used for trace filtering
scalacOptions ~= { _.filterNot(_.startsWith("-P:scalajs:mapSourceURI")) }
Test / jsEnv := new NodeJSEnv(
NodeJSEnv
.Config()
.withArgs(
List(
"--experimental-wasm-exnref",
"--experimental-wasm-imported-strings",
"--turboshaft-wasm"
))
.withSourceMap(true)
),
scalaJSLinkerConfig ~= {
_.withExperimentalUseWebAssembly(true)
.withModuleKind(ModuleKind.ESModule)
.withOutputPatterns(OutputPatterns.fromJSFile("%s.mjs"))
.withClosureCompiler(false)
}
)
.jvmSettings(
fork := true,
Test / javaOptions += "-Dcats.effect.trackFiberContext=true"
)
.nativeSettings(
Compile / mainClass := Some("catseffect.examples.NativeRunner"),
nativeTestSettings
Test / unmanagedSourceDirectories += {
(LocalRootProject / baseDirectory).value / "tests" / "shared" / "src" / "native" / "test" / "scala"
}
)

def configureIOAppTests(p: Project): Project =
Expand All @@ -1007,7 +996,7 @@ def configureIOAppTests(p: Project): Project =
buildInfoPackage := "cats.effect",
buildInfoKeys ++= Seq(
"jsRunner" -> (tests.js / Compile / fastOptJS / artifactPath).value,
"nativeRunner" -> (tests.native / Compile / crossTarget).value / (tests.native / Compile / moduleName).value
"nativeRunner" -> (tests.native / Compile / nativeLink / artifactPath).value
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
*/

package cats.effect
package example
package unsafe

object Example extends IOApp {
def run(args: List[String]): IO[ExitCode] =
(IO.println(args(0)).replicateA_(5) >>
IO.println(args(1)).replicateA_(5)).replicateA_(2).as(ExitCode(2))
/**
* An introspectable executor that runs fibers. Useful for fiber dumps.
*/
private[unsafe] trait FiberExecutor {
def liveTraces(): Map[IOFiber[?], Trace]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
package cats.effect
package unsafe

import scala.concurrent.ExecutionContext
import scala.scalajs.{js, LinkingInfo}

private[effect] sealed abstract class FiberMonitor extends FiberMonitorShared {

/**
Expand All @@ -44,8 +41,8 @@ private[effect] sealed abstract class FiberMonitor extends FiberMonitorShared {

private final class FiberMonitorImpl(
// A reference to the compute pool of the `IORuntime` in which this suspended fiber bag
// operates. `null` if the compute pool of the `IORuntime` is not a `BatchingMacrotaskExecutor`.
private[this] val compute: BatchingMacrotaskExecutor
// operates. `null` if the compute pool of the `IORuntime` is not a `FiberExecutor`.
private[this] val compute: FiberExecutor
) extends FiberMonitor {
private[this] val bag = new WeakBag[IOFiber[?]]()

Expand Down Expand Up @@ -95,26 +92,4 @@ private final class NoOpFiberMonitor extends FiberMonitor {
def liveFiberSnapshot(print: String => Unit): Unit = ()
}

private[effect] object FiberMonitor {
def apply(compute: ExecutionContext): FiberMonitor = {
if (LinkingInfo.developmentMode && weakRefsAvailable) {
if (compute.isInstanceOf[BatchingMacrotaskExecutor]) {
val bmec = compute.asInstanceOf[BatchingMacrotaskExecutor]
new FiberMonitorImpl(bmec)
} else {
new FiberMonitorImpl(null)
}
} else {
new NoOpFiberMonitor()
}
}

private[this] final val Undefined = "undefined"

/**
* Feature-tests for all the required, well, features :)
*/
private[unsafe] def weakRefsAvailable: Boolean =
js.typeOf(js.Dynamic.global.WeakRef) != Undefined &&
js.typeOf(js.Dynamic.global.FinalizationRegistry) != Undefined
}
private[effect] object FiberMonitor extends FiberMonitorPlatform
Loading
Loading