diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4e463b89e04..12971bef3d3 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - scala: [2.12.12, 2.13.6] + scala: [2.12.12, 2.13.6, 3.2.2] java: ['1.8', '1.11'] project: ['finagle-base-http', 'finagle-benchmark', 'finagle-benchmark-thrift', 'finagle-core', 'finagle-example', 'finagle-exp', 'finagle-grpc-context', 'finagle-http', 'finagle-http2','finagle-init','finagle-integration','finagle-memcached','finagle-mux','finagle-mysql','finagle-netty4','finagle-netty4-http','finagle-opencensus-tracing','finagle-partitioning','finagle-redis','finagle-scribe','finagle-serversets','finagle-stats','finagle-stats-core','finagle-thrift','finagle-thriftmux','finagle-toggle','finagle-tunable','finagle-zipkin-core','finagle-zipkin-scribe'] runs-on: ubuntu-latest @@ -111,4 +111,4 @@ jobs: - name: set up netty snapshot run: source ./netty-snapshot-env.sh - name: test - run: ${{ format('./sbt ++{0} clean "{1}/test"', matrix.scala, matrix.project) }} + run: ${{ format('./sbt "++{0} -v clean; ++{0} {1}/test"', matrix.scala, matrix.project) }} diff --git a/build.sbt b/build.sbt index 83b12af33b3..483a2995225 100644 --- a/build.sbt +++ b/build.sbt @@ -37,7 +37,7 @@ val nettyVersionInfo = settingKey[String]("A setting reference for printing the // zkVersion should be kept in sync with the 'util-zk' dependency version val zkVersion = "3.5.6" -val scalaCollectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.1.2" +val scalaCollectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.7.0" val caffeineLib = "com.github.ben-manes.caffeine" % "caffeine" % "2.9.3" val hdrHistogramLib = "org.hdrhistogram" % "HdrHistogram" % "2.1.11" val jsr305Lib = "com.google.code.findbugs" % "jsr305" % "2.0.1" @@ -142,22 +142,47 @@ def jdk11GcJavaOptions: Seq[String] = { ) } -val sharedSettings = Seq( +val scalacBaseOptions = Seq( + "-deprecation", + "-unchecked", + "-feature", + "-language:_", + "-encoding", + "utf8" +) +val scalac2Options = scalacBaseOptions ++ Seq( + "-target:jvm-1.8", + "-Xlint:-missing-interpolator", + "-Ypatmat-exhaust-depth", + "40" +) +val scalac3Options = scalacBaseOptions ++ Seq( + "-Xtarget:8", +) + +val scalaDependencies = Seq( + // See https://www.scala-sbt.org/0.13/docs/Testing.html#JUnit + "com.novocode" % "junit-interface" % "0.11" % "test", + "org.scalacheck" %% "scalacheck" % "1.15.4" % "test", + scalaCollectionCompat +) +val scala2Dependencies = scalaDependencies ++ Seq( + "org.scalatest" %% "scalatest" % "3.1.1" % "test", + "org.scalatestplus" %% "junit-4-12" % "3.1.2.0" % "test", +) +val scala3Dependencies = scalaDependencies ++ Seq( + "org.scalatest" %% "scalatest" % "3.2.9" % "test", + "org.scalatestplus" %% "junit-4-13" % "3.2.9.0" % "test", + "org.scalatestplus" %% "mockito-3-4" % "3.2.9.0" % "test", + "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" % "test", +) + +val baseSettings = Seq( version := releaseVersion, organization := "com.twitter", scalaVersion := "2.13.6", crossScalaVersions := Seq("2.12.12", "2.13.6"), Test / fork := true, // We have to fork to get the JavaOptions - libraryDependencies ++= Seq( - // See https://www.scala-sbt.org/0.13/docs/Testing.html#JUnit - "com.novocode" % "junit-interface" % "0.11" % "test", - "org.scalacheck" %% "scalacheck" % "1.15.4" % "test", - "org.scalatest" %% "scalatest" % "3.1.1" % "test", - "org.scalatestplus" %% "junit-4-12" % "3.1.2.0" % "test", - "org.scalatestplus" %% "mockito-3-3" % "3.1.2.0" % "test", - "org.scalatestplus" %% "scalacheck-1-14" % "3.1.2.0" % "test", - scalaCollectionCompat - ), // Workaround for cross building Dtab.scala, which is not compatible between // 2.12- with 2.13+. Compile / unmanagedSourceDirectories += { @@ -174,18 +199,11 @@ val sharedSettings = Seq( , - scalacOptions := Seq( - "-target:jvm-1.8", - "-deprecation", - "-unchecked", - "-feature", - "-language:_", - "-encoding", - "utf8", - "-Xlint:-missing-interpolator", - "-Ypatmat-exhaust-depth", - "40" - ), + // We have to switch compiler options like this or sbt has problems selecting the right settings when using + // cross commands like "+test" + scalacOptions := { + if (scalaVersion.value.startsWith("2.")) scalac2Options else scalac3Options + }, javacOptions ++= Seq( "-Xlint:unchecked", "-source", @@ -264,6 +282,17 @@ val sharedSettings = Seq( } ) +val sharedSettings = baseSettings ++ + Seq( + libraryDependencies ++= scala2Dependencies, + ) + +val sharedScala3EnabledSettings = baseSettings ++ + Seq( + libraryDependencies ++= scala3Dependencies, + crossScalaVersions := crossScalaVersions.value ++ Seq("3.2.2"), + ) + val jmockSettings = Seq( libraryDependencies ++= Seq( "org.jmock" % "jmock" % "2.4.0" % "test", @@ -379,7 +408,7 @@ lazy val finagleInit = Project( id = "finagle-init", base = file("finagle-init") ).settings( - sharedSettings + sharedScala3EnabledSettings ).settings( name := "finagle-init" )