From d3020c77518ddc90d16809022cc0577396277c5d Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 6 Jul 2022 02:28:04 +0000 Subject: [PATCH 1/4] First steps for Native build --- .github/workflows/ci.yml | 6 +++--- build.sbt | 25 +++++++++++++++++-------- project/plugins.sbt | 2 ++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6cea95be..3143b7537 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,17 +56,17 @@ jobs: - name: Build project (Scala 2) if: matrix.scala == '2.12.16' || matrix.scala == '2.13.8' - run: sbt ++${{ matrix.scala }} validateJVM validateJS + run: sbt ++${{ matrix.scala }} validateJVM validateJS validateNative - name: Build project (Scala 3) if: matrix.scala == '3.1.2' - run: sbt ++${{ matrix.scala }} validateJVM30 validateJS30 + run: sbt ++${{ matrix.scala }} validateJVM30 validateJS30 validateNative30 - name: Codecov uses: codecov/codecov-action@v1 - name: Compress target directories - run: tar cf targets.tar modules/jsonpath/jvm/target modules/shapeless/js/target target modules/docs/target modules/pureconfig/jvm/target modules/core/js/target modules/core/jvm/target modules/scodec/jvm/target modules/scodec/js/target modules/shapeless/jvm/target modules/cats/js/target modules/cats/jvm/target modules/eval/jvm/target modules/scopt/jvm/target modules/scalaz/jvm/target modules/scalacheck/jvm/target modules/scalacheck/js/target modules/benchmark/target project/target + run: tar cf targets.tar modules/jsonpath/jvm/target modules/shapeless/js/target modules/scalacheck/native/target target modules/cats/native/target modules/core/native/target modules/docs/target modules/pureconfig/jvm/target modules/core/js/target modules/shapeless/native/target modules/core/jvm/target modules/scodec/jvm/target modules/scodec/js/target modules/shapeless/jvm/target modules/cats/js/target modules/cats/jvm/target modules/eval/jvm/target modules/scopt/jvm/target modules/scalaz/jvm/target modules/scalacheck/jvm/target modules/scalacheck/js/target modules/benchmark/target project/target - name: Upload target directories uses: actions/upload-artifact@v2 diff --git a/build.sbt b/build.sbt index f330337ef..cefd47ef2 100644 --- a/build.sbt +++ b/build.sbt @@ -40,16 +40,16 @@ def macroParadise(configuration: Configuration): Def.Initialize[Seq[ModuleID]] = } val moduleCrossPlatformMatrix: Map[String, List[Platform]] = Map( - "cats" -> List(JVMPlatform, JSPlatform), - "core" -> List(JVMPlatform, JSPlatform), + "cats" -> List(JVMPlatform, JSPlatform, NativePlatform), + "core" -> List(JVMPlatform, JSPlatform, NativePlatform), "eval" -> List(JVMPlatform), "jsonpath" -> List(JVMPlatform), "pureconfig" -> List(JVMPlatform), - "scalacheck" -> List(JVMPlatform, JSPlatform), + "scalacheck" -> List(JVMPlatform, JSPlatform, NativePlatform), "scalaz" -> List(JVMPlatform), "scodec" -> List(JVMPlatform, JSPlatform), "scopt" -> List(JVMPlatform), - "shapeless" -> List(JVMPlatform, JSPlatform) + "shapeless" -> List(JVMPlatform, JSPlatform, NativePlatform) ) val moduleCrossScalaVersionsMatrix: (String, Platform) => List[String] = { @@ -75,6 +75,7 @@ val allSubprojectsJVM30 = allSubprojectsOf(JVMPlatform, Set(Scala_3)) val allSubprojectsJS = allSubprojectsOf(JSPlatform) val allSubprojectsJS30 = allSubprojectsOf(JSPlatform, Set(Scala_3)) val allSubprojectsNative = allSubprojectsOf(NativePlatform) +val allSubprojectsNative30 = allSubprojectsOf(NativePlatform, Set(Scala_3)) /// sbt-github-actions configuration @@ -100,12 +101,12 @@ ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec(Adopt, "8")) ThisBuild / githubWorkflowBuild := Seq( WorkflowStep.Sbt( - List("validateJVM", "validateJS"), + List("validateJVM", "validateJS", "validateNative"), name = Some("Build project (Scala 2)"), cond = Some(s"matrix.scala == '$Scala_2_12' || matrix.scala == '$Scala_2_13'") ), WorkflowStep.Sbt( - List("validateJVM30", "validateJS30"), + List("validateJVM30", "validateJS30", "validateNative30"), name = Some("Build project (Scala 3)"), cond = Some(s"matrix.scala == '$Scala_3'") ), @@ -515,10 +516,11 @@ addCommandsAlias( ) ) -addCommandsAlias("compileNative", allSubprojectsNative.map(_ + "/compile")) +addCommandsAlias("testNative", allSubprojectsNative.map(_ + "/test")) addCommandsAlias("testJS", allSubprojectsJS.map(_ + "/test")) addCommandsAlias("testJVM", allSubprojectsJVM.map(_ + "/test")) +addCommandsAlias("testNative30", allSubprojectsNative30.map(_ + "/test")) addCommandsAlias("testJS30", allSubprojectsJS30.map(_ + "/test")) addCommandsAlias("testJVM30", allSubprojectsJVM30.map(_ + "/test")) @@ -547,7 +549,7 @@ addCommandsAlias( addCommandsAlias( "validateNative", Seq( - "compileNative" + "testNative" ) ) @@ -565,3 +567,10 @@ addCommandsAlias( "testJS30" ) ) + +addCommandsAlias( + "validateNative30", + Seq( + "testNative30" + ) +) diff --git a/project/plugins.sbt b/project/plugins.sbt index f1a810b77..e9b99fdd6 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -16,6 +16,8 @@ addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.5") + addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.0") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") From e289a32dd5cf387154146fdc34e2ad104e8d5bec Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 6 Jul 2022 15:42:06 +0000 Subject: [PATCH 2/4] Fixups --- build.sbt | 4 ++-- .../scala-3.0-/eu/timepit/refined/StringValidateSpec.scala | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index cefd47ef2..48504f11b 100644 --- a/build.sbt +++ b/build.sbt @@ -40,7 +40,7 @@ def macroParadise(configuration: Configuration): Def.Initialize[Seq[ModuleID]] = } val moduleCrossPlatformMatrix: Map[String, List[Platform]] = Map( - "cats" -> List(JVMPlatform, JSPlatform, NativePlatform), + "cats" -> List(JVMPlatform, JSPlatform), "core" -> List(JVMPlatform, JSPlatform, NativePlatform), "eval" -> List(JVMPlatform), "jsonpath" -> List(JVMPlatform), @@ -144,7 +144,7 @@ lazy val cats = myCrossProject("cats") libraryDependencies ++= Seq( "org.typelevel" %%% "cats-core" % catsVersion, "org.typelevel" %%% "cats-laws" % catsVersion % Test, - "org.typelevel" %%% "discipline-scalatest" % "2.1.5" % Test + "org.typelevel" %%% "discipline-scalatest" % "2.2.0" % Test ), initialCommands += s""" import $rootPkg.cats._ diff --git a/modules/core/shared/src/test/scala-3.0-/eu/timepit/refined/StringValidateSpec.scala b/modules/core/shared/src/test/scala-3.0-/eu/timepit/refined/StringValidateSpec.scala index b1d28f3df..d533a6c20 100644 --- a/modules/core/shared/src/test/scala-3.0-/eu/timepit/refined/StringValidateSpec.scala +++ b/modules/core/shared/src/test/scala-3.0-/eu/timepit/refined/StringValidateSpec.scala @@ -56,7 +56,10 @@ class StringValidateSpec extends Properties("StringValidate") { val jsErr = showResult[Uri](" /a/b/c") ?= "Uri predicate failed: Malformed URI in /a/b/c at -1" - jvmErr || jsErr + val nativeErr = showResult[Uri](" /a/b/c") ?= + "Uri predicate failed: Illegal character in path in /a/b/c at 1" + + jvmErr || jsErr || nativeErr } property("Uuid.isValid") = secure { From 22904dac67570376f2d0bc86bfdd36105ea81308 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 6 Jul 2022 15:48:21 +0000 Subject: [PATCH 3/4] Regenerate workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3143b7537..fed1a53fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: uses: codecov/codecov-action@v1 - name: Compress target directories - run: tar cf targets.tar modules/jsonpath/jvm/target modules/shapeless/js/target modules/scalacheck/native/target target modules/cats/native/target modules/core/native/target modules/docs/target modules/pureconfig/jvm/target modules/core/js/target modules/shapeless/native/target modules/core/jvm/target modules/scodec/jvm/target modules/scodec/js/target modules/shapeless/jvm/target modules/cats/js/target modules/cats/jvm/target modules/eval/jvm/target modules/scopt/jvm/target modules/scalaz/jvm/target modules/scalacheck/jvm/target modules/scalacheck/js/target modules/benchmark/target project/target + run: tar cf targets.tar modules/jsonpath/jvm/target modules/shapeless/js/target modules/scalacheck/native/target target modules/core/native/target modules/docs/target modules/pureconfig/jvm/target modules/core/js/target modules/shapeless/native/target modules/core/jvm/target modules/scodec/jvm/target modules/scodec/js/target modules/shapeless/jvm/target modules/cats/js/target modules/cats/jvm/target modules/eval/jvm/target modules/scopt/jvm/target modules/scalaz/jvm/target modules/scalacheck/jvm/target modules/scalacheck/js/target modules/benchmark/target project/target - name: Upload target directories uses: actions/upload-artifact@v2 From 68430bd86c39aec33e2843be0e7b8ee3052c8c3c Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 6 Jul 2022 15:56:56 +0000 Subject: [PATCH 4/4] More memory --- .jvmopts | 1 + 1 file changed, 1 insertion(+) diff --git a/.jvmopts b/.jvmopts index dabc2e322..1b0d7dc4b 100644 --- a/.jvmopts +++ b/.jvmopts @@ -1 +1,2 @@ -XX:+UseG1GC +-Xmx4G