Skip to content

Commit

Permalink
Scala Native support (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
joroKr21 authored Apr 13, 2021
1 parent c8b33ce commit 5c528a4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 52 deletions.
34 changes: 3 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
os: [ubuntu-latest]
scala: [2.12.13, 2.13.5]
java: [[email protected]]
ci: [validateJVM, validateJS, validateNative]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -52,17 +53,8 @@ jobs:
- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck

- name: Build and Validate
run: sbt ++${{ matrix.scala }} validate

- name: Compress target directories
run: tar cf targets.tar target core/.js/target core/.jvm/target project/target

- name: Upload target directories
uses: actions/upload-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
path: targets.tar
- name: Validation
run: sbt ++${{ matrix.scala }} '${{ matrix.ci }}'

publish:
name: Publish Artifacts
Expand Down Expand Up @@ -97,26 +89,6 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.12.13)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.12.13-${{ matrix.java }}

- name: Inflate target directories (2.12.13)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.5)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.13.5-${{ matrix.java }}

- name: Inflate target directories (2.13.5)
run: |
tar xf targets.tar
rm targets.tar
- uses: olafurpg/setup-gpg@v3

- env:
Expand Down
21 changes: 15 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,35 @@ lazy val coreSettings =

lazy val kittens = project
.in(file("."))
.aggregate(coreJS, coreJVM)
.dependsOn(coreJS, coreJVM)
.aggregate(coreJS, coreJVM, coreNative)
.dependsOn(coreJS, coreJVM, coreNative)
.settings(coreSettings: _*)
.settings(noPublishSettings)

lazy val core = crossProject(JSPlatform, JVMPlatform)
lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "kittens")
.settings(coreSettings: _*)
.jsSettings(commonJsSettings: _*)

lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val coreNative = core.native

addCommandAlias("root", ";project kittens")
addCommandAlias("jvm", ";project coreJVM")
addCommandAlias("js", ";project coreJS")
addCommandAlias("native", ";project coreNative")

addCommandAlias("validate", "all scalafmtCheckAll scalafmtSbtCheck test doc coreJVM/mimaReportBinaryIssues")
addCommandAlias(
"validateJVM",
"all scalafmtCheckAll scalafmtSbtCheck coreJVM/test coreJVM/doc coreJVM/mimaReportBinaryIssues"
)
addCommandAlias("validateJS", "all coreJS/test")
addCommandAlias("validateNative", "all coreNative/test")
addCommandAlias("mima", "coreJVM/mimaReportBinaryIssues")
addCommandAlias("fmt", "all scalafmtSbt scalafmtAll")
addCommandAlias("fmtCheck", "all scalafmtSbtCheck scalafmtCheckAll")
addCommandAlias("mima", "coreJVM/mimaReportBinaryIssues")

lazy val crossVersionSharedSources: Seq[Setting[_]] = Seq(Compile, Test).map { sc =>
(sc / unmanagedSourceDirectories) ++= (sc / unmanagedSourceDirectories).value.map { dir: File =>
Expand All @@ -102,7 +109,9 @@ lazy val noPublishSettings =
publish / skip := true

ThisBuild / githubWorkflowJavaVersions := Seq("[email protected]")
ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("validate"), id = None, name = Some("Build and Validate")))
ThisBuild / githubWorkflowArtifactUpload := false
ThisBuild / githubWorkflowBuildMatrixAdditions += "ci" -> List("validateJVM", "validateJS", "validateNative")
ThisBuild / githubWorkflowBuild := List(WorkflowStep.Sbt(List("${{ matrix.ci }}"), name = Some("Validation")))
ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v")))
ThisBuild / githubWorkflowPublishPreamble += WorkflowStep.Use(UseRef.Public("olafurpg", "setup-gpg", "v3"))
Expand Down
12 changes: 0 additions & 12 deletions core/src/test/scala/cats/derived/empty.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ class EmptySuite extends KittensSuite {
test(s"$context.Empty[IList[Dummy]]")(assert(iList.empty == INil()))
test(s"$context.Empty[Snoc[Dummy]]")(assert(snoc.empty == SNil()))
test(s"$context.Empty respects existing instances")(assert(box.empty == Box(Mask(0xffffffff))))
// Known limitation of recursive typeclass derivation.
test(s"$context.Empty[Chain] throws a StackOverflowError") {
try { // MUnit doesn't catch fatal errors
chain.empty
fail("Expected a StackOverflowError")
} catch {
case error: Throwable =>
val jvm = error.isInstanceOf[StackOverflowError]
val js = Option(error.getMessage).exists(_.contains("stack size exceeded"))
assert(jvm || js)
}
}
checkAll(s"$context.Empty is Serializable", SerializableTests.serializable(Empty[Interleaved[String]]))
}

Expand Down
8 changes: 5 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.0.0")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.0")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.1")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.1")

0 comments on commit 5c528a4

Please sign in to comment.