Skip to content

Commit b25f934

Browse files
authored
Merge pull request #183 from armanbilge/feature/js-native
Cross for JS and Native
2 parents 0ea393a + 56decb1 commit b25f934

File tree

5 files changed

+34
-25
lines changed

5 files changed

+34
-25
lines changed

.github/workflows/ci.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
matrix:
2828
os: [ubuntu-latest]
29-
scala: [2.13.8, 3.1.2, 2.12.14]
29+
scala: [2.13.8, 3.2.2, 2.12.14]
3030
java: [temurin@11]
3131
runs-on: ${{ matrix.os }}
3232
steps:
@@ -63,7 +63,7 @@ jobs:
6363
run: sbt ++${{ matrix.scala }} docs/mdoc
6464

6565
- name: Compress target directories
66-
run: tar cf targets.tar target modules/core/target project/target
66+
run: tar cf targets.tar target modules/core/.native/target modules/core/.js/target modules/core/.jvm/target project/target
6767

6868
- name: Upload target directories
6969
uses: actions/upload-artifact@v2
@@ -116,12 +116,12 @@ jobs:
116116
tar xf targets.tar
117117
rm targets.tar
118118
119-
- name: Download target directories (3.1.2)
119+
- name: Download target directories (3.2.2)
120120
uses: actions/download-artifact@v2
121121
with:
122-
name: target-${{ matrix.os }}-3.1.2-${{ matrix.java }}
122+
name: target-${{ matrix.os }}-3.2.2-${{ matrix.java }}
123123

124-
- name: Inflate target directories (3.1.2)
124+
- name: Inflate target directories (3.2.2)
125125
run: |
126126
tar xf targets.tar
127127
rm targets.tar
@@ -162,12 +162,12 @@ jobs:
162162
tar xf targets.tar
163163
rm targets.tar
164164
165-
- name: Download target directories (3.1.2)
165+
- name: Download target directories (3.2.2)
166166
uses: actions/download-artifact@v2
167167
with:
168-
name: target-${{ matrix.os }}-3.1.2-${{ matrix.java }}
168+
name: target-${{ matrix.os }}-3.2.2-${{ matrix.java }}
169169

170-
- name: Inflate target directories (3.1.2)
170+
- name: Inflate target directories (3.2.2)
171171
run: |
172172
tar xf targets.tar
173173
rm targets.tar

build.sbt

+18-13
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Global / excludeLintKeys += scmInfo
1818
val Scala213 = "2.13.8"
1919
ThisBuild / spiewakMainBranches := Seq("main")
2020

21-
ThisBuild / crossScalaVersions := Seq(Scala213, "3.1.2", "2.12.14")
21+
ThisBuild / crossScalaVersions := Seq(Scala213, "3.2.2", "2.12.14")
2222
ThisBuild / scalaVersion := (ThisBuild / crossScalaVersions).value.head
2323
ThisBuild / initialCommands := """
2424
|import cats._, data._, syntax.all._
@@ -34,27 +34,32 @@ ThisBuild / initialCommands := """
3434
ThisBuild / testFrameworks += new TestFramework("munit.Framework")
3535
ThisBuild / Test / parallelExecution := false
3636

37-
def dep(org: String, prefix: String, version: String)(modules: String*)(testModules: String*) =
38-
modules.map(m => org %% (prefix ++ m) % version) ++
39-
testModules.map(m => org %% (prefix ++ m) % version % Test)
37+
def dep(org: String, prefix: String, version: String)(
38+
modules: String*
39+
)(testModules: String*) =
40+
Def.setting {
41+
modules.map(m => org %%% (prefix ++ m) % version) ++
42+
testModules.map(m => org %%% (prefix ++ m) % version % Test)
43+
}
4044

4145
lazy val root = project
4246
.in(file("."))
4347
.enablePlugins(NoPublishPlugin, SonatypeCiReleasePlugin)
44-
.aggregate(core)
48+
.aggregate(core.jvm, core.js, core.native)
4549

46-
lazy val core = project
50+
lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
51+
.crossType(CrossType.Pure)
4752
.in(file("modules/core"))
4853
.settings(
4954
name := "upperbound",
5055
scalafmtOnCompile := true,
5156
libraryDependencies ++=
52-
dep("org.typelevel", "cats-", "2.7.0")("core")() ++
53-
dep("org.typelevel", "cats-effect", "3.3.11")("")("-laws", "-testkit") ++
54-
dep("co.fs2", "fs2-", "3.2.7")("core")() ++
55-
dep("org.scalameta", "munit", "0.7.29")()("", "-scalacheck") ++
56-
dep("org.typelevel", "", "1.0.7")()("munit-cats-effect-3") ++
57-
dep("org.typelevel", "scalacheck-effect", "1.0.3")()("", "-munit")
57+
dep("org.typelevel", "cats-", "2.9.0")("core")().value ++
58+
dep("org.typelevel", "cats-effect", "3.5.0")("")("-laws", "-testkit").value ++
59+
dep("co.fs2", "fs2-", "3.7.0")("core")().value ++
60+
dep("org.scalameta", "munit", "1.0.0-M7")()("", "-scalacheck").value ++
61+
dep("org.typelevel", "", "2.0.0-M3")()("munit-cats-effect").value ++
62+
dep("org.typelevel", "scalacheck-effect", "2.0.0-M2")()("", "-munit").value
5863
)
5964

6065
lazy val docs = project
@@ -71,7 +76,7 @@ lazy val docs = project
7176
githubWorkflowArtifactUpload := false,
7277
fatalWarningsInCI := false
7378
)
74-
.dependsOn(core)
79+
.dependsOn(core.jvm)
7580
.enablePlugins(MdocPlugin, NoPublishPlugin)
7681

7782
ThisBuild / githubWorkflowBuildPostamble ++= List(

modules/core/src/test/scala/BaseSuite.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121

2222
package upperbound
2323

24-
import scala.concurrent.ExecutionContext
2524
import munit.{CatsEffectSuite, ScalaCheckEffectSuite}
2625

2726
abstract class BaseSuite extends CatsEffectSuite with ScalaCheckEffectSuite {
28-
override val munitExecutionContext: ExecutionContext = ExecutionContext.global
27+
def isJS = Option(System.getProperty("java.vm.name")).contains("Scala.js")
2928
}

modules/core/src/test/scala/LimiterSuite.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class LimiterSuite extends BaseSuite {
9393
maxConcurrent = Int.MaxValue,
9494
productionInterval = 1.millis,
9595
producers = 4,
96-
jobsPerProducer = 100,
96+
jobsPerProducer = if (isJS) 10 else 100,
9797
jobCompletion = 0.seconds
9898
)
9999

@@ -108,7 +108,7 @@ class LimiterSuite extends BaseSuite {
108108
maxConcurrent = Int.MaxValue,
109109
productionInterval = 300.millis,
110110
producers = 1,
111-
jobsPerProducer = 100,
111+
jobsPerProducer = if (isJS) 10 else 100,
112112
jobCompletion = 0.seconds
113113
)
114114

project/plugins.sbt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.23.0")
22
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
33
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.24")
4+
5+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.1")
6+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.12")
7+
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.1")
8+
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.1")

0 commit comments

Comments
 (0)