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

Add Scala Native support to core and examples #5

Merged
merged 5 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
64 changes: 39 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [3]
java: [temurin@8]
project: [rootJS, rootJVM]
java: [temurin@17]
project: [rootJS, rootJVM, rootNative]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
Expand All @@ -39,48 +39,52 @@ jobs:
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt githubWorkflowCheck

- name: Check headers and formatting
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck

- name: scalaJSLink
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

- name: Check binary compatibility
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' mimaReportBinaryIssues

- name: Generate API documentation
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' doc

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p modules/compiler-plugin/target modules/core/js/target modules/core/jvm/target modules/bundle/target project/target
run: mkdir -p modules/compiler-plugin/target modules/core/native/target modules/core/js/target modules/core/jvm/target modules/bundle/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 modules/compiler-plugin/target modules/core/js/target modules/core/jvm/target modules/bundle/target project/target
run: tar cf targets.tar modules/compiler-plugin/target modules/core/native/target modules/core/js/target modules/core/jvm/target modules/bundle/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 All @@ -96,25 +100,25 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@8]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Download target directories (3, rootJS)
Expand All @@ -137,6 +141,16 @@ jobs:
tar xf targets.tar
rm targets.tar

- name: Download target directories (3, rootNative)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3-rootNative

- name: Inflate target directories (3, 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 @@ -167,29 +181,29 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@8]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
modules-ignore: rootjs_3 examples_sjs1_3 rootjvm_3 rootnative_3 examples_3 tests_3
modules-ignore: examples_native0.4_3 rootjs_3 examples_sjs1_3 rootjvm_3 rootnative_3 examples_3 tests_3
configs-ignore: test scala-tool scala-doc-tool test-internal
1 change: 1 addition & 0 deletions .jvmopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Xmx2G
34 changes: 27 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ThisBuild / developers ++= List(
tlGitHubDev("baccata", "Olivier Mélois")
)

ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because I bring an eclipse jgit version that is built for Java 11. Not really intentional, but probably not a big deal to use newer JDK on CI.


ThisBuild / scalacOptions ++= Seq(
"-language:implicitConversions"
)
Expand All @@ -24,12 +26,12 @@ ThisBuild / scalaVersion := Scala3 // the default Scala
testFrameworks += new TestFramework("munit.Framework")

val smithyVersion = "1.47.0"
val smithy4sVersion = "0.18.16"
val smithy4sVersion = "0.18.23"
val alloyVersion = "0.3.7"

lazy val root = tlCrossRootProject.aggregate(core, examples, plugin, pluginBundle, tests)

lazy val core = crossProject(JVMPlatform, JSPlatform)
lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("modules/core"))
.settings(
name := "smithy4s-deriving",
Expand Down Expand Up @@ -89,16 +91,21 @@ lazy val tests = crossProject(JVMPlatform)
)
)

lazy val examples = crossProject(JVMPlatform, JSPlatform)
lazy val examples = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("modules/examples"))
.dependsOn(core)
.enablePlugins(NoPublishPlugin)
.settings(
libraryDependencies ++= Seq(
"com.disneystreaming.smithy4s" %% "smithy4s-http4s" % smithy4sVersion,
"com.disneystreaming.smithy4s" %% "smithy4s-dynamic" % smithy4sVersion,
"org.http4s" %% "http4s-ember-client" % "0.23.26",
"org.http4s" %% "http4s-ember-server" % "0.23.26"
"com.disneystreaming.smithy4s" %%% "smithy4s-http4s" % smithy4sVersion,
"com.disneystreaming.smithy4s" %%% "smithy4s-dynamic" % smithy4sVersion,
"org.http4s" %%% "http4s-ember-client" % "0.23.26",
"org.http4s" %%% "http4s-ember-server" % "0.23.26",
// This particular version of fs2-io performs evictions of core CE and
// fs2 libraries so that networking with Ember works out of the box
// It still requires all necessary native dependencies (openssl, s2n, zlib)
// to be installed globally
"co.fs2" %%% "fs2-io" % "3.10-365636d"
),
autoCompilerPlugins := true,
Compile / fork := true,
Expand All @@ -113,6 +120,19 @@ lazy val examples = crossProject(JVMPlatform, JSPlatform)
"software.amazon.smithy" % "smithy-model" % smithyVersion
)
)
.nativeEnablePlugins(VcpkgNativePlugin)
.nativeSettings(
vcpkgDependencies := VcpkgDependencies(
"curl",
"s2n",
"openssl"
),
vcpkgNativeConfig ~= {
_.withRenamedLibraries(
Map("curl" -> "libcurl")
)
}
)
.jsSettings(
Test / fork := false
)
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.6.7")
// Set me up for CI release, but don't touch my scalacOptions!
addSbtPlugin("org.typelevel" % "sbt-typelevel-ci-release" % "0.6.7")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.17")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0")
addSbtPlugin("com.indoorvivants.vcpkg" % "sbt-vcpkg-native" % "0.0.20")
Loading