From 2291507ffe6ddc2bb079ca920d267dad2c5c85f5 Mon Sep 17 00:00:00 2001 From: Roman Langolf Date: Sat, 16 Mar 2024 16:14:10 +0700 Subject: [PATCH] Fix scala 2 native build (#35) * fix scala 2 native build --- .github/workflows/ci.yml | 20 +++++++++++++++---- README.md | 2 ++ build.sbt | 15 +++++++------- .../main/scala-2/dumbo/ResourceFilePath.scala | 5 +++-- .../scala-2/ffstest/FFrameworkPlatform.scala | 20 +++++++++++++++++++ .../test/scala/ResourceFileConfigSpec.scala | 6 +++--- 6 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 modules/tests/native/src/main/scala-2/ffstest/FFrameworkPlatform.scala diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc9fae4..7e3d78b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,8 +36,6 @@ jobs: java: temurin@17 - project: rootNative java: temurin@17 - - project: rootNative - scala: 2.13 runs-on: ${{ matrix.os }} timeout-minutes: 60 steps: @@ -105,8 +103,12 @@ jobs: if: matrix.java == 'temurin@21' && matrix.os == 'ubuntu-latest' run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' doc + - name: CLI test + if: matrix.project == 'rootNative' && (matrix.scala == '3') + run: sbt cliNative/test + - name: Generate CLI native binary - if: matrix.project == 'rootNative' + if: matrix.project == 'rootNative' && (matrix.scala == '3') env: SCALANATIVE_MODE: release-fast SCALANATIVE_LTO: thin @@ -205,6 +207,16 @@ jobs: tar xf targets.tar rm targets.tar + - name: Download target directories (2.13, rootNative) + uses: actions/download-artifact@v4 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13-rootNative + + - name: Inflate target directories (2.13, rootNative) + run: | + tar xf targets.tar + rm targets.tar + - name: Import signing key if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' env: @@ -294,5 +306,5 @@ jobs: - name: Submit Dependencies uses: scalacenter/sbt-dependency-submission@v2 with: - modules-ignore: dumbo_3 dumbo_2.13 testsflyway_3 testsflyway_2.13 dumbo_3 dumbo_2.13 dumbo_3 dumbo_2.13 tests_3 tests_2.13 example_3 example_2.13 tests_native0.4_3 + modules-ignore: dumbo_3 dumbo_2.13 testsflyway_3 testsflyway_2.13 dumbo_3 dumbo_2.13 dumbo_3 dumbo_2.13 tests_3 tests_2.13 example_3 example_2.13 tests_native0.4_3 tests_native0.4_2.13 configs-ignore: test scala-tool scala-doc-tool test-internal diff --git a/README.md b/README.md index d588ca0..7b392ab 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.rolang/dumbo_3.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/rolang/dumbo_3/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.rolang/dumbo_3.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/rolang/dumbo_3/) +[![dumbo Scala version support](https://index.scala-lang.org/rolang/dumbo/dumbo/latest-by-scala-version.svg?platform=native0.4)](https://index.scala-lang.org/rolang/dumbo/dumbo) +[![dumbo Scala version support](https://index.scala-lang.org/rolang/dumbo/dumbo/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/rolang/dumbo/dumbo) ![Logo](./docs/assets/logo.png) diff --git a/build.sbt b/build.sbt index a358be7..846ef37 100644 --- a/build.sbt +++ b/build.sbt @@ -52,10 +52,16 @@ ThisBuild / githubWorkflowBuild := { ) +: (ThisBuild / githubWorkflowBuild).value } +ThisBuild / githubWorkflowBuild += WorkflowStep.Run( + commands = List("sbt cliNative/test"), + name = Some("CLI test"), + cond = Some("matrix.project == 'rootNative' && (matrix.scala == '3')"), +) + ThisBuild / githubWorkflowBuild += WorkflowStep.Run( commands = List("sbt buildCliBinary"), name = Some("Generate CLI native binary"), - cond = Some("matrix.project == 'rootNative'"), + cond = Some("matrix.project == 'rootNative' && (matrix.scala == '3')"), env = Map( "SCALANATIVE_MODE" -> Mode.releaseFast.toString(), "SCALANATIVE_LTO" -> LTO.thin.toString(), @@ -94,10 +100,6 @@ ThisBuild / githubWorkflowBuild += WorkflowStep.Sbt( cond = Some("matrix.project == 'rootJVM'"), ) -ThisBuild / githubWorkflowBuildMatrixExclusions ++= Seq( - MatrixExclude(Map("project" -> "rootNative", "scala" -> "2.13")) -) - addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt") addCommandAlias("fix", "; all scalafixAll; all scalafmtSbt scalafmtAll") addCommandAlias("check", "; scalafmtSbtCheck; scalafmtCheckAll; scalafixAll --check") @@ -132,7 +134,7 @@ lazy val commonSettings = List( lazy val root = tlCrossRootProject .settings(name := "dumbo") - .aggregate(core, cli, tests, testsFlyway, example) + .aggregate(core, tests, testsFlyway, example) .settings(commonSettings) lazy val skunkVersion = "1.0.0-M4" @@ -243,7 +245,6 @@ lazy val tests = crossProject(JVMPlatform, NativePlatform) libraryDependencies += "com.armanbilge" %%% "epollcat" % epollcatVersion, Test / nativeBrewFormulas ++= brewFormulas, Test / envVars ++= Map("S2N_DONT_MLOCK" -> "1"), - scalaVersion := `scala-3`, nativeConfig ~= { _.withEmbedResources(true) }, diff --git a/modules/core/native/src/main/scala-2/dumbo/ResourceFilePath.scala b/modules/core/native/src/main/scala-2/dumbo/ResourceFilePath.scala index f0d34b3..6d568d8 100644 --- a/modules/core/native/src/main/scala-2/dumbo/ResourceFilePath.scala +++ b/modules/core/native/src/main/scala-2/dumbo/ResourceFilePath.scala @@ -4,8 +4,9 @@ package dumbo -import java.nio.file.{Path, Paths} +import java.nio.file.Paths final case class ResourceFilePath(value: String) extends AnyVal { - def toNioPath: Path = Paths.get(value) + def fileName: String = Paths.get(value).getFileName.toString() + def append(p: String): ResourceFilePath = ResourceFilePath(value + p) } diff --git a/modules/tests/native/src/main/scala-2/ffstest/FFrameworkPlatform.scala b/modules/tests/native/src/main/scala-2/ffstest/FFrameworkPlatform.scala new file mode 100644 index 0000000..a12bd39 --- /dev/null +++ b/modules/tests/native/src/main/scala-2/ffstest/FFrameworkPlatform.scala @@ -0,0 +1,20 @@ +// Copyright (c) 2023 by Roman Langolf +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package ffstest + +import cats.effect.IO +import dumbo.{Dumbo, DumboWithResourcesPartiallyApplied} +import epollcat.unsafe.EpollRuntime +import fs2.io.file.Path +import munit.CatsEffectSuite + +trait FTestPlatform extends CatsEffectSuite { + override def munitIORuntime = EpollRuntime.global + + def dumboWithResources(path: String): DumboWithResourcesPartiallyApplied[IO] = + dumboWithFiles(Path("modules/tests/shared/src/test/resources/" + path)) + + def dumboWithFiles(path: Path): DumboWithResourcesPartiallyApplied[IO] = Dumbo.withFilesIn(path) +} diff --git a/modules/tests/shared/src/test/scala/ResourceFileConfigSpec.scala b/modules/tests/shared/src/test/scala/ResourceFileConfigSpec.scala index 28690af..789ec32 100644 --- a/modules/tests/shared/src/test/scala/ResourceFileConfigSpec.scala +++ b/modules/tests/shared/src/test/scala/ResourceFileConfigSpec.scala @@ -8,17 +8,17 @@ class ResourceFileConfigSpec extends ffstest.FTest { test("parse config file") { assertEquals( ResourceFileConfig.fromLines(List("executeInTransaction=true")), - Right[String, Set[ResourceFileConfig]](Set(ResourceFileConfig.ExecuteInTransaction(true))), + Right[String, Set[ResourceFileConfig]](Set(ResourceFileConfig.ExecuteInTransaction(value = true))), ) assertEquals( ResourceFileConfig.fromLines(List("executeInTransaction=false")), - Right[String, Set[ResourceFileConfig]](Set(ResourceFileConfig.ExecuteInTransaction(false))), + Right[String, Set[ResourceFileConfig]](Set(ResourceFileConfig.ExecuteInTransaction(value = false))), ) assertEquals( ResourceFileConfig.fromLines(List(" ", " executeInTransaction = true ", "")), - Right[String, Set[ResourceFileConfig]](Set(ResourceFileConfig.ExecuteInTransaction(true))), + Right[String, Set[ResourceFileConfig]](Set(ResourceFileConfig.ExecuteInTransaction(value = true))), ) assertEquals(