Skip to content

Commit

Permalink
Merge branch 'main' into update/sbt-scalajs-1.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilquist authored Feb 8, 2023
2 parents 34acf51 + e7a89b2 commit 6b54fe1
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1')
run: mkdir -p modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/.jvm/target modules/opentracing/target modules/noop/native/target modules/xray/.js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/log-odin/target modules/mtl/jvm/target modules/opentelemetry/target modules/lightstep/target project/target
run: mkdir -p modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target modules/testkit/native/target target modules/log/native/target modules/testkit/js/target .js/target modules/core-tests/js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/.jvm/target modules/opentracing/target modules/noop/native/target modules/xray/.js/target modules/core/js/target modules/noop/js/target modules/core-tests/jvm/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/log-odin/target modules/mtl/jvm/target modules/testkit/jvm/target modules/core-tests/native/target modules/opentelemetry/target modules/lightstep/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1')
run: tar cf targets.tar modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/.jvm/target modules/opentracing/target modules/noop/native/target modules/xray/.js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/log-odin/target modules/mtl/jvm/target modules/opentelemetry/target modules/lightstep/target project/target
run: tar cf targets.tar modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target modules/testkit/native/target target modules/log/native/target modules/testkit/js/target .js/target modules/core-tests/js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/.jvm/target modules/opentracing/target modules/noop/native/target modules/xray/.js/target modules/core/js/target modules/noop/js/target modules/core-tests/jvm/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/log-odin/target modules/mtl/jvm/target modules/testkit/jvm/target modules/core-tests/native/target modules/opentelemetry/target modules/lightstep/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1')
Expand Down
16 changes: 16 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ pull_request_rules:
add:
- core
remove: []
- name: Label core-tests PRs
conditions:
- files~=^modules/core-tests/
actions:
label:
add:
- core-tests
remove: []
- name: Label datadog PRs
conditions:
- files~=^modules/datadog/
Expand Down Expand Up @@ -165,6 +173,14 @@ pull_request_rules:
add:
- opentracing
remove: []
- name: Label testkit PRs
conditions:
- files~=^modules/testkit/
actions:
label:
add:
- testkit
remove: []
- name: Label xray PRs
conditions:
- files~=^modules/xray/
Expand Down
47 changes: 35 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ ThisBuild / tlBaseVersion := "0.3"

val scala212Version = "2.12.17"
val scala213Version = "2.13.10"
val scala30Version = "3.2.1"
val scala30Version = "3.2.2"

val collectionCompatVersion = "2.9.0"

val catsVersion = "2.9.0"
val catsEffectVersion = "3.4.5"
val catsEffectVersion = "3.4.6"
val fs2Version = "3.5.0"

// Publishing
Expand Down Expand Up @@ -61,17 +61,14 @@ lazy val commonSettings = Seq(
)
)

lazy val commonNativeSettings = Seq(
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.7").toMap
)

// Compilation
ThisBuild / scalaVersion := scala213Version
ThisBuild / crossScalaVersions := Seq(scala212Version, scala213Version, scala30Version)
ThisBuild / githubWorkflowScalaVersions := Seq("2.12", "2.13", "3")

lazy val root = tlCrossRootProject.aggregate(
core,
coreTests,
jaeger,
honeycomb,
opencensus,
Expand All @@ -87,6 +84,7 @@ lazy val root = tlCrossRootProject.aggregate(
noop,
xray,
logOdin,
testkit,
examples
)

Expand All @@ -106,7 +104,15 @@ lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
"org.scala-lang.modules" %%% "scala-collection-compat" % collectionCompatVersion
)
)
.nativeSettings(commonNativeSettings)
.nativeSettings(
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.7").toMap
)

lazy val coreTests = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.in(file("modules/core-tests"))
.dependsOn(core, testkit)
.enablePlugins(AutomateHeaderPlugin, NoPublishPlugin)
.settings(commonSettings)

lazy val jaeger = project
.in(file("modules/jaeger"))
Expand Down Expand Up @@ -229,8 +235,8 @@ lazy val datadog = project
name := "natchez-datadog",
description := "Datadog bindings for Natchez.",
libraryDependencies ++= Seq(
"com.datadoghq" % "dd-trace-ot" % "1.5.0",
"com.datadoghq" % "dd-trace-api" % "1.5.0"
"com.datadoghq" % "dd-trace-ot" % "1.6.0",
"com.datadoghq" % "dd-trace-api" % "1.6.0"
)
)

Expand All @@ -248,7 +254,9 @@ lazy val log = crossProject(JSPlatform, JVMPlatform, NativePlatform)
"io.github.cquiroz" %%% "scala-java-time" % "2.5.0" % Test
)
)
.nativeSettings(commonNativeSettings)
.nativeSettings(
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.7").toMap
)

lazy val newrelic = project
.in(file("modules/newrelic"))
Expand Down Expand Up @@ -278,7 +286,9 @@ lazy val mtl = crossProject(JSPlatform, JVMPlatform, NativePlatform)
"org.typelevel" %%% "cats-mtl" % "1.3.0"
)
)
.nativeSettings(commonNativeSettings)
.nativeSettings(
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.7").toMap
)

lazy val noop = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.in(file("modules/noop"))
Expand All @@ -290,7 +300,9 @@ lazy val noop = crossProject(JSPlatform, JVMPlatform, NativePlatform)
description := "No-Op Open Tracing implementation",
libraryDependencies ++= Seq()
)
.nativeSettings(commonNativeSettings)
.nativeSettings(
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.7").toMap
)

lazy val xray = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
Expand Down Expand Up @@ -369,6 +381,17 @@ lazy val logOdin = project
)
)

lazy val testkit = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.in(file("modules/testkit"))
.dependsOn(core)
.enablePlugins(AutomateHeaderPlugin)
.settings(commonSettings)
.settings(
name := "natchez-testkit",
description := "In-memory Natchez implementation that is useful for testing",
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.3.1").toMap
)

lazy val docs = project
.in(file("modules/docs"))
.dependsOn(mtl.jvm, honeycomb, datadog, jaeger, log.jvm, opentelemetry)
Expand Down
59 changes: 59 additions & 0 deletions modules/core-tests/shared/src/test/scala/InMemorySuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2019-2020 by Rob Norris and Contributors
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT

package natchez

import cats.data.Kleisli
import cats.effect.{IO, MonadCancelThrow}
import munit.CatsEffectSuite
import natchez.InMemory.Lineage.defaultRootName

trait InMemorySuite extends CatsEffectSuite {
type Lineage = InMemory.Lineage
val Lineage = InMemory.Lineage
type NatchezCommand = InMemory.NatchezCommand
val NatchezCommand = InMemory.NatchezCommand

trait TraceTest {
def program[F[_]: MonadCancelThrow: Trace]: F[Unit]
def expectedHistory: List[(Lineage, NatchezCommand)]
}

def traceTest(name: String, tt: TraceTest): Unit = {
test(s"$name - Kleisli")(
testTraceKleisli(tt.program[Kleisli[IO, Span[IO], *]](implicitly, _), tt.expectedHistory)
)
test(s"$name - IOLocal")(testTraceIoLocal(tt.program[IO](implicitly, _), tt.expectedHistory))
}

def testTraceKleisli(
traceProgram: Trace[Kleisli[IO, Span[IO], *]] => Kleisli[IO, Span[IO], Unit],
expectedHistory: List[(Lineage, NatchezCommand)]
): IO[Unit] = testTrace[Kleisli[IO, Span[IO], *]](
traceProgram,
root => IO.pure(Trace[Kleisli[IO, Span[IO], *]] -> (k => k.run(root))),
expectedHistory
)

def testTraceIoLocal(
traceProgram: Trace[IO] => IO[Unit],
expectedHistory: List[(Lineage, NatchezCommand)]
): IO[Unit] = testTrace[IO](traceProgram, Trace.ioTrace(_).map(_ -> identity), expectedHistory)

def testTrace[F[_]](
traceProgram: Trace[F] => F[Unit],
makeTraceAndResolver: Span[IO] => IO[(Trace[F], F[Unit] => IO[Unit])],
expectedHistory: List[(Lineage, NatchezCommand)]
): IO[Unit] =
InMemory.EntryPoint.create[IO].flatMap { ep =>
val traced = ep.root(defaultRootName).use { r =>
makeTraceAndResolver(r).flatMap { case (traceInstance, resolve) =>
resolve(traceProgram(traceInstance))
}
}
traced *> ep.ref.get.map { history =>
assertEquals(history.toList, expectedHistory)
}
}
}
Loading

0 comments on commit 6b54fe1

Please sign in to comment.