mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-21 14:14:28 +01:00
Refactor sbt and make Eclair tests download bitcoind (#727)
This commit is contained in:
parent
d810e17324
commit
f6ed565c14
10 changed files with 174 additions and 168 deletions
|
@ -2,11 +2,6 @@ name := "bitcoin-s-bitcoind-rpc-test"
|
|||
|
||||
libraryDependencies ++= Deps.bitcoindRpcTest(scalaVersion.value)
|
||||
|
||||
lazy val downloadBitcoind = taskKey[Unit] {
|
||||
"Download bitcoind binaries, extract to ./bitcoind-binaries"
|
||||
}
|
||||
|
||||
import java.nio.file.Paths
|
||||
lazy val bitcoindRpc = project in Paths.get("..", "bitcoind-rpc").toFile
|
||||
|
||||
Test / test := (Test / test dependsOn bitcoindRpc / downloadBitcoind).value
|
||||
Test / test := (Test / test dependsOn {
|
||||
Projects.bitcoindRpc / TaskKeys.downloadBitcoind
|
||||
}).value
|
||||
|
|
|
@ -7,16 +7,11 @@ name := "bitcoin-s-bitcoind-rpc"
|
|||
|
||||
libraryDependencies ++= Deps.bitcoindRpc
|
||||
|
||||
dependsOn {
|
||||
lazy val core = project in Paths.get("..", "core").toFile
|
||||
core
|
||||
}
|
||||
dependsOn(Projects.core)
|
||||
|
||||
lazy val downloadBitcoind = taskKey[Unit] {
|
||||
"Download bitcoind binaries, extract to ./binaries/bitcoind"
|
||||
}
|
||||
CommonSettings.prodSettings
|
||||
|
||||
downloadBitcoind := {
|
||||
TaskKeys.downloadBitcoind := {
|
||||
val logger = streams.value.log
|
||||
import scala.sys.process._
|
||||
|
||||
|
|
163
build.sbt
163
build.sbt
|
@ -9,107 +9,6 @@ flywayClean / aggregate := false
|
|||
//allow us to wipe our test databases
|
||||
Test / flywayClean / aggregate := true
|
||||
|
||||
lazy val commonCompilerOpts = {
|
||||
List(
|
||||
"-Xsource:2.12",
|
||||
"-target:jvm-1.8"
|
||||
)
|
||||
}
|
||||
|
||||
val scala2_13CompilerOpts = Seq("-Xlint:unused")
|
||||
|
||||
val nonScala2_13CompilerOpts = Seq(
|
||||
"-Xmax-classfile-name",
|
||||
"128",
|
||||
"-Ywarn-unused",
|
||||
"-Ywarn-unused-import"
|
||||
)
|
||||
|
||||
//https://docs.scala-lang.org/overviews/compiler-options/index.html
|
||||
def compilerOpts(scalaVersion: String) =
|
||||
Seq(
|
||||
"-encoding",
|
||||
"UTF-8",
|
||||
"-unchecked",
|
||||
"-feature",
|
||||
"-deprecation",
|
||||
"-Ywarn-dead-code",
|
||||
"-Ywarn-value-discard",
|
||||
"-Ywarn-unused",
|
||||
"-unchecked",
|
||||
"-deprecation",
|
||||
"-feature"
|
||||
) ++ commonCompilerOpts ++ {
|
||||
if (scalaVersion.startsWith("2.13")) scala2_13CompilerOpts
|
||||
else nonScala2_13CompilerOpts
|
||||
}
|
||||
|
||||
val testCompilerOpts = commonCompilerOpts
|
||||
|
||||
lazy val isCI = {
|
||||
sys.props
|
||||
.get("CI")
|
||||
.isDefined
|
||||
}
|
||||
lazy val commonSettings = List(
|
||||
organization := "org.bitcoin-s",
|
||||
homepage := Some(url("https://bitcoin-s.org")),
|
||||
developers := List(
|
||||
Developer(
|
||||
"christewart",
|
||||
"Chris Stewart",
|
||||
"stewart.chris1234@gmail.com",
|
||||
url("https://twitter.com/Chris_Stewart_5")
|
||||
)
|
||||
),
|
||||
////
|
||||
// scaladoc settings
|
||||
Compile / doc / scalacOptions ++= List(
|
||||
"-doc-title",
|
||||
"Bitcoin-S",
|
||||
"-doc-version",
|
||||
version.value
|
||||
),
|
||||
// Set apiURL to define the base URL for the Scaladocs for our library.
|
||||
// This will enable clients of our library to automatically link against
|
||||
// the API documentation using autoAPIMappings.
|
||||
apiURL := homepage.value.map(_.toString + "/api").map(url(_)),
|
||||
// scaladoc settings end
|
||||
////
|
||||
scalacOptions in Compile := compilerOpts(scalaVersion.value),
|
||||
scalacOptions in Test := testCompilerOpts,
|
||||
Compile / compile / javacOptions ++= {
|
||||
if (isCI) {
|
||||
//jdk11 is used on CI, we need to use the --release flag to make sure
|
||||
//byte code is compatible with jdk 8
|
||||
//https://github.com/eclipse/jetty.project/issues/3244#issuecomment-495322586
|
||||
Seq("--release", "8")
|
||||
} else {
|
||||
Seq("-source", "1.8", "-target", "1.8")
|
||||
}
|
||||
},
|
||||
//show full stack trace of failed tests
|
||||
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oF"),
|
||||
//show duration of tests
|
||||
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oD"),
|
||||
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
|
||||
// Travis has performance issues on macOS
|
||||
Test / parallelExecution := !(Properties.isMac && isCI)
|
||||
)
|
||||
|
||||
lazy val commonTestSettings = Seq(
|
||||
publish / skip := true
|
||||
) ++ commonSettings
|
||||
|
||||
lazy val commonTestWithDbSettings = Seq(
|
||||
// To make in-memory DBs work properly
|
||||
Test / fork := true,
|
||||
// To avoid deadlock issues with SQLite
|
||||
Test / parallelExecution := false
|
||||
) ++ commonTestSettings
|
||||
|
||||
lazy val commonProdSettings = commonSettings
|
||||
|
||||
lazy val Benchmark = config("bench") extend Test
|
||||
lazy val benchSettings: Seq[Def.SettingsDefinition] = {
|
||||
//for scalameter
|
||||
|
@ -129,6 +28,11 @@ lazy val benchSettings: Seq[Def.SettingsDefinition] = {
|
|||
)
|
||||
}
|
||||
|
||||
import Projects._
|
||||
lazy val core = project in file("core")
|
||||
lazy val bitcoindRpc = project in file("bitcoind-rpc")
|
||||
lazy val eclairRpc = project in file("eclair-rpc")
|
||||
|
||||
// quoting the val name this way makes it appear as
|
||||
// 'bitcoin-s' in sbt/bloop instead of 'bitcoins'
|
||||
lazy val `bitcoin-s` = project
|
||||
|
@ -157,7 +61,7 @@ lazy val `bitcoin-s` = project
|
|||
testkit,
|
||||
zmq
|
||||
)
|
||||
.settings(commonSettings: _*)
|
||||
.settings(CommonSettings.settings: _*)
|
||||
// crossScalaVersions must be set to Nil on the aggregating project
|
||||
.settings(crossScalaVersions := Nil)
|
||||
// unidoc aggregates Scaladocs for all subprojects into one big doc
|
||||
|
@ -228,7 +132,7 @@ lazy val `bitcoin-s` = project
|
|||
|
||||
lazy val secp256k1jni = project
|
||||
.in(file("secp256k1jni"))
|
||||
.settings(commonSettings: _*)
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.settings(
|
||||
libraryDependencies ++= Deps.secp256k1jni,
|
||||
// we place lib files in this directory
|
||||
|
@ -280,16 +184,9 @@ lazy val secp256k1jni = project
|
|||
*/
|
||||
val testAndCompile = "compile->compile;test->test"
|
||||
|
||||
lazy val core = project
|
||||
.in(file("core"))
|
||||
.settings(commonProdSettings: _*)
|
||||
.dependsOn(
|
||||
secp256k1jni
|
||||
)
|
||||
|
||||
lazy val coreTest = project
|
||||
.in(file("core-test"))
|
||||
.settings(commonTestSettings: _*)
|
||||
.settings(CommonSettings.testSettings: _*)
|
||||
.settings(
|
||||
name := "bitcoin-s-core-test"
|
||||
)
|
||||
|
@ -300,7 +197,7 @@ lazy val coreTest = project
|
|||
|
||||
lazy val walletServer = project
|
||||
.in(file("app/server"))
|
||||
.settings(commonSettings: _*)
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.dependsOn(
|
||||
picklers,
|
||||
node,
|
||||
|
@ -311,7 +208,7 @@ lazy val walletServer = project
|
|||
|
||||
lazy val walletServerTest = project
|
||||
.in(file("app/server-test"))
|
||||
.settings(commonTestSettings)
|
||||
.settings(CommonSettings.testSettings)
|
||||
.dependsOn(
|
||||
walletServer,
|
||||
testkit
|
||||
|
@ -321,19 +218,19 @@ lazy val walletServerTest = project
|
|||
// and CLI
|
||||
lazy val picklers = project
|
||||
.in(file("app/picklers"))
|
||||
.settings(commonSettings: _*)
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.dependsOn(core % testAndCompile)
|
||||
|
||||
lazy val cli = project
|
||||
.in(file("app/cli"))
|
||||
.settings(commonSettings: _*)
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.dependsOn(
|
||||
picklers
|
||||
)
|
||||
|
||||
lazy val cliTest = project
|
||||
.in(file("app/cli-test"))
|
||||
.settings(commonTestSettings: _*)
|
||||
.settings(CommonSettings.testSettings: _*)
|
||||
.dependsOn(
|
||||
cli,
|
||||
testkit
|
||||
|
@ -342,7 +239,7 @@ lazy val cliTest = project
|
|||
lazy val chainDbSettings = dbFlywaySettings("chaindb")
|
||||
lazy val chain = project
|
||||
.in(file("chain"))
|
||||
.settings(commonProdSettings: _*)
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.settings(chainDbSettings: _*)
|
||||
.settings(
|
||||
name := "bitcoin-s-chain",
|
||||
|
@ -353,7 +250,7 @@ lazy val chain = project
|
|||
|
||||
lazy val chainTest = project
|
||||
.in(file("chain-test"))
|
||||
.settings(commonTestWithDbSettings: _*)
|
||||
.settings(CommonSettings.testWithDbSettings: _*)
|
||||
.settings(chainDbSettings: _*)
|
||||
.settings(
|
||||
name := "bitcoin-s-chain-test",
|
||||
|
@ -364,7 +261,7 @@ lazy val chainTest = project
|
|||
|
||||
lazy val dbCommons = project
|
||||
.in(file("db-commons"))
|
||||
.settings(commonSettings: _*)
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.settings(
|
||||
name := "bitcoin-s-db-commons",
|
||||
libraryDependencies ++= Deps.dbCommons
|
||||
|
@ -373,24 +270,20 @@ lazy val dbCommons = project
|
|||
|
||||
lazy val zmq = project
|
||||
.in(file("zmq"))
|
||||
.settings(commonSettings: _*)
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.settings(name := "bitcoin-s-zmq", libraryDependencies ++= Deps.bitcoindZmq)
|
||||
.dependsOn(
|
||||
core % testAndCompile
|
||||
)
|
||||
|
||||
lazy val bitcoindRpc = project
|
||||
.in(file("bitcoind-rpc"))
|
||||
.settings(commonProdSettings: _*)
|
||||
|
||||
lazy val bitcoindRpcTest = project
|
||||
.in(file("bitcoind-rpc-test"))
|
||||
.settings(commonTestSettings: _*)
|
||||
.settings(CommonSettings.testSettings: _*)
|
||||
.dependsOn(core % testAndCompile, testkit)
|
||||
|
||||
lazy val bench = project
|
||||
.in(file("bench"))
|
||||
.settings(commonSettings: _*)
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.settings(
|
||||
libraryDependencies ++= Deps.bench,
|
||||
name := "bitcoin-s-bench",
|
||||
|
@ -398,13 +291,9 @@ lazy val bench = project
|
|||
)
|
||||
.dependsOn(core % testAndCompile)
|
||||
|
||||
lazy val eclairRpc = project
|
||||
.in(file("eclair-rpc"))
|
||||
.settings(commonProdSettings: _*)
|
||||
|
||||
lazy val eclairRpcTest = project
|
||||
.in(file("eclair-rpc-test"))
|
||||
.settings(commonTestSettings: _*)
|
||||
.settings(CommonSettings.testSettings: _*)
|
||||
.settings(libraryDependencies ++= Deps.eclairRpcTest,
|
||||
name := "bitcoin-s-eclair-rpc-test")
|
||||
.dependsOn(core % testAndCompile, testkit)
|
||||
|
@ -413,7 +302,7 @@ lazy val nodeDbSettings = dbFlywaySettings("nodedb")
|
|||
lazy val node =
|
||||
project
|
||||
.in(file("node"))
|
||||
.settings(commonSettings: _*)
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.settings(nodeDbSettings: _*)
|
||||
.settings(
|
||||
name := "bitcoin-s-node",
|
||||
|
@ -430,7 +319,7 @@ lazy val node =
|
|||
lazy val nodeTest =
|
||||
project
|
||||
.in(file("node-test"))
|
||||
.settings(commonTestWithDbSettings: _*)
|
||||
.settings(CommonSettings.testWithDbSettings: _*)
|
||||
.settings(nodeDbSettings: _*)
|
||||
.settings(
|
||||
name := "bitcoin-s-node-test",
|
||||
|
@ -452,7 +341,7 @@ lazy val nodeTest =
|
|||
|
||||
lazy val testkit = project
|
||||
.in(file("testkit"))
|
||||
.settings(commonSettings: _*)
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.dependsOn(
|
||||
core % testAndCompile,
|
||||
walletServer,
|
||||
|
@ -466,7 +355,7 @@ lazy val testkit = project
|
|||
|
||||
lazy val docs = project
|
||||
.in(file("bitcoin-s-docs")) // important: it must not be docs/
|
||||
.settings(commonTestSettings: _*)
|
||||
.settings(CommonSettings.testSettings: _*)
|
||||
.dependsOn(
|
||||
bitcoindRpc,
|
||||
core,
|
||||
|
@ -479,7 +368,7 @@ lazy val docs = project
|
|||
lazy val walletDbSettings = dbFlywaySettings("walletdb")
|
||||
lazy val wallet = project
|
||||
.in(file("wallet"))
|
||||
.settings(commonProdSettings: _*)
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.settings(walletDbSettings: _*)
|
||||
.settings(
|
||||
name := "bitcoin-s-wallet",
|
||||
|
@ -490,7 +379,7 @@ lazy val wallet = project
|
|||
|
||||
lazy val walletTest = project
|
||||
.in(file("wallet-test"))
|
||||
.settings(commonTestWithDbSettings: _*)
|
||||
.settings(CommonSettings.testWithDbSettings: _*)
|
||||
.settings(walletDbSettings: _*)
|
||||
.settings(
|
||||
name := "bitcoin-s-wallet-test",
|
||||
|
|
|
@ -6,6 +6,10 @@ testOptions in Test += Tests.Argument(TestFrameworks.ScalaCheck,
|
|||
"-verbosity",
|
||||
"2")
|
||||
|
||||
CommonSettings.prodSettings
|
||||
|
||||
dependsOn(Projects.secp256k1jni)
|
||||
|
||||
coverageMinimum := 90
|
||||
|
||||
coverageFailOnMinimum := true
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
lazy val downloadEclair = taskKey[Unit] {
|
||||
"Download Eclair binaries, extract ./binaries/eclair"
|
||||
}
|
||||
Test / test := (Test / test dependsOn {
|
||||
Projects.eclairRpc / TaskKeys.downloadEclair
|
||||
}).value
|
||||
|
||||
import java.nio.file.Paths
|
||||
lazy val eclairRpc = project in Paths.get("..", "eclair-rpc").toFile
|
||||
|
||||
Test / test := (Test / test dependsOn eclairRpc / downloadEclair).value
|
||||
Test / test := (Test / test dependsOn {
|
||||
Projects.bitcoindRpc / TaskKeys.downloadBitcoind
|
||||
}).value
|
||||
|
|
|
@ -4,16 +4,11 @@ name := "bitcoin-s-eclair-rpc"
|
|||
|
||||
libraryDependencies ++= Deps.eclairRpc
|
||||
|
||||
dependsOn {
|
||||
lazy val bitcoindRpc = project in Paths.get("..", "bitcoind-rpc").toFile
|
||||
bitcoindRpc
|
||||
}
|
||||
dependsOn(Projects.bitcoindRpc)
|
||||
|
||||
lazy val downloadEclair = taskKey[Unit] {
|
||||
"Download Eclair binaries, extract ./binaries/eclair"
|
||||
}
|
||||
CommonSettings.prodSettings
|
||||
|
||||
downloadEclair := {
|
||||
TaskKeys.downloadEclair := {
|
||||
val logger = streams.value.log
|
||||
import scala.sys.process._
|
||||
|
||||
|
|
109
project/CommonSettings.scala
Normal file
109
project/CommonSettings.scala
Normal file
|
@ -0,0 +1,109 @@
|
|||
// these two imports are needed for sbt syntax to work
|
||||
import sbt._
|
||||
import sbt.Keys._
|
||||
|
||||
import scala.util.Properties
|
||||
|
||||
object CommonSettings {
|
||||
private val isCI = {
|
||||
sys.props
|
||||
.get("CI")
|
||||
.isDefined
|
||||
}
|
||||
|
||||
lazy val settings: Seq[Setting[_]] = List(
|
||||
organization := "org.bitcoin-s",
|
||||
homepage := Some(url("https://bitcoin-s.org")),
|
||||
developers := List(
|
||||
Developer(
|
||||
"christewart",
|
||||
"Chris Stewart",
|
||||
"stewart.chris1234@gmail.com",
|
||||
url("https://twitter.com/Chris_Stewart_5")
|
||||
)
|
||||
),
|
||||
////
|
||||
// scaladoc settings
|
||||
Compile / doc / scalacOptions ++= List(
|
||||
"-doc-title",
|
||||
"Bitcoin-S",
|
||||
"-doc-version",
|
||||
version.value
|
||||
),
|
||||
// Set apiURL to define the base URL for the Scaladocs for our library.
|
||||
// This will enable clients of our library to automatically link against
|
||||
// the API documentation using autoAPIMappings.
|
||||
apiURL := homepage.value.map(_.toString + "/api").map(url(_)),
|
||||
// scaladoc settings end
|
||||
////
|
||||
scalacOptions in Compile := compilerOpts(scalaVersion.value),
|
||||
scalacOptions in Test := testCompilerOpts,
|
||||
Compile / compile / javacOptions ++= {
|
||||
if (isCI) {
|
||||
//jdk11 is used on CI, we need to use the --release flag to make sure
|
||||
//byte code is compatible with jdk 8
|
||||
//https://github.com/eclipse/jetty.project/issues/3244#issuecomment-495322586
|
||||
Seq("--release", "8")
|
||||
} else {
|
||||
Seq("-source", "1.8", "-target", "1.8")
|
||||
}
|
||||
},
|
||||
//show full stack trace of failed tests
|
||||
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oF"),
|
||||
//show duration of tests
|
||||
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oD"),
|
||||
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
|
||||
// Travis has performance issues on macOS
|
||||
Test / parallelExecution := !(Properties.isMac && isCI)
|
||||
)
|
||||
|
||||
private val commonCompilerOpts = {
|
||||
List(
|
||||
"-Xsource:2.12",
|
||||
"-target:jvm-1.8"
|
||||
)
|
||||
}
|
||||
|
||||
private val scala2_13CompilerOpts = Seq("-Xlint:unused")
|
||||
|
||||
private val nonScala2_13CompilerOpts = Seq(
|
||||
"-Xmax-classfile-name",
|
||||
"128",
|
||||
"-Ywarn-unused",
|
||||
"-Ywarn-unused-import"
|
||||
)
|
||||
|
||||
//https://docs.scala-lang.org/overviews/compiler-options/index.html
|
||||
def compilerOpts(scalaVersion: String): Seq[String] =
|
||||
Seq(
|
||||
"-encoding",
|
||||
"UTF-8",
|
||||
"-unchecked",
|
||||
"-feature",
|
||||
"-deprecation",
|
||||
"-Ywarn-dead-code",
|
||||
"-Ywarn-value-discard",
|
||||
"-Ywarn-unused",
|
||||
"-unchecked",
|
||||
"-deprecation",
|
||||
"-feature"
|
||||
) ++ commonCompilerOpts ++ {
|
||||
if (scalaVersion.startsWith("2.13")) scala2_13CompilerOpts
|
||||
else nonScala2_13CompilerOpts
|
||||
}
|
||||
|
||||
val testCompilerOpts: Seq[String] = commonCompilerOpts
|
||||
|
||||
lazy val testSettings: Seq[Setting[_]] = Seq(
|
||||
publish / skip := true
|
||||
) ++ settings
|
||||
|
||||
lazy val testWithDbSettings: Seq[Setting[_]] = Seq(
|
||||
// To make in-memory DBs work properly
|
||||
Test / fork := true,
|
||||
// To avoid deadlock issues with SQLite
|
||||
Test / parallelExecution := false
|
||||
) ++ testSettings
|
||||
|
||||
lazy val prodSettings: Seq[Setting[_]] = settings
|
||||
}
|
9
project/Projects.scala
Normal file
9
project/Projects.scala
Normal file
|
@ -0,0 +1,9 @@
|
|||
import sbt._
|
||||
import java.nio.file.Paths
|
||||
|
||||
object Projects {
|
||||
val core = project in file("..") / "core"
|
||||
val eclairRpc = project in file("..") / "eclair-rpc"
|
||||
val bitcoindRpc = project in file("..") / "bitcoind-rpc"
|
||||
val secp256k1jni = project in file("..") / "secp256k1jni "
|
||||
}
|
11
project/TaskKeys.scala
Normal file
11
project/TaskKeys.scala
Normal file
|
@ -0,0 +1,11 @@
|
|||
import sbt._
|
||||
|
||||
object TaskKeys {
|
||||
lazy val downloadBitcoind = taskKey[Unit] {
|
||||
"Download bitcoind binaries, extract to ./binaries/bitcoind"
|
||||
}
|
||||
|
||||
lazy val downloadEclair = taskKey[Unit] {
|
||||
"Download Eclair binaries, extract ./binaries/eclair"
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue