From 889ab186e632ea65af0c0df6b260332fa7cb8ceb Mon Sep 17 00:00:00 2001 From: Brian Harrington Date: Fri, 1 Mar 2024 07:37:21 -0600 Subject: [PATCH] enable cross-building for scala 3 Help ensure code stays compatible with 3 going forward. --- .github/workflows/pr.yml | 2 +- .github/workflows/release.yml | 3 ++- .github/workflows/snapshot.yml | 3 ++- .../netflix/atlas/eval/model/TimeSeriesMessage.scala | 1 - .../atlas/eval/stream/FinalExprEvalSuite.scala | 7 +++++-- project/BuildSettings.scala | 12 +++++++++++- project/Dependencies.scala | 4 ++-- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1a4ba91ee..0f75d2bd3 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: java: [17, 21] - scala: [2.13.11] + scala: [2.13.13, 3.4.0] steps: - uses: actions/checkout@v3 - name: Set up JDK ${{ matrix.java }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 089ab2d47..c201189f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,5 +31,6 @@ jobs: PGP_PASSPHRASE: ${{ secrets.ORG_SIGNING_PASSWORD }} run: | git fetch --unshallow --tags - cat /dev/null | project/sbt ++2.13.11 clean test +publishSigned + cat /dev/null | project/sbt ++2.13.13 clean test +publishSigned + cat /dev/null | project/sbt ++3.4.0 clean test +publishSigned cat /dev/null | project/sbt sonatypeBundleRelease diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index a6eee5925..d5b2c7b86 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -31,4 +31,5 @@ jobs: PGP_PASSPHRASE: ${{ secrets.ORG_SIGNING_PASSWORD }} run: | git fetch --unshallow --tags - cat /dev/null | project/sbt ++2.13.11 clean test +publishSigned + cat /dev/null | project/sbt ++2.13.13 clean test +publishSigned + cat /dev/null | project/sbt ++3.4.0 clean test +publishSigned diff --git a/atlas-eval/src/main/scala/com/netflix/atlas/eval/model/TimeSeriesMessage.scala b/atlas-eval/src/main/scala/com/netflix/atlas/eval/model/TimeSeriesMessage.scala index dd0611e60..fa36f9b9d 100644 --- a/atlas-eval/src/main/scala/com/netflix/atlas/eval/model/TimeSeriesMessage.scala +++ b/atlas-eval/src/main/scala/com/netflix/atlas/eval/model/TimeSeriesMessage.scala @@ -18,7 +18,6 @@ package com.netflix.atlas.eval.model import com.fasterxml.jackson.core.JsonGenerator import com.netflix.atlas.chart.model.LineStyle import com.netflix.atlas.chart.model.Palette -import com.netflix.atlas.chart.model.PlotDef import com.netflix.atlas.core.model.* import com.netflix.atlas.core.util.Strings import com.netflix.atlas.json.JsonSupport diff --git a/atlas-eval/src/test/scala/com/netflix/atlas/eval/stream/FinalExprEvalSuite.scala b/atlas-eval/src/test/scala/com/netflix/atlas/eval/stream/FinalExprEvalSuite.scala index 59bfd24cb..219fbf839 100644 --- a/atlas-eval/src/test/scala/com/netflix/atlas/eval/stream/FinalExprEvalSuite.scala +++ b/atlas-eval/src/test/scala/com/netflix/atlas/eval/stream/FinalExprEvalSuite.scala @@ -149,12 +149,15 @@ class FinalExprEvalSuite extends FunSuite { } private def getValue(ts: TimeSeriesMessage): Double = { + // https://github.com/lampepfl/dotty/issues/15661 ? + // On 3.4.0 there is an error if using `v` instead of `null` for the case + // where it is not ArrayData. ts.data match { case ArrayData(vs) => assertEquals(vs.length, 1) vs(0) - case v => - fail(s"unexpected data value: $v") + case null => + fail(s"unexpected data value: null") } } diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index 7acb21430..81bb66ee0 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -24,10 +24,11 @@ object BuildSettings { scalacOptions := { CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, _)) => compilerFlags ++ Seq("-Xsource:3") - case _ => compilerFlags + case _ => compilerFlags ++ Seq("-source", "3.3") } }, javacOptions ++= Seq("--release", "17"), + Compile / doc / sources := (Compile / doc / sources).value.filterNot(skipForDocs), crossPaths := true, crossScalaVersions := Dependencies.Versions.crossScala, sourcesInBase := false, @@ -67,4 +68,13 @@ object BuildSettings { .settings(buildSettings: _*) .settings(libraryDependencies ++= commonDeps) } + + /** Ignoring all scala files will cause it to use javadoc instead. This is done to workaround + * an issue with scaladoc on 3.x: + * + * https://github.com/Netflix/atlas/issues/1568 + */ + def skipForDocs(f: File): Boolean = { + f.getName.endsWith(".scala") || f.getName == "Evaluator.java" + } } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index c29c94629..b4b5108e8 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -9,12 +9,12 @@ object Dependencies { val iep = "5.0.17" val jackson = "2.16.1" val log4j = "2.22.1" - val scala = "2.13.12" + val scala = "2.13.13" val slf4j = "1.7.36" val spectator = "1.7.7" val spring = "6.1.3" - val crossScala = Seq(scala) + val crossScala = Seq(scala, "3.4.0") } import Versions._