Skip to content

Commit

Permalink
feat: Cross build for Scala 3 for CSV and Cassandra (#2957)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-alfers authored Feb 28, 2023
1 parent 5228417 commit 07ab774
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
- name: Cache Coursier cache
uses: coursier/[email protected]

- name: "Code style, compile tests, MiMa. Run locally with: sbt +~2.13 \"verifyCodeStyle; Test/compile; mimaReportBinaryIssues\""
run: sbt +~2.13 "verifyCodeStyle; Test/compile; mimaReportBinaryIssues"
- name: "Code style, compile tests, MiMa. Run locally with: sbt \"verifyCodeStyle; +Test/compile; mimaReportBinaryIssues\""
run: sbt "verifyCodeStyle; +Test/compile; mimaReportBinaryIssues"

documentation:
name: ScalaDoc, Documentation with Paradox
Expand Down
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ lazy val azureStorageQueue = alpakkaProject(

lazy val cassandra =
alpakkaProject("cassandra", "cassandra", Dependencies.Cassandra)
.settings(Scala3.settings)

lazy val couchbase =
alpakkaProject("couchbase", "couchbase", Dependencies.Couchbase)

lazy val csv = alpakkaProject("csv", "csv")
lazy val csv = alpakkaProject("csv", "csv").settings(Scala3.settings)

lazy val csvBench = internalProject("csv-bench")
.dependsOn(csv)
Expand Down Expand Up @@ -444,6 +445,7 @@ lazy val docs = project
)

lazy val testkit = internalProject("testkit", Dependencies.testkit)
.settings(Scala3.settings) // needed for modules that depend on testKit, e.g. csv

lazy val `doc-examples` = project
.enablePlugins(AutomateHeaderPlugin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ final class CassandraSession(@InternalApi private[akka] val delegate: scaladsl.C
onClose: java.lang.Runnable) =
this(system.classicSystem, sessionProvider, executionContext, log, metricsCategory, init, onClose)

implicit private val ec = delegate.ec
implicit private val ec: ExecutionContext = delegate.ec

/**
* Closes the underlying Cassandra session.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import scala.concurrent.duration._

final class CassandraSessionPerformanceSpec extends CassandraSpecBase(ActorSystem("CassandraSessionPerformanceSpec")) {

val log = Logging(system, this.getClass)
val log = Logging(system, this.getClass.asInstanceOf[Class[Any]])

val data = 1 to 5 * 1000 * 1000

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import scala.concurrent.duration._

final class CassandraSessionSpec extends CassandraSpecBase(ActorSystem("CassandraSessionSpec")) {

val log = Logging(system, this.getClass)
val log = Logging(system, this.getClass.asInstanceOf[Class[Any]])
val javadslSessionRegistry = javadsl.CassandraSessionRegistry.get(system)

val data = 1 until 103
Expand Down
4 changes: 2 additions & 2 deletions csv/src/test/scala/docs/scaladsl/CsvParsingSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
package docs.scaladsl

import java.nio.file.Paths

import akka.NotUsed
import akka.stream.alpakka.csv.scaladsl.{CsvParsing, CsvToMap}
import akka.stream.scaladsl.{FileIO, Flow, Keep, Sink, Source}
import akka.stream.testkit.{TestPublisher, TestSubscriber}
import akka.stream.testkit.scaladsl.StreamTestKit.assertAllStagesStopped
import akka.stream.testkit.scaladsl.{TestSink, TestSource}
import akka.util.ByteString
Expand Down Expand Up @@ -120,7 +120,7 @@ class CsvParsingSpec extends CsvSpec {
}

"emit completion even without new line at end" in assertAllStagesStopped {
val (source, sink) = TestSource[ByteString]()
val (source: TestPublisher.Probe[ByteString], sink: TestSubscriber.Probe[List[String]]) = TestSource[ByteString]()
.via(CsvParsing.lineScanner())
.map(_.map(_.utf8String))
.toMat(TestSink[List[String]]())(Keep.both)
Expand Down
7 changes: 5 additions & 2 deletions csv/src/test/scala/docs/scaladsl/CsvSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

package docs.scaladsl

import akka.actor.ActorSystem
import akka.actor.{ActorSystem, ClassicActorSystemProvider}
import akka.stream.Materializer
import akka.stream.alpakka.testkit.scaladsl.LogCapturing
import akka.testkit.TestKit
import org.scalatest.concurrent.ScalaFutures
Expand All @@ -20,7 +21,9 @@ abstract class CsvSpec
with ScalaFutures
with LogCapturing {

implicit val system = ActorSystem(this.getClass.getSimpleName)
implicit val system: ActorSystem = ActorSystem(this.getClass.getSimpleName)
implicit val classic: ClassicActorSystemProvider = system
implicit val mat: Materializer = Materializer(system)

override protected def afterAll(): Unit =
TestKit.shutdownActorSystem(system)
Expand Down
2 changes: 1 addition & 1 deletion mongodb/src/test/scala/docs/scaladsl/MongoSinkSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MongoSinkSpec
private val domainObjectsDocumentColl = db.getCollection("domainObjectsSink")

implicit val defaultPatience =
PatienceConfig(timeout = 5.seconds, interval = 50.millis)
PatienceConfig(timeout = 10.seconds, interval = 100.millis)

override def afterEach(): Unit = {
Source.fromPublisher(numbersDocumentColl.deleteMany(new Document())).runWith(Sink.head).futureValue
Expand Down
25 changes: 16 additions & 9 deletions project/Common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object Common extends AutoPlugin {
override lazy val projectSettings = Dependencies.Common ++ Seq(
projectInfoVersion := (if (isSnapshot.value) "snapshot" else version.value),
crossVersion := CrossVersion.binary,
crossScalaVersions := Dependencies.ScalaVersions,
crossScalaVersions := Dependencies.Scala2Versions,
scalaVersion := Dependencies.Scala213,
scalacOptions ++= Seq(
"-encoding",
Expand All @@ -55,7 +55,8 @@ object Common extends AutoPlugin {
"8"
),
scalacOptions ++= (scalaVersion.value match {
case Dependencies.Scala213 if insideCI.value && fatalWarnings.value && !Dependencies.CronBuild =>
case Dependencies.Scala213
if insideCI.value && fatalWarnings.value && !Dependencies.CronBuild && scalaVersion.value != Dependencies.Scala3 =>
Seq("-Werror")
case _ => Seq.empty[String]
}),
Expand All @@ -65,14 +66,20 @@ object Common extends AutoPlugin {
"-doc-version",
version.value,
"-sourcepath",
(ThisBuild / baseDirectory).value.toString,
"-skip-packages",
"akka.pattern:" + // for some reason Scaladoc creates this
"org.mongodb.scala:" + // this one is a mystery as well
(ThisBuild / baseDirectory).value.toString
) ++ {
// excluding generated grpc classes, except the model ones (com.google.pubsub)
"com.google.api:com.google.cloud:com.google.iam:com.google.logging:" +
"com.google.longrunning:com.google.protobuf:com.google.rpc:com.google.type"
),
val skip = "akka.pattern:" + // for some reason Scaladoc creates this
"org.mongodb.scala:" + // this one is a mystery as well
// excluding generated grpc classes, except the model ones (com.google.pubsub)
"com.google.api:com.google.cloud:com.google.iam:com.google.logging:" +
"com.google.longrunning:com.google.protobuf:com.google.rpc:com.google.type"
if (scalaBinaryVersion.value.startsWith("3")) {
Seq(s"-skip-packages:$skip") // different usage in scala3
} else {
Seq("-skip-packages", skip)
}
},
Compile / doc / scalacOptions ++=
Seq(
"-doc-source-url", {
Expand Down
4 changes: 3 additions & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ object Dependencies {

val Scala213 = "2.13.10" // update even in link-validator.conf
val Scala212 = "2.12.17"
val ScalaVersions = Seq(Scala213, Scala212)
val Scala3 = "3.1.3"
val Scala2Versions = Seq(Scala213, Scala212)
val ScalaVersions = Dependencies.Scala2Versions :+ Dependencies.Scala3

val AkkaVersion = "2.7.0"
val AkkaBinaryVersion = "2.7"
Expand Down
7 changes: 7 additions & 0 deletions project/Scala3.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sbt.Keys.crossScalaVersions

object Scala3 {

val settings = Seq(crossScalaVersions := Dependencies.ScalaVersions)

}

0 comments on commit 07ab774

Please sign in to comment.