Skip to content

Commit

Permalink
Merge pull request #1348 from Philippus/apply-scalafmtsbt
Browse files Browse the repository at this point in the history
Set up scalafmtSbt
  • Loading branch information
hughsimpson authored Oct 11, 2024
2 parents b8dea69 + 1b46829 commit f4898d9
Show file tree
Hide file tree
Showing 12 changed files with 336 additions and 352 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Initial scalafmtAll was applied
022216d6b1ebe4dd0c00aef204625f7f3372fc90
# Initial scalafmtSbt was applied
75eea26c78cd437116617eedc9bc1a144d163921
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ jobs:
jvm: adopt:8
apps: sbt
- name: Test
run: sbt -v "+scalafmtCheckAll"

run: sbt -v "+scalafmtCheckAll;scalafmtSbtCheck"
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ If you want to make a code contribution to the project

Awesome! First, please note that we try to follow the [commit message conventions] used by the Spray guys and we need
you to electronically fill our [CLA] before accepting your contribution. This project uses scalafmt for style, so
remember to apply scalafmtAll to your commit. Also, if your PR contains various commits, please squash them into a
single commit. Let the PR rain begin!
remember to apply scalafmtAll and scalafmtSbt to your commit. Also, if your PR contains various commits, please squash
them into a single commit. Let the PR rain begin!


[open an issue]: https://github.com/kamon-io/Kamon/issues/new
Expand Down
329 changes: 140 additions & 189 deletions build.sbt

Large diffs are not rendered by default.

123 changes: 64 additions & 59 deletions instrumentation/kamon-akka/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ lazy val `Compile-Akka-2.6` = config("akka-2.6")
/**
* Test Configurations
*/
lazy val TestCommon = config("test-common") extend(Common)
lazy val `Test-Akka-2.5` = config("test-akka-2.5") extend(`Compile-Akka-2.5`)
lazy val `Test-Akka-2.6` = config("test-akka-2.6") extend(`Compile-Akka-2.6`)
lazy val TestCommon = config("test-common") extend (Common)
lazy val `Test-Akka-2.5` = config("test-akka-2.5") extend (`Compile-Akka-2.5`)
lazy val `Test-Akka-2.6` = config("test-akka-2.6") extend (`Compile-Akka-2.6`)

configs(
Common,
Expand All @@ -34,91 +34,98 @@ inConfig(Common)(Defaults.compileSettings ++ Seq(
crossScalaVersions := Seq(`scala_2.12_version`, `scala_2.13_version`, scala_3_version)
))

libraryDependencies ++= { if(scalaBinaryVersion.value == "2.11") Seq.empty else Seq(
kanelaAgent % Common,
scalatest % TestCommon,
logbackClassic % TestCommon,
"com.typesafe.akka" %% "akka-actor" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-slf4j" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-remote" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-cluster" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-cluster-sharding" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-protobuf" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.6-version` % TestCommon
)}

libraryDependencies ++= {
if (scalaBinaryVersion.value == "2.11") Seq.empty
else Seq(
kanelaAgent % Common,
scalatest % TestCommon,
logbackClassic % TestCommon,
"com.typesafe.akka" %% "akka-actor" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-slf4j" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-remote" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-cluster" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-cluster-sharding" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-protobuf" % `Akka-2.6-version` % Common,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.6-version` % TestCommon
)
}

inConfig(`Compile-Akka-2.6`)(Defaults.compileSettings ++ Seq(
crossScalaVersions := Seq(`scala_2.12_version`, `scala_2.13_version`, scala_3_version),
sources := joinSources(Common, `Compile-Akka-2.6`).value
))

libraryDependencies ++= { if(scalaBinaryVersion.value == "2.11") Seq.empty else Seq(
kanelaAgent % `Compile-Akka-2.6`,
scalatest % `Test-Akka-2.6`,
logbackClassic % `Test-Akka-2.6`,
"com.typesafe.akka" %% "akka-actor" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-slf4j" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-remote" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-cluster" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-cluster-sharding" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-protobuf" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.6-version` % `Test-Akka-2.6`
)}

libraryDependencies ++= {
if (scalaBinaryVersion.value == "2.11") Seq.empty
else Seq(
kanelaAgent % `Compile-Akka-2.6`,
scalatest % `Test-Akka-2.6`,
logbackClassic % `Test-Akka-2.6`,
"com.typesafe.akka" %% "akka-actor" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-slf4j" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-remote" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-cluster" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-cluster-sharding" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-protobuf" % `Akka-2.6-version` % `Compile-Akka-2.6`,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.6-version` % `Test-Akka-2.6`
)
}

inConfig(`Compile-Akka-2.5`)(Defaults.compileSettings ++ Seq(
sources := joinSources(Common, `Compile-Akka-2.5`).value
))

libraryDependencies ++= {if (scalaVersion.value startsWith "3") Seq.empty else Seq(
kanelaAgent % `Compile-Akka-2.5`,
scalatest % `Test-Akka-2.5`,
logbackClassic % `Test-Akka-2.5`,
"com.typesafe.akka" %% "akka-actor" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-slf4j" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-remote" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-cluster" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-cluster-sharding" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-protobuf" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.5-version` % `Test-Akka-2.5`
)}
libraryDependencies ++= {
if (scalaVersion.value startsWith "3") Seq.empty
else Seq(
kanelaAgent % `Compile-Akka-2.5`,
scalatest % `Test-Akka-2.5`,
logbackClassic % `Test-Akka-2.5`,
"com.typesafe.akka" %% "akka-actor" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-slf4j" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-remote" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-cluster" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-cluster-sharding" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-protobuf" % `Akka-2.5-version` % `Compile-Akka-2.5`,
"com.typesafe.akka" %% "akka-testkit" % `Akka-2.5-version` % `Test-Akka-2.5`
)
}

// Ensure that the packaged artifact contains the instrumentation for all Akka versions.
Compile / packageBin / mappings := Def.taskDyn {
if(scalaBinaryVersion.value == "2.11") {
if (scalaBinaryVersion.value == "2.11") {
Def.task {
joinProducts((`Compile-Akka-2.5` / products).value) ++
joinProducts((Common / unmanagedResourceDirectories).value)
}
} else if (scalaVersion.value startsWith "3") {
Def.task {
joinProducts((`Compile-Akka-2.6` / products).value) ++
joinProducts((`Compile-Akka-2.6` / products).value) ++
joinProducts((Common / unmanagedResourceDirectories).value)
}
} else {
Def.task {
joinProducts(
(`Compile-Akka-2.5` / products).value ++
(`Compile-Akka-2.6` / products).value
) ++ joinProducts((Common / unmanagedResourceDirectories).value)
) ++ joinProducts((Common / unmanagedResourceDirectories).value)
}
}
}.value

// Ensure that the packaged sources contains the instrumentation for all Akka versions.
Compile / packageSrc / mappings := Def.taskDyn {
if(scalaBinaryVersion.value == "2.11") {
if (scalaBinaryVersion.value == "2.11") {
Def.task {
(`Compile-Akka-2.5` / packageSrc / mappings).value ++
(Common / packageSrc / mappings).value
}
}
} else if (scalaVersion.value startsWith "3") {
Def.task {
(`Compile-Akka-2.6` / packageSrc / mappings).value ++
(`Compile-Akka-2.6` / packageSrc / mappings).value ++
(Common / packageSrc / mappings).value
}
} else {
Expand All @@ -128,19 +135,19 @@ Compile / packageSrc / mappings := Def.taskDyn {
(Common / packageSrc / mappings).value
}
}
}.value
}.value

// Compile will return the compile analysis for the Common configuration but will run on all Akka configurations.
Compile / compile := Def.taskDyn {
if(scalaBinaryVersion.value == "2.11") {
if (scalaBinaryVersion.value == "2.11") {
Def.task {
(`Compile-Akka-2.5` / compile).value
}
} else if (scalaVersion.value startsWith "3"){
} else if (scalaVersion.value startsWith "3") {

Def.task {
(`Compile-Akka-2.6` / compile).value
}
}
} else {
Def.task {
(`Compile-Akka-2.5` / compile).value
Expand All @@ -151,7 +158,6 @@ Compile / compile := Def.taskDyn {

exportJars := true


/**
* Test-related settings
*/
Expand Down Expand Up @@ -181,19 +187,18 @@ inConfig(`Test-Akka-2.6`)(Defaults.testSettings ++ instrumentationSettings ++ ba
))

Test / test := Def.taskDyn {
if(scalaBinaryVersion.value == "2.11") {
if (scalaBinaryVersion.value == "2.11") {
Def.task {
(`Test-Akka-2.5` / test).value
}
} else if (scalaVersion.value startsWith "3") {
Def.task {
(`Test-Akka-2.6` / test).value
}
}
else {
} else {
Def.task {
(`Test-Akka-2.5` / test).value
(`Test-Akka-2.6` / test).value
}
}
}.value
}.value
10 changes: 5 additions & 5 deletions instrumentation/kamon-cassandra/build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lazy val Cassandra3xTest = config("testCas3") extend(Test)
lazy val Cassandra4xTest = config("testCas4") extend(Test)
lazy val Cassandra3xTest = config("testCas3") extend (Test)
lazy val Cassandra4xTest = config("testCas4") extend (Test)

val cassandra3xDriverVersion = "3.10.0"
val cassandra4xDriverVersion = "4.10.0"
Expand All @@ -16,15 +16,15 @@ libraryDependencies ++= Seq(
)

libraryDependencies ++= Seq(
"com.datastax.oss" % "java-driver-core" % cassandra4xDriverVersion % "provided,testCas4",
"com.datastax.oss" % "java-driver-query-builder" % cassandra4xDriverVersion % "provided,testCas4"
"com.datastax.oss" % "java-driver-core" % cassandra4xDriverVersion % "provided,testCas4",
"com.datastax.oss" % "java-driver-query-builder" % cassandra4xDriverVersion % "provided,testCas4"
)

configs(Cassandra3xTest, Cassandra4xTest)
inConfig(Cassandra3xTest)(Defaults.testSettings)
inConfig(Cassandra4xTest)(Defaults.testSettings)

Test / test := {
Test / test := {
(Cassandra3xTest / test).value
(Cassandra4xTest / test).value
}
37 changes: 23 additions & 14 deletions instrumentation/kamon-executors/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,30 @@ import sbt.Tests.{Group, SubProcess}
Test / testGrouping := groupByExperimentalExecutorTests((Test / definedTests).value, kanelaAgentJar.value)

def groupByExperimentalExecutorTests(tests: Seq[TestDefinition], kanelaJar: File): Seq[Group] = {
val (stable, experimental) = tests.partition(t => t.name != "kamon.instrumentation.executor.CaptureContextOnSubmitInstrumentationSpec")
val (stable, experimental) =
tests.partition(t => t.name != "kamon.instrumentation.executor.CaptureContextOnSubmitInstrumentationSpec")

val stableGroup = Group("stableTests", stable, SubProcess(
ForkOptions().withRunJVMOptions(Vector(
"-javaagent:" + kanelaJar.toString
))
))
val stableGroup = Group(
"stableTests",
stable,
SubProcess(
ForkOptions().withRunJVMOptions(Vector(
"-javaagent:" + kanelaJar.toString
))
)
)

val experimentalGroup = Group("experimentalTests", experimental, SubProcess(
ForkOptions().withRunJVMOptions(Vector(
"-javaagent:" + kanelaJar.toString,
"-Dkanela.modules.executor-service.enabled=false",
"-Dkanela.modules.executor-service-capture-on-submit.enabled=true"
))
))
val experimentalGroup = Group(
"experimentalTests",
experimental,
SubProcess(
ForkOptions().withRunJVMOptions(Vector(
"-javaagent:" + kanelaJar.toString,
"-Dkanela.modules.executor-service.enabled=false",
"-Dkanela.modules.executor-service-capture-on-submit.enabled=true"
))
)
)

Seq(stableGroup, experimentalGroup)
}
}
31 changes: 17 additions & 14 deletions instrumentation/kamon-pekko/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ inConfig(Compile)(Defaults.compileSettings ++ Seq(
))

val pekkoVersion = "1.0.1"
libraryDependencies ++= { if(scalaBinaryVersion.value == "2.11") Seq.empty else Seq(
kanelaAgent % "provided",
scalatest % Test,
logbackClassic % Test,
"org.apache.pekko" %% "pekko-actor" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-testkit" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-slf4j" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-remote" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-cluster" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-cluster-sharding" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-protobuf" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-testkit" % pekkoVersion % Test
)}
libraryDependencies ++= {
if (scalaBinaryVersion.value == "2.11") Seq.empty
else Seq(
kanelaAgent % "provided",
scalatest % Test,
logbackClassic % Test,
"org.apache.pekko" %% "pekko-actor" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-testkit" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-slf4j" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-remote" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-cluster" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-cluster-sharding" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-protobuf" % pekkoVersion % "provided,test",
"org.apache.pekko" %% "pekko-testkit" % pekkoVersion % Test
)
}

exportJars := true

Expand All @@ -33,5 +36,5 @@ lazy val baseTestSettings = Seq(
)

inConfig(Test)(Defaults.testSettings ++ instrumentationSettings ++ baseTestSettings ++ Seq(
crossScalaVersions := Seq(`scala_2.12_version`, `scala_2.13_version`, scala_3_version),
crossScalaVersions := Seq(`scala_2.12_version`, `scala_2.13_version`, scala_3_version)
))
Loading

0 comments on commit f4898d9

Please sign in to comment.