Skip to content

Commit

Permalink
Enable Scala 2 inliner and update dependencies (#2054)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyri-petrou authored Dec 21, 2023
1 parent ec142b4 commit ad88995
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 36 deletions.
24 changes: 13 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import com.typesafe.tools.mima.core.*
import org.scalajs.linker.interface.ModuleSplitStyle
import sbtcrossproject.CrossPlugin.autoImport.{ crossProject, CrossType }

Expand All @@ -16,23 +15,23 @@ val http4sVersion = "0.23.24"
val javaTimeVersion = "2.5.0"
val jsoniterVersion = "2.25.0"
val laminextVersion = "0.16.2"
val magnoliaScala2Version = "1.1.6"
val magnoliaScala2Version = "1.1.8"
val magnoliaScala3Version = "1.3.4"
val pekkoHttpVersion = "1.0.0"
val playVersion = "3.0.0"
val playVersion = "3.0.1"
val playJsonVersion = "3.0.1"
val scalafmtVersion = "3.7.17"
val sttpVersion = "3.9.1"
val tapirVersion = "1.9.4"
val zioVersion = "2.0.19"
val tapirVersion = "1.9.5"
val zioVersion = "2.0.20"
val zioInteropCats2Version = "22.0.0.0"
val zioInteropCats3Version = "23.0.0.8"
val zioInteropCats3Version = "23.1.0.0"
val zioInteropReactiveVersion = "2.0.2"
val zioConfigVersion = "3.0.7"
val zqueryVersion = "0.6.0"
val zioJsonVersion = "0.6.2"
val zioHttpVersion = "3.0.0-RC4"
val zioOpenTelemetryVersion = "3.0.0-RC15"
val zioOpenTelemetryVersion = "3.0.0-RC19"
val zioPreludeVersion = "1.0.0-RC21"

Global / onChangedBuildSource := ReloadOnSourceChanges
Expand Down Expand Up @@ -646,17 +645,20 @@ lazy val commonSettings = Def.settings(
"-Ywarn-unused:-nowarn",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit",
"-opt-inline-from:<source>",
"-opt-warnings",
"-opt:l:inline",
"-opt:l:method",
"-opt:l:inline",
"-opt-inline-from:scala.**",
"-explaintypes"
)
case Some((2, 13)) =>
Seq(
"-Xlint:-byname-implicit",
"-explaintypes",
"-opt:l:method"
"-Ybackend-parallelism:4",
"-opt:l:method",
"-opt:l:inline",
"-opt-inline-from:scala.**",
"-explaintypes"
)

case Some((3, _)) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.9.7
sbt.version = 1.9.8
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ private[caliban] trait StringParsers {
case (Some(value), head :: tail) => head :: tail.map(_.drop(value))
case _ => l1
}
// NOTE: @noinline annotation required as Scala 2.12 inlines `.dropWhile` which results in compilation error since these methods are used within fastparse's macros
// remove start lines that are only whitespaces
val l3 = l2.dropWhile("[ \t]*".r.replaceAllIn(_, "").isEmpty)
val l3 = l2.dropWhile("[ \t]*".r.replaceAllIn(_, "").isEmpty): @noinline
// remove end lines that are only whitespaces
val l4 = l3.reverse.dropWhile("[ \t]*".r.replaceAllIn(_, "").isEmpty).reverse
val l4 = (l3.reverse.dropWhile("[ \t]*".r.replaceAllIn(_, "").isEmpty): @noinline).reverse
l4.mkString("\n")
}
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.9.7
sbt.version = 1.9.8
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.16")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % sbtcrossProjectVersion)
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % sbtcrossProjectVersion)
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.6")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.7")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.5.1")
Expand Down
4 changes: 2 additions & 2 deletions sbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

set -o pipefail

declare -r sbt_release_version="1.9.7"
declare -r sbt_unreleased_version="1.9.7"
declare -r sbt_release_version="1.9.8"
declare -r sbt_unreleased_version="1.9.8"

declare -r latest_dotty="3.3.1"
declare -r latest_213="2.13.12"
Expand Down
13 changes: 6 additions & 7 deletions tracing/src/main/scala/caliban/tracing/FieldTracer.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package caliban.tracing

import caliban.CalibanError
import caliban.ResponseValue
import caliban.{ CalibanError, ResponseValue }
import caliban.execution.FieldInfo
import io.opentelemetry.api.trace.StatusCode
import caliban.wrappers.Wrapper.FieldWrapper
import io.opentelemetry.api.trace.StatusCode
import zio._
import zio.query.{ QueryAspect, ZQuery }
import zio.query._
import zio.telemetry.opentelemetry.tracing.{ ErrorMapper, Tracing }
import zio.query.ZQuery
import zio.telemetry.opentelemetry.tracing.{ StatusMapper, Tracing }

object FieldTracer {
val wrapper = new FieldWrapper[Tracing] {
Expand All @@ -21,7 +19,8 @@ object FieldTracer {
) { case (span, end) => end } { case (span, _) =>
query.foldCauseQuery(
cause => {
val status = cause.failureOption.flatMap(ErrorMapper.default.body.lift).getOrElse(StatusCode.ERROR)
val status =
cause.failureOption.flatMap(StatusMapper.default.failure.lift).fold(StatusCode.ERROR)(_.statusCode)
ZQuery.fromZIO(ZIO.succeed(span.setStatus(status, cause.prettyPrint))) *> ZQuery.failCause(cause)
},
value => ZQuery.succeed(value)
Expand Down
17 changes: 6 additions & 11 deletions tracing/src/main/scala/caliban/tracing/SchemaTracer.scala
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
package caliban.tracing

import caliban.CalibanError
import caliban.GraphQLResponse
import caliban.InputValue
import caliban.InputValue.ObjectValue
import caliban.Value
import caliban.Value.FloatValue.FloatNumber
import caliban.Value.IntValue.IntNumber
import caliban.Value.StringValue
import caliban.execution.ExecutionRequest
import caliban.execution.Field
import caliban.execution.{ ExecutionRequest, Field }
import caliban.parsing.adt.OperationType
import caliban.tools.stitching.RemoteQuery
import caliban.wrappers.Wrapper.ExecutionWrapper
import caliban.{ CalibanError, GraphQLResponse, InputValue, Value }
import io.opentelemetry.api.trace.SpanKind
import zio.telemetry.opentelemetry.tracing.ErrorMapper
import zio.telemetry.opentelemetry.tracing.Tracing
import zio._
import zio.telemetry.opentelemetry.tracing.Tracing

object SchemaTracer {
val wrapper = new ExecutionWrapper[Tracing] {
val wrapper: ExecutionWrapper[Tracing] = new ExecutionWrapper[Tracing] {
def wrap[R <: Tracing](
f: ExecutionRequest => ZIO[R, Nothing, GraphQLResponse[CalibanError]]
): ExecutionRequest => ZIO[R, Nothing, GraphQLResponse[CalibanError]] =
Expand All @@ -30,11 +25,11 @@ object SchemaTracer {
if (parentField == "__schema") f(request)
else
ZIO.serviceWithZIO[Tracing](tracer =>
tracer.span[R, Nothing, GraphQLResponse[CalibanError]](
tracer.span(
spanName(request),
SpanKind.INTERNAL
) {
ZIO.foreach(attributes(request.field)) { case (k, v) =>
ZIO.foreachDiscard(attributes(request.field)) { case (k, v) =>
tracer.setAttribute(k, v)
} *> f(request)
}
Expand Down

0 comments on commit ad88995

Please sign in to comment.