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

Support for ScalaJS #398

Merged
merged 5 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
65 changes: 39 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,86 +14,99 @@ on:

jobs:
lint:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- name: Checkout current branch
uses: actions/checkout@v3.3.0
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v14
- name: Setup Java
uses: actions/setup-[email protected]
with:
java-version: [email protected]
distribution: temurin
java-version: 17
check-latest: true
- name: Cache scala dependencies
uses: coursier/cache-action@v6
uses: coursier/cache-action@v6.4.4
- name: Lint code
run: sbt check

website:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- name: Checkout current branch
uses: actions/checkout@v3.3.0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v14
uses: actions/checkout@v4.1.1
- name: Setup Java
uses: actions/setup-[email protected]
with:
java-version: [email protected]
distribution: temurin
java-version: 17
check-latest: true
- name: Cache scala dependencies
uses: coursier/cache-action@v6
uses: coursier/cache-action@v6.4.4
- name: Check Document Generation
run: sbt docs/compileDocs

test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
java: ['17']
scala: ['2.12.17', '2.13.8', '3.3.0']
platform: ['JVM', 'Native']
scala: ['2.12.17', '2.13.11', '3.3.1']
platform: ['JVM', 'Native', 'JS']
steps:
- name: Checkout current branch
uses: actions/checkout@v3.3.0
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v14
- name: Setup Java
uses: actions/setup-[email protected]
with:
distribution: temurin
java-version: ${{ matrix.java }}
check-latest: true
- name: Cache scala dependencies
uses: coursier/cache-action@v6
uses: coursier/cache-action@v6.4.4
- name: Install libuv
if: matrix.platform == 'Native'
run: sudo apt-get update && sudo apt-get install -y libuv1-dev
- name: Setup NodeJS
uses: actions/setup-node@v4
if: matrix.platform == 'JS'
with:
node-version: 21.6.1
- name: Run tests
run: sbt ++${{ matrix.scala }} zioProcess${{ matrix.platform }}/test

ci:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: [lint, website, test]
steps:
- name: Aggregate job outcomes
run: echo "build succeeded"

publish:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 30
needs: [ci]
if: github.event_name != 'pull_request'
steps:
- name: Checkout current branch
uses: actions/checkout@v3.3.0
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: Setup Scala and Java
- name: Setup Java
uses: actions/[email protected]
with:
java-version: [email protected]
uses: olafurpg/setup-scala@v14
distribution: temurin
java-version: 17
check-latest: true
- name: Cache scala dependencies
uses: coursier/cache-action@v6
uses: coursier/cache-action@v6.4.4
- name: Release artifacts
run: sbt ci-release
env:
Expand Down
39 changes: 21 additions & 18 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BuildHelper._
import sbtwelcome._
import sbt.addSbtPlugin
//import sbtcrossproject.CrossPlugin.autoImport._
import org.scalajs.linker.interface.ModuleInitializer

inThisBuild(
List(
Expand Down Expand Up @@ -55,38 +55,41 @@ lazy val root =
publish / skip := true,
crossScalaVersions := Nil
)
.aggregate(zioProcess.jvm, zioProcess.native, docs)
.aggregate(zioProcess.jvm, zioProcess.native, zioProcess.js, docs)

lazy val zioProcess =
crossProject(JVMPlatform, NativePlatform)
crossProject(JVMPlatform, NativePlatform, JSPlatform)
.in(file("zio-process"))
.settings(stdSettings("zio-process"))
.settings(crossProjectSettings)
.settings(buildInfoSettings("zio.process"))
.jvmSettings(testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")))
.jvmSettings(
.settings(testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")))
.settings(
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion,
"dev.zio" %% "zio-streams" % zioVersion,
"org.scala-lang.modules" %% "scala-collection-compat" % "2.9.0",
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
"dev.zio" %%% "zio" % zioVersion,
"dev.zio" %%% "zio-streams" % zioVersion,
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.9.0",
"dev.zio" %%% "zio-test" % zioVersion % Test,
"dev.zio" %%% "zio-test-sbt" % zioVersion % Test
)
)
.enablePlugins(BuildInfoPlugin)
.jvmSettings(dottySettings)
.settings(dottySettings)
.nativeSettings(Test / fork := false)
.nativeSettings(testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")))
.nativeSettings(
libraryDependencies ++= Seq(
"dev.zio" %%% "zio" % zioVersion,
"dev.zio" %%% "zio-streams" % zioVersion,
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.9.0",
"dev.zio" %%% "zio-test" % zioVersion % Test,
"dev.zio" %%% "zio-test-sbt" % zioVersion % Test,
"io.github.cquiroz" %%% "scala-java-time" % "2.5.0" % Test
"io.github.cquiroz" %%% "scala-java-time" % "2.5.0" % Test
)
)
.jsSettings(Test / fork := false)
.jsSettings(
libraryDependencies ++= Seq(
"io.github.cquiroz" %%% "scala-java-time" % "2.5.0" % Test
)
)
.jsSettings(
scalaJSUseMainModuleInitializer := true
)

lazy val docs = project
.in(file("zio-process-docs"))
Expand Down
34 changes: 11 additions & 23 deletions project/BuildHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,10 @@ import sbtbuildinfo._
import sbtcrossproject.CrossPlugin.autoImport._

object BuildHelper {
private val versions: Map[String, String] = {
import org.snakeyaml.engine.v2.api.{ Load, LoadSettings }

import java.util.{ List => JList, Map => JMap }
import scala.jdk.CollectionConverters._
val doc = new Load(LoadSettings.builder().build())
.loadFromReader(scala.io.Source.fromFile(".github/workflows/ci.yml").bufferedReader())
val yaml = doc.asInstanceOf[JMap[String, JMap[String, JMap[String, JMap[String, JMap[String, JList[String]]]]]]]
val list = yaml.get("jobs").get("test").get("strategy").get("matrix").get("scala").asScala
list.map { v =>
val vs = v.split('.'); val init = vs.take(vs(0) match { case "2" => 2; case _ => 1 }); (init.mkString("."), v)
}.toMap
}

val Scala212: String = versions("2.12")
val Scala213: String = versions("2.13")
val Scala3: String = versions("3")
val Scala212 = "2.12.18"
val Scala213 = "2.13.11"
val Scala3 = "3.3.1"

private val stdOptions = Seq(
"-encoding",
Expand All @@ -30,8 +17,7 @@ object BuildHelper {
"-language:higherKinds",
"-language:existentials",
"-unchecked",
"-deprecation",
"-Xfatal-warnings"
"-deprecation"
)

private val stdOpts213 = Seq(
Expand All @@ -51,7 +37,8 @@ object BuildHelper {
"-Ywarn-infer-any",
"-Ywarn-inaccessible",
"-Ywarn-nullary-unit",
"-Ywarn-unused-import"
"-Ywarn-unused-import",
"-Xfatal-warnings"
)

private val stdOptsUpto211 = Seq(
Expand Down Expand Up @@ -145,10 +132,11 @@ object BuildHelper {
val dottySettings = Seq(
crossScalaVersions += Scala3,
scalacOptions ++= {
if (scalaVersion.value == Scala3)
Seq("-noindent")
else
Seq()
(scalaVersion.value, crossProjectPlatform.value.identifier) match {
case (Scala3, "js") => Seq("-noindent", "-scalajs")
case (Scala3, _) => Seq("-noindent")
case _ => Seq()
}
},
scalacOptions --= {
if (scalaVersion.value == Scala3)
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.8.2
sbt.version = 1.9.8
35 changes: 14 additions & 21 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")

addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.5")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.7")

addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.7")

addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.9")

addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0")

addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11")

addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.2.2")

addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.3.4")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.17")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.5")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.7")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.7")
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.9")
addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11")
addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.2.2")
addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.3.4")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.17")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.15.0")

libraryDependencies += "org.snakeyaml" % "snakeyaml-engine" % "2.6"

Expand Down
Loading
Loading