Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala Native support #319

Merged
merged 1 commit into from
Apr 13, 2021
Merged
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
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: [adopt@1.8]
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("adopt@1.8")
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")