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

Scala3 builds csv, cassandra, testkit #2957

Merged
merged 9 commits into from
Feb 28, 2023
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 csv/src/test/scala/docs/scaladsl/CsvToMapSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -460,5 +460,5 @@ class CsvToMapSpec extends CsvSpec {
)
)
// #header-line
}
}(mat)
sebastian-alfers marked this conversation as resolved.
Show resolved Hide resolved
}
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)
Copy link
Member

Choose a reason for hiding this comment

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

Re scala3 in PRs, I got the understanding that we only want scala3 (same for 2.12) to be used during cros publishing. At least this is how it is right now for the scla3 builds I was working on.

We should at minimum compile with all Scala versions. We typically do that with +Test/compile. That should be changed here

run: sbt +~2.13 "verifyCodeStyle; Test/compile; mimaReportBinaryIssues"

It's probably obsolete to use 2.13 there, since 2.13 is the default version.

Also, currently I think we run tests with the default 2.13, which is good, but it means that we currently don't build with 2.12 at all (unless I missed something, didn't look so close). Anyway, that is fixed by compiling with +Test/compile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, will review.

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)

}