Skip to content

Commit

Permalink
Fix scala 2 native build (#35)
Browse files Browse the repository at this point in the history
* fix scala 2 native build
  • Loading branch information
rolang authored Mar 16, 2024
1 parent a74a425 commit 2291507
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 16 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
15 changes: 8 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2291507

Please sign in to comment.