Skip to content

Commit

Permalink
Merge pull request #347 from tpolecat/ce3-scala-3
Browse files Browse the repository at this point in the history
Scala 3 (series/0.1)
  • Loading branch information
tpolecat committed May 17, 2021
2 parents 16d0a0c + 55d6a0d commit 09082d0
Show file tree
Hide file tree
Showing 30 changed files with 581 additions and 39 deletions.
93 changes: 55 additions & 38 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
val scala212Version = "2.12.12"
val scala213Version = "2.13.5"
val scala30PreviousVersion = "3.0.0-RC2"
val scala30Version = "3.0.0-RC3"
val scala30Version = "3.0.0"

val collectionCompatVersion = "2.4.3"
val collectionCompatVersion = "2.4.4"

val catsVersion = "2.6.0"
val catsEffectVersion = "3.1.0"
val catsVersion = "2.6.1"
val catsEffectVersion = "3.1.1"

// We do `evictionCheck` in CI and don't sweat the Java deps for now.
inThisBuild(Seq(
Expand All @@ -23,6 +22,12 @@ inThisBuild(Seq(
"org.typelevel" % "*" % "semver-spec",
"org.scala-js" % "*" % "semver-spec",
"org.jctools" % "*" % "always",
"org.jetbrains" % "*" % "always",
"org.jboss.logging" % "*" % "always",
"org.jboss.threads" % "*" % "always",
"org.wildfly.common" % "*" % "always",
"org.jboss.xnio" % "*" % "always",
"com.lihaoyi" % "*" % "always",
)
))

Expand All @@ -49,14 +54,14 @@ lazy val commonSettings = Seq(

// Testing
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % "0.7.25" % Test,
"org.typelevel" %%% "munit-cats-effect-3" % "1.0.2" % Test,
"org.scalameta" %%% "munit" % "0.7.26" % Test,
"org.typelevel" %%% "munit-cats-effect-3" % "1.0.3" % Test,
),
testFrameworks += new TestFramework("munit.Framework"),

// Compilation
scalaVersion := scala213Version,
crossScalaVersions := Seq(scala212Version, scala213Version, scala30PreviousVersion, scala30Version),
crossScalaVersions := Seq(scala212Version, scala213Version, scala30Version),
Compile / console / scalacOptions --= Seq("-Xfatal-warnings", "-Ywarn-unused:imports"),
Compile / doc / scalacOptions --= Seq("-Xfatal-warnings"),
Compile / doc / scalacOptions ++= Seq(
Expand All @@ -68,26 +73,6 @@ lazy val commonSettings = Seq(
compilerPlugin("org.typelevel" %% "kind-projector" % "0.11.3" cross CrossVersion.full),
).filterNot(_ => scalaVersion.value.startsWith("3.")),

// Add some more source directories
Compile / unmanagedSourceDirectories ++= {
val sourceDir = (Compile / sourceDirectory).value
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq(sourceDir / "scala-3")
case Some((2, _)) => Seq(sourceDir / "scala-2")
case _ => Seq()
}
},

// Also for test
Test / unmanagedSourceDirectories ++= {
val sourceDir = (Test / sourceDirectory).value
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq(sourceDir / "scala-3")
case Some((2, _)) => Seq(sourceDir / "scala-2")
case _ => Seq()
}
},

// dottydoc really doesn't work at all right now
Compile / doc / sources := {
val old = (Compile / doc / sources).value
Expand Down Expand Up @@ -205,7 +190,7 @@ lazy val lightstepGrpc = project
description := "Lightstep gRPC bindings for Natchez.",
libraryDependencies ++= Seq(
"com.lightstep.tracer" % "tracer-grpc" % "0.30.3",
"io.grpc" % "grpc-netty" % "1.37.0",
"io.grpc" % "grpc-netty" % "1.37.1",
"io.netty" % "netty-tcnative-boringssl-static" % "2.0.39.Final"
)
)
Expand Down Expand Up @@ -249,8 +234,8 @@ lazy val datadog = project
description := "Datadog bindings for Natchez.",
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion,
"com.datadoghq" % "dd-trace-ot" % "0.78.3",
"com.datadoghq" % "dd-trace-api" % "0.78.3"
"com.datadoghq" % "dd-trace-ot" % "0.80.0",
"com.datadoghq" % "dd-trace-api" % "0.80.0"
)
)

Expand All @@ -263,13 +248,11 @@ lazy val log = crossProject(JSPlatform, JVMPlatform)
name := "natchez-log",
description := "Logging bindings for Natchez, using log4cats.",
libraryDependencies ++= Seq(
"io.circe" %%% "circe-core" % {
if (scalaVersion.value == scala30PreviousVersion) "0.14.0-M5"
else if (scalaVersion.value == scala30Version) "0.14.0-M6"
else "0.13.0"
"io.circe" %%% "circe-core" % {
if (scalaVersion.value.startsWith("3.")) "0.14.0-M7" else "0.13.0"
},
"org.typelevel" %%% "log4cats-core" % "2.1.0",
"io.github.cquiroz" %%% "scala-java-time" % "2.2.2" % Test,
"org.typelevel" %%% "log4cats-core" % "2.1.1",
"io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test,
)
)
lazy val logJVM = log.jvm.dependsOn(coreJVM)
Expand Down Expand Up @@ -306,7 +289,7 @@ lazy val mtl = crossProject(JSPlatform, JVMPlatform)
name := "natchez-mtl",
description := "cats-mtl bindings for Natchez.",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-mtl" % "1.2.0",
"org.typelevel" %%% "cats-mtl" % "1.2.1",
)
)

Expand Down Expand Up @@ -370,3 +353,37 @@ lazy val examples = project
// "com.github.valskalla" %% "odin-json" % "0.9.1"
// ).filterNot(_ => isDotty.value)
// )

lazy val docs = project
.in(file("modules/docs"))
.dependsOn(jaeger)
.enablePlugins(AutomateHeaderPlugin)
.enablePlugins(ParadoxPlugin)
.enablePlugins(ParadoxSitePlugin)
.enablePlugins(GhpagesPlugin)
.enablePlugins(MdocPlugin)
.settings(commonSettings)
.settings(
scalacOptions := Nil,
git.remoteRepo := "git@github.com:tpolecat/natchez.git",
ghpagesNoJekyll := true,
publish / skip := true,
paradoxTheme := Some(builtinParadoxTheme("generic")),
version := version.value.takeWhile(_ != '+'), // strip off the +3-f22dca22+20191110-1520-SNAPSHOT business
paradoxProperties ++= Map(
"scala-versions" -> (coreJVM / crossScalaVersions).value.map(CrossVersion.partialVersion).flatten.distinct.map { case (a, b) => s"$a.$b"} .mkString("/"),
"org" -> organization.value,
"scala.binary.version" -> s"2.${CrossVersion.partialVersion(scalaVersion.value).get._2}",
"core-dep" -> s"${(coreJVM / name).value}_2.${CrossVersion.partialVersion(scalaVersion.value).get._2}",
"version" -> version.value,
"scaladoc.natchez.base_url" -> s"https://static.javadoc.io/org.tpolecat/natchez-core_2.13/${version.value}",
),
mdocIn := (baseDirectory.value) / "src" / "main" / "paradox",
Compile / paradox / sourceDirectory := mdocOut.value,
makeSite := makeSite.dependsOn(mdoc.toTask("")).value,
mdocExtraArguments := Seq("--no-link-hygiene"), // paradox handles this
libraryDependencies ++= Seq(
// "org.http4s" %% "http4s-dsl" % "1.0.0-M21", // not available yet, ok
)
)

3 changes: 3 additions & 0 deletions modules/docs/src/main/paradox/_template/js/link_fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function sourceUrlFix(sourceUrl) {
$("#source-link").attr("href", sourceUrl.replace("target/mdoc", "src/main/paradox"))
}
9 changes: 9 additions & 0 deletions modules/docs/src/main/paradox/_template/source.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script type="text/javascript" src="$page.base$js/link_fix.js"></script>

$if(page.source_url)$
<div class="source-github">
The source code for this page can be found <a id="source-link" href="$page.source_url$">here</a>.
</div>
$endif$

<script type="text/javascript">jQuery(function(){sourceUrlFix('$page.source_url$')});</script>
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/backends/datadog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Data Dog
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/backends/honeycomb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Honeycomb
20 changes: 20 additions & 0 deletions modules/docs/src/main/paradox/backends/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Back Ends

Natchez supports the following tracing back ends. If you're not sure which one you'd like to use, you might start with @ref:[Jaeger](jaeger.md), which is easy to set up with Docker.

@@@ index

* [DataDog](datadog.md)
* [Honeycomb](honeycomb.md)
* [Jaeger](jaeger.md)
* [Lightstep](lightstep.md)
* [Log4Cats](log4cats.md)
* [Mock](mock.md)
* [New Relic](newrelic.md)
* [No-Op](noop.md)
* [Odin](odin.md)
* [OpenCensus](opencensus.md)

@@@

@@toc { depth=2 }
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/backends/jaeger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Jaeger
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/backends/lightstep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Lightstep
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/backends/log4cats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Log4Cats
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/backends/mock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Mock
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/backends/newrelic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# New Relic
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/backends/noop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# No-Op
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/backends/odin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Odin
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/backends/opencensus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# OpenCensus
64 changes: 64 additions & 0 deletions modules/docs/src/main/paradox/entrypoint.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/examples/http4s.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Http4s
8 changes: 8 additions & 0 deletions modules/docs/src/main/paradox/examples/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Examples

@@@ index

* [Http4s](http4s.md)
* [Skunk](skunk.md)

@@@
1 change: 1 addition & 0 deletions modules/docs/src/main/paradox/examples/skunk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Skunk
60 changes: 60 additions & 0 deletions modules/docs/src/main/paradox/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Natchez


![](natchez.jpg)

_The Natchez Trace, also known as the "Old Natchez Trace", is a historic forest trail within the United States which extends roughly 440 miles (710 km) from Nashville, Tennessee, to Natchez, Mississippi, linking the Cumberland, Tennessee, and Mississippi rivers._

_Credits: [Wikipedia](https://en.wikipedia.org/wiki/Natchez_Trace) and the [National Park Service](https://www.nps.gov/natr/index.htm)._

@@@index

* [Overview](overview.md)
* [Reference](reference/index.md)
* [Back Ends](backends/index.md)
* [Examples](examples/index.md)

@@@

## Welcome!

**Natchez** is a minimal distributed tracing library for Cats, inspired by earlier work done on [puretracing](https://github.com/tabdulradi/puretracing). Natchez is published for **Scala $scala-versions$**, with limited support for Scala-JS.

## Quick Start

1. Choose your dependency:

- If you wish to write **application code** then you should use the dependency specific to your tracing @ref[back end](backends/index.md).

- If you wish to write **library code** that supports any tracing back-end, then you should use the core dependency below (also available for Scala-JS).

@@dependency[sbt,Maven,Gradle] {
group="$org$"
artifact="$core-dep$"
version="$version$"
}


2. Read the @ref:[Overview](overview.md) and explore from there.


Natchez is written for [cats](http://typelevel.org/cats/) and [cats-effect](https://typelevel.org/cats-effect/). This documentation assumes you are familiar with pure-functional programming with effects, including use of `Resource` and tagless-final coding style. If you run into trouble be sure to check out:

- The Natchez channel on [Typelevel Discord](https://sca.la/typeleveldiscord).
- The [API Documentation](https://javadoc.io/doc/org.tpolecat/natchez-core_$scala.binary.version$/$version$/index.html).


3. Let us know how it goes!

## How to Contribute

- If you see a typo in the doc, click the link at the bottom and fix it!
- If you find a bug please open an issue (or fix it and open a PR) at our [GitHub Repository](https://github.com/tpolecat/natchez).
- If you want to make a larger contribution, please open an issue first so we can discuss.

Note that there are two active version series right now:

- Versions **0.0.x** are built with Cats-Effect 2 from branch `master`. This is a terminal series and will end sometime in 2021.
- Versions **0.1.x** are built with Cats-Effect 3 from branch `series/0.1`. This will be the continuing series moving forward.
- Contibutions should target the `master` branch. Maintainers will merge these into `series/0.1` as needed.

Binary file added modules/docs/src/main/paradox/natchez.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 09082d0

Please sign in to comment.