Skip to content

Commit

Permalink
Merge pull request #429 from armanbilge/feature/native
Browse files Browse the repository at this point in the history
Cross-build for Native
  • Loading branch information
sh0hei authored Jun 21, 2022
2 parents 684f069 + fc0fe9f commit 2d193a2
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 25 deletions.
66 changes: 50 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [3.1.1, 2.12.15, 2.13.8]
scala: [3.1.2, 2.12.16, 2.13.8]
java: [temurin@8]
project: [rootJS, rootJVM]
project: [rootJS, rootJVM, rootNative]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -77,6 +77,10 @@ jobs:
if: matrix.project == 'rootJS'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/scalaJSLinkerResult

- name: nativeLink
if: matrix.project == 'rootNative'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/nativeLink

- name: Test
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test

Expand All @@ -90,11 +94,11 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p target unidocs/target .js/target site/target core/.js/target laws/.js/target core/.jvm/target tests/.js/target .jvm/target .native/target laws/.jvm/target tests/.jvm/target project/target
run: mkdir -p target unidocs/target .js/target core/.native/target site/target laws/.native/target core/.js/target laws/.js/target core/.jvm/target tests/js/target .jvm/target .native/target laws/.jvm/target tests/jvm/target tests/native/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar target unidocs/target .js/target site/target core/.js/target laws/.js/target core/.jvm/target tests/.js/target .jvm/target .native/target laws/.jvm/target tests/.jvm/target project/target
run: tar cf targets.tar target unidocs/target .js/target core/.native/target site/target laws/.native/target core/.js/target laws/.js/target core/.jvm/target tests/js/target .jvm/target .native/target laws/.jvm/target tests/jvm/target tests/native/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
Expand Down Expand Up @@ -147,42 +151,62 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

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

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

- name: Inflate target directories (3.1.2, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.1.2, rootNative)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.1-rootJS
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.2-rootNative

- name: Inflate target directories (3.1.1, rootJS)
- name: Inflate target directories (3.1.2, rootNative)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.1.1, rootJVM)
- name: Download target directories (2.12.16, rootJS)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.1-rootJVM
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-rootJS

- name: Inflate target directories (3.1.1, rootJVM)
- name: Inflate target directories (2.12.16, rootJS)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.12.15, rootJS)
- name: Download target directories (2.12.16, rootJVM)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJS
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-rootJVM

- name: Inflate target directories (2.12.15, rootJS)
- name: Inflate target directories (2.12.16, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.12.15, rootJVM)
- name: Download target directories (2.12.16, rootNative)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJVM
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-rootNative

- name: Inflate target directories (2.12.15, rootJVM)
- name: Inflate target directories (2.12.16, rootNative)
run: |
tar xf targets.tar
rm targets.tar
Expand All @@ -207,6 +231,16 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.8, rootNative)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootNative

- name: Inflate target directories (2.13.8, rootNative)
run: |
tar xf targets.tar
rm targets.tar
- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
run: echo $PGP_SECRET | base64 -di | gpg --import
Expand Down
25 changes: 16 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ThisBuild / tlBaseVersion := "1.2"
ThisBuild / tlBaseVersion := "1.3"
ThisBuild / startYear := Some(2021)
ThisBuild / developers := List(
tlGitHubDev("SystemFw", "Fabio Labella"),
Expand All @@ -11,7 +11,7 @@ ThisBuild / developers := List(

val Scala213 = "2.13.8"

ThisBuild / crossScalaVersions := Seq("3.1.1", "2.12.15", Scala213)
ThisBuild / crossScalaVersions := Seq("3.1.2", "2.12.16", Scala213)
ThisBuild / tlVersionIntroduced := Map("3" -> "1.2.1")

lazy val commonJvmSettings = Seq(
Expand All @@ -22,39 +22,46 @@ lazy val commonJsSettings = Seq(
doctestGenTests := Seq.empty
)

val CatsVersion = "2.7.0"
lazy val commonNativeSettings = Seq(
doctestGenTests := Seq.empty,
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "1.3.0").toMap
)

val CatsVersion = "2.8.0"

lazy val root = tlCrossRootProject.aggregate(core, laws, tests)

lazy val core = crossProject(JSPlatform, JVMPlatform)
lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(name := "cats-mtl")
.settings(
libraryDependencies += "org.typelevel" %%% "cats-core" % CatsVersion
)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)

lazy val laws = crossProject(JSPlatform, JVMPlatform)
lazy val laws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.dependsOn(core)
.settings(name := "cats-mtl-laws")
.settings(libraryDependencies += "org.typelevel" %%% "cats-laws" % CatsVersion)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)

lazy val tests = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
lazy val tests = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.dependsOn(core, laws)
.enablePlugins(NoPublishPlugin)
.settings(name := "cats-mtl-tests")
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-testkit" % CatsVersion,
"org.scalameta" %%% "munit" % "0.7.29",
"org.typelevel" %%% "discipline-munit" % "1.0.9"))
"org.scalameta" %%% "munit" % "1.0.0-M5",
"org.typelevel" %%% "discipline-munit" % "2.0.0-M2"))
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)

lazy val unidocs = project
.in(file("unidocs"))
Expand Down
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0")
addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.10.0")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.12")
addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % "0.4.12")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ private[tests] object Platform {
// $COVERAGE-OFF$
final val isJvm = false
final val isJs = true
final val isNative = false
// $COVERAGE-ON$
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ private[tests] object Platform {
// $COVERAGE-OFF$
final val isJvm = true
final val isJs = false
final val isNative = false
// $COVERAGE-ON$
}
26 changes: 26 additions & 0 deletions tests/native/src/test/scala/cats/mtl/tests/Platform.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2021 Typelevel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cats.mtl.tests

private[tests] object Platform {
// using `final val` makes compiler constant-fold any use of these values, dropping dead code automatically
// $COVERAGE-OFF$
final val isJvm = false
final val isJs = false
final val isNative = true
// $COVERAGE-ON$
}

0 comments on commit 2d193a2

Please sign in to comment.