Skip to content

Commit

Permalink
Build core and calev modules for Scala.js (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
fthomas authored Mar 9, 2023
1 parent 8330757 commit e7475d8
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 24 deletions.
42 changes: 38 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
os: [ubuntu-latest]
scala: [2.12.17, 2.13.10, 3.2.2]
java: [temurin@8]
project: [rootJVM]
project: [rootJS, rootJVM]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -73,6 +73,10 @@ jobs:
if: matrix.java == 'temurin@8' && 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: Test
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' test

Expand All @@ -85,7 +89,7 @@ jobs:
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' doc

- name: Check README
if: matrix.scala != '3.2.2'
if: matrix.scala != '3.2.2' && matrix.project == 'rootJVM'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' readme/mdoc

- name: Generate coverage report
Expand All @@ -97,11 +101,11 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master')
run: mkdir -p target .js/target modules/cron4s/.jvm/target .jvm/target .native/target modules/cron-utils/.jvm/target modules/readme/target modules/core/.jvm/target modules/calev/.jvm/target project/target
run: mkdir -p target .js/target modules/core/.js/target modules/cron4s/.jvm/target .jvm/target .native/target modules/cron-utils/.jvm/target modules/readme/target modules/calev/.js/target modules/core/.jvm/target modules/calev/.jvm/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master')
run: tar cf targets.tar target .js/target modules/cron4s/.jvm/target .jvm/target .native/target modules/cron-utils/.jvm/target modules/readme/target modules/core/.jvm/target modules/calev/.jvm/target project/target
run: tar cf targets.tar target .js/target modules/core/.js/target modules/cron4s/.jvm/target .jvm/target .native/target modules/cron-utils/.jvm/target modules/readme/target modules/calev/.js/target modules/core/.jvm/target modules/calev/.jvm/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master')
Expand Down Expand Up @@ -154,6 +158,16 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.12.17, rootJS)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.17-rootJS

- name: Inflate target directories (2.12.17, rootJS)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.12.17, rootJVM)
uses: actions/download-artifact@v3
with:
Expand All @@ -164,6 +178,16 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.10, rootJS)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.10-rootJS

- name: Inflate target directories (2.13.10, rootJS)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.10, rootJVM)
uses: actions/download-artifact@v3
with:
Expand All @@ -174,6 +198,16 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.2.2, rootJS)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.2.2-rootJS

- name: Inflate target directories (3.2.2, rootJS)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.2.2, rootJVM)
uses: actions/download-artifact@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ pull_request_rules:
- name: merge scala-steward's PRs
conditions:
- author=scala-steward
- status-success=Build and Test (ubuntu-latest, 2.12.17, temurin@8, rootJS)
- status-success=Build and Test (ubuntu-latest, 2.12.17, temurin@8, rootJVM)
- status-success=Build and Test (ubuntu-latest, 2.13.10, temurin@8, rootJS)
- status-success=Build and Test (ubuntu-latest, 2.13.10, temurin@8, rootJVM)
- status-success=Build and Test (ubuntu-latest, 3.2.2, temurin@8, rootJS)
- status-success=Build and Test (ubuntu-latest, 3.2.2, temurin@8, rootJVM)
actions:
merge:
Expand Down
32 changes: 23 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import sbtcrossproject.{CrossProject, CrossType, Platform}
val groupId = "eu.timepit"
val projectName = "fs2-cron"
val rootPkg = s"$groupId.${projectName.replace("-", "")}"
val gitHubOwner = "fthomas"

val Scala_2_12 = "2.12.17"
val Scala_2_13 = "2.13.10"
val Scala_3 = "3.2.2"

val moduleCrossPlatformMatrix: Map[String, List[Platform]] = Map(
"calev" -> List(JVMPlatform),
"core" -> List(JVMPlatform),
"calev" -> List(JVMPlatform, JSPlatform),
"core" -> List(JVMPlatform, JSPlatform),
"cron4s" -> List(JVMPlatform),
"cron-utils" -> List(JVMPlatform)
)
Expand All @@ -35,7 +34,7 @@ ThisBuild / githubWorkflowBuild ++= Seq(
WorkflowStep.Sbt(
commands = List("readme/mdoc"),
name = Some("Check README"),
cond = Some(s"matrix.scala != '$Scala_3'")
cond = Some(s"matrix.scala != '$Scala_3' && matrix.project == 'rootJVM'")
),
WorkflowStep.Sbt(
commands = List("coverage", "test", "coverageReport"),
Expand Down Expand Up @@ -71,26 +70,41 @@ lazy val root = tlCrossRootProject
lazy val core = myCrossProject("core")
.settings(
libraryDependencies ++= Seq(
Dependencies.fs2Core,
Dependencies.munitCatsEffect % Test
"co.fs2" %%% "fs2-core" % "3.6.1",
"org.typelevel" %%% "munit-cats-effect-3" % "1.0.7" % Test
)
)
.jsSettings(
tlVersionIntroduced := Map(
"2.12" -> "0.8.3",
"2.13" -> "0.8.3",
"3" -> "0.8.3"
)
)

lazy val calev = myCrossProject("calev")
.dependsOn(core % "compile->compile;test->test")
.settings(
libraryDependencies += Dependencies.calevCore,
libraryDependencies += "com.github.eikek" %%% "calev-core" % "0.6.4",
initialCommands += s"""
import $rootPkg.calev._
import com.github.eikek.calev._
"""
)
.jsSettings(
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.5.0" % Test,
tlVersionIntroduced := Map(
"2.12" -> "0.8.3",
"2.13" -> "0.8.3",
"3" -> "0.8.3"
)
)

lazy val cron4s = myCrossProject("cron4s")
.dependsOn(core % "compile->compile;test->test")
.settings(
crossScalaVersions := List(Scala_2_12, Scala_2_13),
libraryDependencies += Dependencies.cron4s,
libraryDependencies += "com.github.alonsodomin.cron4s" %% "cron4s-core" % "0.6.1",
initialCommands += s"""
import $rootPkg.cron4s._
import _root_.cron4s.Cron
Expand All @@ -101,7 +115,7 @@ lazy val cron4s = myCrossProject("cron4s")
lazy val cronUtils = myCrossProject("cron-utils")
.dependsOn(core % "compile->compile;test->test")
.settings(
libraryDependencies += Dependencies.cronUtils,
libraryDependencies += "com.cronutils" % "cron-utils" % "9.2.0",
initialCommands += s"""
import $rootPkg.cronutils._
import com.cronutils.model.CronType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import cats.effect.{Sync, Temporal}
import cats.syntax.all._

import java.time.temporal.ChronoUnit
import java.time.{ZoneId, ZoneOffset, ZonedDateTime}
import java.time.{Instant, ZoneId, ZoneOffset, ZonedDateTime}
import java.util.concurrent.TimeUnit
import scala.concurrent.duration.FiniteDuration

Expand All @@ -38,7 +38,7 @@ abstract class ZonedDateTimeScheduler[F[_], Schedule](zoneId: F[ZoneId])(implici
}

private val now: F[ZonedDateTime] =
(temporal.realTimeInstant, zoneId).mapN(_.atZone(_))
(temporal.realTime, zoneId).mapN((d, z) => Instant.EPOCH.plusNanos(d.toNanos).atZone(z))
}

object ZonedDateTimeScheduler {
Expand Down
9 changes: 0 additions & 9 deletions project/Dependencies.scala

This file was deleted.

0 comments on commit e7475d8

Please sign in to comment.