diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dd4cc17..71054760 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: fail-fast: false matrix: java: ['adopt@1.8', 'adopt@1.11'] - scala: ['2.12.14', '2.13.6'] + scala: ['2.12.15', '2.13.6', '3.0.2'] steps: - name: Checkout current branch uses: actions/checkout@v2.3.4 @@ -64,6 +64,9 @@ jobs: uses: coursier/cache-action@v6 - name: Run tests run: sbt ++${{ matrix.scala }}! test + - name: Compile examples + if: ${{ startsWith(matrix.scala, '2') }} + run: ./sbt ++${{ matrix.scala }}! compileExamples ci: runs-on: ubuntu-20.04 diff --git a/build.sbt b/build.sbt index 214de620..b1335d2a 100644 --- a/build.sbt +++ b/build.sbt @@ -36,12 +36,13 @@ Global / testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramew addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt") addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck") +addCommandAlias("compileExamples", "opentracingExample/compile;opentelemetryExample/compile") lazy val root = project .in(file(".")) .settings(publish / skip := true) - .aggregate(opentracing, opentelemetry, opencensus, opentracingExample, opentelemetryExample) + .aggregate(opentracing, opentelemetry, opencensus) lazy val opentracing = project @@ -65,6 +66,7 @@ lazy val opentracingExample = .in(file("opentracing-example")) .settings(stdSettings("opentracing-example")) .settings(publish / skip := true) + .settings(onlyWithScala2) .settings(libraryDependencies := Dependencies.opentracingExample) .dependsOn(opentracing) @@ -73,6 +75,7 @@ lazy val opentelemetryExample = .in(file("opentelemetry-example")) .settings(stdSettings("opentelemetry-example")) .settings(publish / skip := true) + .settings(onlyWithScala2) .settings(libraryDependencies := Dependencies.opentelemetryExample) .dependsOn(opentelemetry) diff --git a/opentracing/src/test/scala/zio/telemetry/opentracing/OpenTracingTest.scala b/opentracing/src/test/scala/zio/telemetry/opentracing/OpenTracingTest.scala index 6236a7c3..88d373ca 100644 --- a/opentracing/src/test/scala/zio/telemetry/opentracing/OpenTracingTest.scala +++ b/opentracing/src/test/scala/zio/telemetry/opentracing/OpenTracingTest.scala @@ -20,7 +20,7 @@ object OpenTracingTest extends DefaultRunnableSpec { ZLayer.fromEffect(UIO(new MockTracer)) val testService: URLayer[HasMockTracer with Clock, OpenTracing] = - ZLayer.fromServiceManaged(tracer => OpenTracing.managed(tracer, "ROOT")) + ZLayer.fromServiceManaged((tracer: MockTracer) => OpenTracing.managed(tracer, "ROOT")) val customLayer = mockTracer ++ ((mockTracer ++ Clock.any) >>> testService) diff --git a/project/BuildHelper.scala b/project/BuildHelper.scala index d4953462..139c12b0 100644 --- a/project/BuildHelper.scala +++ b/project/BuildHelper.scala @@ -5,13 +5,17 @@ object BuildHelper { def stdSettings(prjName: String) = Seq( name := s"$prjName", - crossScalaVersions := Seq(Scala212, Scala213), + crossScalaVersions := Seq(Scala212, Scala213, Scala3), ThisBuild / scalaVersion := Scala212, scalacOptions := stdOptions ++ extraOptions(scalaVersion.value, optimize = !isSnapshot.value), libraryDependencies += compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"), incOptions ~= (_.withLogRecompileOnMacro(false)) ) + val onlyWithScala2 = Seq( + crossScalaVersions := Seq(Scala212, Scala213) + ) + private val versions: Map[String, String] = { import org.snakeyaml.engine.v2.api.{ Load, LoadSettings } @@ -27,15 +31,21 @@ object BuildHelper { private val Scala212: String = versions("2.12") private val Scala213: String = versions("2.13") + private val Scala3: String = versions("3.0") private val stdOptions = Seq( "-deprecation", "-encoding", "UTF-8", "-feature", - "-unchecked", - "-Xfatal-warnings" - ) + "-unchecked" + ) ++ { + if (sys.env.contains("CI")) { + Seq("-Xfatal-warnings") + } else { + Nil // to enable Scalafix locally + } + } private val std2xOptions = Seq( "-language:higherKinds", @@ -52,6 +62,12 @@ object BuildHelper { private def extraOptions(scalaVersion: String, optimize: Boolean) = CrossVersion.partialVersion(scalaVersion) match { + case Some((3, _)) => + Seq( + "-language:implicitConversions", + "-Xignore-scala2-macros" + ) + case Some((2, 13)) => Seq("-Ywarn-unused:params,-implicits", "-Xlint:-byname-implicit") ++ std2xOptions ++ optimizerOptions(optimize) @@ -74,7 +90,6 @@ object BuildHelper { "242" ) ++ std2xOptions ++ optimizerOptions(optimize) - case _ => - Seq.empty + case _ => Seq.empty } } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 6dc3fe40..ef913836 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -25,7 +25,7 @@ object Dependencies { "io.opentracing" % "opentracing-api" % Versions.opentracing, "io.opentracing" % "opentracing-noop" % Versions.opentracing, "io.opentracing" % "opentracing-mock" % Versions.opentracing % Test, - "org.scala-lang.modules" %% "scala-collection-compat" % "2.3.1" + "org.scala-lang.modules" %% "scala-collection-compat" % "2.5.0" ) lazy val opentelemetry = zio ++ Seq(