2019-08-30 22:11:52 +02:00
|
|
|
// these two imports are needed for sbt syntax to work
|
2021-02-18 13:57:18 -06:00
|
|
|
import com.typesafe.sbt.SbtNativePackager.Docker
|
|
|
|
import com.typesafe.sbt.SbtNativePackager.autoImport.packageName
|
2020-02-17 12:07:04 -06:00
|
|
|
|
2021-02-18 13:57:18 -06:00
|
|
|
import java.nio.file.Paths
|
2021-02-26 07:35:20 -06:00
|
|
|
import com.typesafe.sbt.packager.Keys.{
|
|
|
|
daemonUser,
|
|
|
|
daemonUserUid,
|
2021-03-03 13:58:04 -06:00
|
|
|
dockerAlias,
|
|
|
|
dockerAliases,
|
2021-02-26 07:35:20 -06:00
|
|
|
dockerRepository,
|
2021-03-03 13:58:04 -06:00
|
|
|
dockerUpdateLatest,
|
2021-02-26 07:35:20 -06:00
|
|
|
maintainer
|
|
|
|
}
|
2021-02-18 13:57:18 -06:00
|
|
|
import com.typesafe.sbt.packager.docker.DockerPlugin.autoImport.dockerBaseImage
|
2019-08-30 22:11:52 +02:00
|
|
|
import sbt._
|
|
|
|
import sbt.Keys._
|
|
|
|
|
|
|
|
import scala.util.Properties
|
|
|
|
|
|
|
|
object CommonSettings {
|
2020-08-20 12:33:18 -07:00
|
|
|
|
Implement caching of bitcoind in the walletTest,nodeTest, and partially bitcoindRpcTest project (#2792)
* Create CachedBitcoind, implement it in FundTransactionHandlingTest
* Add BaseWalletTest, extend it with BitcoinSWalletTest & BitcoinSWalletTestCachedBitcoind, add CachedBitcoinV19 and use it RescanHandlingTest
* Make ProcessBlockTest work with cached bitcoind
* Make trait for CachedBitcoindNewest for the newest version of bitcoind
* Make UTXOLifeCycleTest use cached bitcoind
* Add WalletBloom, WalletSyncTest to use cached bitcoinds
* Add WalletIntegrationTest
* Rework beforeAll() and afterAll() into the super trait like BaseWalletTest
* Add standlone BitcoindFixtures, use it in BitcoindBackendTest
* Use new BitcoindFixtures in BitcoindBlockPollingTest
* Introduce BaseNodeTest, start implementing the usage of cached bitcoinds in the nodeTest project
* Use cached bitcoind's with SpvNodeTest & SpvNodeWithWalletTest
* Fix bug on postgres with reusing database, upsert the genesis header rather than create it
* Get NeutrinoNode tests workign with cached bitcoinds
* Fix NeutrinoNodeWithWallet by destroying wallet state for Postgres
* Add teardown helper method for bitcoind
* Teardown chain project when using node fixtures since node is dependent upon the chain project.
* Turn off parallelExecution again
* Switch the parallelExecution flag to only be set on CI, so we can get better performance when running locally
* Start implementing BitcoindFixtures, use BitcoindFixturesCachedTriple on TestUtilRpcTest
* Fix compiler errors, begin implementing NodePair
* Refactor TestRpcUtilTest to use 2 bitcoinds rather than 2
* Reduce the number of bitcoinds that MultiWalletRpcTest needs from 3 -> 1
* Reduce number of bitcoinds used in WalletRpcTest from 3 -> 2
* Add some documentation
* Try to re-add parallelExecution
* Reduce the number of bitcoinds used in PsbtRpcTest from 3 -> 2
* Disable parallelExecution in Test again
* Make BitcoindV21RpcClientTest & BitcoindV20RpcClientTest reduce bitcoind usage from 2 -> 1
* Make BitcoindV19RpcClienttest reduce bitcoind usage from 2 -> 1
* Rework MempoolRpcTest to use fixtures, add BitcoindVersion to CachedBitcoindCollection
* Make sure clientAccumm has to be specified as a paramter now rather than filling in by default
* Begin parameterizing NodePair/NodeTriple to retain type information for the specific version of bitcoind that was used
* Don't implement version in super trait
* Fix docs
* Fix async issue in V21 test suite
* Append to vectors in CachedBitcoinCollection rather than replace
* Fix rebase issues
* Add scaladocs
* Fix BitcoindV18RpcClient address info test
* Implement fixtures in BitcoindV17RpcClientTest fixtures
* Cleanup v17 PsbtRpcTest
* Reduce bitcoind usage from 3 -> 1 in BitcoindV18RpcClientTest
* Remove abandon transaction test, this allows us to reduce the number of bitcoind's used in MempoolRpcTest from 3 -> 2
* Remove the requirement to inject BitcoinSAsyncFixtureTest, add it in the test traits explicitly to make things easier. Also add explicit afterAll() method to tear down both the CachedBitcoind & BitcoinSAsyncFixtureTest
* Fix missing Await.result() in BitcoindRpcTest.afterAll()
* Rework MultiWalletRpcTest to use a NodePair
* Rework BlockchainRpcTest to use fixtures
* Rework Client start()/stop() methods. Now use an AtomicBoolean to indicate when a user has requested a client to start/stop rather than sending pings to bitcoind that can fail because the conneciton pool has been shutdown in test cases
* Try my luck with turning on parallelExecution in CI again
* Revert parallelExecution, now testes do not run in parallel on CI
* Only turn off parallelExecution for bitcoindRpcTest
* Adjust build to only have bitcoindRpcTest NOT in run parallel on mac, reduce number of blocks used in BitcoindRpcTestUtil.createNodeSequence
* Run less tests in the rpc test suite as that takes the longest, move them over to node/wallet/dlc test suite on mac osx CI
* Don't run eclair tests in parallel either
* Remove CachedBitcoind from BitcoinSWalletTest
* Fix async bug in test case
* Push to github to force re-run of CI
* Push to github to force re-run of CI
* Push to github to force re-run of CI
2021-03-19 06:37:53 -05:00
|
|
|
private def isCI = {
|
|
|
|
Properties
|
|
|
|
.envOrNone("CI")
|
2019-08-30 22:11:52 +02:00
|
|
|
.isDefined
|
|
|
|
}
|
|
|
|
|
2021-03-02 07:05:21 -06:00
|
|
|
lazy val settings: Seq[Setting[_]] = Vector(
|
2019-08-30 22:11:52 +02:00
|
|
|
organization := "org.bitcoin-s",
|
|
|
|
homepage := Some(url("https://bitcoin-s.org")),
|
2020-09-23 17:02:40 -05:00
|
|
|
maintainer := "Chris Stewart <stewart.chris1234@gmail.com>",
|
2019-08-30 22:11:52 +02:00
|
|
|
developers := List(
|
|
|
|
Developer(
|
|
|
|
"christewart",
|
|
|
|
"Chris Stewart",
|
|
|
|
"stewart.chris1234@gmail.com",
|
|
|
|
url("https://twitter.com/Chris_Stewart_5")
|
|
|
|
)
|
|
|
|
),
|
2021-03-03 16:52:03 -06:00
|
|
|
scalacOptions in Compile ++= compilerOpts(scalaVersion =
|
|
|
|
scalaVersion.value),
|
|
|
|
Test / scalacOptions ++= testCompilerOpts(scalaVersion =
|
|
|
|
scalaVersion.value),
|
2019-10-03 09:46:43 -05:00
|
|
|
//remove annoying import unused things in the scala console
|
|
|
|
//https://stackoverflow.com/questions/26940253/in-sbt-how-do-you-override-scalacoptions-for-console-in-all-configurations
|
|
|
|
scalacOptions in (Compile, console) ~= (_ filterNot (s =>
|
2020-08-19 09:17:39 -05:00
|
|
|
s == "-Ywarn-unused-import"
|
2020-08-20 12:33:18 -07:00
|
|
|
|| s == "-Ywarn-unused"
|
|
|
|
|| s == "-Xfatal-warnings"
|
2021-02-18 13:57:18 -06:00
|
|
|
//for 2.13 -- they use different compiler opts
|
2020-08-19 09:17:39 -05:00
|
|
|
|| s == "-Xlint:unused")),
|
2020-05-29 07:03:18 -05:00
|
|
|
//we don't want -Xfatal-warnings for publishing with publish/publishLocal either
|
2020-08-20 12:33:18 -07:00
|
|
|
scalacOptions in (Compile, doc) ~= (_ filterNot (s =>
|
2020-05-29 07:03:18 -05:00
|
|
|
s == "-Xfatal-warnings")),
|
2021-03-03 16:52:03 -06:00
|
|
|
scalacOptions in (Test, console) ++= (scalacOptions in (Compile, console)).value,
|
|
|
|
scalacOptions in Test ++= testCompilerOpts(scalaVersion.value),
|
2021-03-02 07:05:21 -06:00
|
|
|
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))
|
|
|
|
)
|
|
|
|
|
|
|
|
lazy val jvmSettings: Seq[Setting[_]] = List(
|
|
|
|
////
|
|
|
|
// 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
|
|
|
|
////
|
2019-08-30 22:11:52 +02:00
|
|
|
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")
|
|
|
|
}
|
2021-03-02 07:05:21 -06:00
|
|
|
}
|
2019-08-30 22:11:52 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
private val commonCompilerOpts = {
|
|
|
|
List(
|
2020-04-23 07:38:20 -05:00
|
|
|
"-Xsource:2.13",
|
2019-08-30 22:11:52 +02:00
|
|
|
"-target:jvm-1.8"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-01-03 08:01:26 -06:00
|
|
|
/** Linting options for scalac */
|
|
|
|
private val scala2_13CompilerLinting = {
|
|
|
|
Seq(
|
|
|
|
"-Xlint:unused",
|
|
|
|
"-Xlint:adapted-args",
|
|
|
|
"-Xlint:nullary-unit",
|
|
|
|
"-Xlint:inaccessible",
|
|
|
|
"-Xlint:infer-any",
|
|
|
|
"-Xlint:missing-interpolator",
|
|
|
|
"-Xlint:eta-sam"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Compiler options for source code */
|
|
|
|
private val scala2_13SourceCompilerOpts = {
|
|
|
|
Seq("-Xfatal-warnings") ++ scala2_13CompilerLinting
|
|
|
|
}
|
2019-08-30 22:11:52 +02:00
|
|
|
|
|
|
|
private val nonScala2_13CompilerOpts = Seq(
|
|
|
|
"-Xmax-classfile-name",
|
2020-08-19 09:17:39 -05:00
|
|
|
"128",
|
|
|
|
"-Ywarn-unused",
|
|
|
|
"-Ywarn-unused-import"
|
2019-08-30 22:11:52 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
//https://docs.scala-lang.org/overviews/compiler-options/index.html
|
2021-01-03 08:01:26 -06:00
|
|
|
def compilerOpts(scalaVersion: String): Seq[String] = {
|
2019-08-30 22:11:52 +02:00
|
|
|
Seq(
|
|
|
|
"-unchecked",
|
|
|
|
"-feature",
|
|
|
|
"-deprecation",
|
2020-08-19 09:17:39 -05:00
|
|
|
"-Ywarn-dead-code",
|
|
|
|
"-Ywarn-value-discard",
|
|
|
|
"-Ywarn-unused",
|
|
|
|
"-unchecked",
|
|
|
|
"-deprecation",
|
2020-11-28 07:36:07 -06:00
|
|
|
"-feature",
|
|
|
|
"-Ypatmat-exhaust-depth",
|
|
|
|
"off"
|
2019-08-30 22:11:52 +02:00
|
|
|
) ++ commonCompilerOpts ++ {
|
2021-01-03 08:01:26 -06:00
|
|
|
if (scalaVersion.startsWith("2.13")) {
|
|
|
|
scala2_13SourceCompilerOpts
|
|
|
|
} else nonScala2_13CompilerOpts
|
2019-08-30 22:11:52 +02:00
|
|
|
}
|
2021-01-03 08:01:26 -06:00
|
|
|
}
|
2019-08-30 22:11:52 +02:00
|
|
|
|
2020-12-20 07:09:07 -06:00
|
|
|
def testCompilerOpts(scalaVersion: String): Seq[String] = {
|
2021-01-05 05:57:56 -06:00
|
|
|
(commonCompilerOpts ++
|
2020-12-20 07:09:07 -06:00
|
|
|
//initialization checks: https://docs.scala-lang.org/tutorials/FAQ/initialization-order.html
|
|
|
|
Vector("-Xcheckinit") ++
|
2021-01-05 05:57:56 -06:00
|
|
|
compilerOpts(scalaVersion))
|
|
|
|
.filterNot(_ == "-Xfatal-warnings")
|
2020-12-20 07:09:07 -06:00
|
|
|
}
|
2019-08-30 22:11:52 +02:00
|
|
|
|
|
|
|
lazy val testSettings: Seq[Setting[_]] = Seq(
|
2020-02-23 10:22:28 -06:00
|
|
|
//show full stack trace (-oF) of failed tests and duration of tests (-oD)
|
|
|
|
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF"),
|
|
|
|
logBuffered in Test := false,
|
Implement caching of bitcoind in the walletTest,nodeTest, and partially bitcoindRpcTest project (#2792)
* Create CachedBitcoind, implement it in FundTransactionHandlingTest
* Add BaseWalletTest, extend it with BitcoinSWalletTest & BitcoinSWalletTestCachedBitcoind, add CachedBitcoinV19 and use it RescanHandlingTest
* Make ProcessBlockTest work with cached bitcoind
* Make trait for CachedBitcoindNewest for the newest version of bitcoind
* Make UTXOLifeCycleTest use cached bitcoind
* Add WalletBloom, WalletSyncTest to use cached bitcoinds
* Add WalletIntegrationTest
* Rework beforeAll() and afterAll() into the super trait like BaseWalletTest
* Add standlone BitcoindFixtures, use it in BitcoindBackendTest
* Use new BitcoindFixtures in BitcoindBlockPollingTest
* Introduce BaseNodeTest, start implementing the usage of cached bitcoinds in the nodeTest project
* Use cached bitcoind's with SpvNodeTest & SpvNodeWithWalletTest
* Fix bug on postgres with reusing database, upsert the genesis header rather than create it
* Get NeutrinoNode tests workign with cached bitcoinds
* Fix NeutrinoNodeWithWallet by destroying wallet state for Postgres
* Add teardown helper method for bitcoind
* Teardown chain project when using node fixtures since node is dependent upon the chain project.
* Turn off parallelExecution again
* Switch the parallelExecution flag to only be set on CI, so we can get better performance when running locally
* Start implementing BitcoindFixtures, use BitcoindFixturesCachedTriple on TestUtilRpcTest
* Fix compiler errors, begin implementing NodePair
* Refactor TestRpcUtilTest to use 2 bitcoinds rather than 2
* Reduce the number of bitcoinds that MultiWalletRpcTest needs from 3 -> 1
* Reduce number of bitcoinds used in WalletRpcTest from 3 -> 2
* Add some documentation
* Try to re-add parallelExecution
* Reduce the number of bitcoinds used in PsbtRpcTest from 3 -> 2
* Disable parallelExecution in Test again
* Make BitcoindV21RpcClientTest & BitcoindV20RpcClientTest reduce bitcoind usage from 2 -> 1
* Make BitcoindV19RpcClienttest reduce bitcoind usage from 2 -> 1
* Rework MempoolRpcTest to use fixtures, add BitcoindVersion to CachedBitcoindCollection
* Make sure clientAccumm has to be specified as a paramter now rather than filling in by default
* Begin parameterizing NodePair/NodeTriple to retain type information for the specific version of bitcoind that was used
* Don't implement version in super trait
* Fix docs
* Fix async issue in V21 test suite
* Append to vectors in CachedBitcoinCollection rather than replace
* Fix rebase issues
* Add scaladocs
* Fix BitcoindV18RpcClient address info test
* Implement fixtures in BitcoindV17RpcClientTest fixtures
* Cleanup v17 PsbtRpcTest
* Reduce bitcoind usage from 3 -> 1 in BitcoindV18RpcClientTest
* Remove abandon transaction test, this allows us to reduce the number of bitcoind's used in MempoolRpcTest from 3 -> 2
* Remove the requirement to inject BitcoinSAsyncFixtureTest, add it in the test traits explicitly to make things easier. Also add explicit afterAll() method to tear down both the CachedBitcoind & BitcoinSAsyncFixtureTest
* Fix missing Await.result() in BitcoindRpcTest.afterAll()
* Rework MultiWalletRpcTest to use a NodePair
* Rework BlockchainRpcTest to use fixtures
* Rework Client start()/stop() methods. Now use an AtomicBoolean to indicate when a user has requested a client to start/stop rather than sending pings to bitcoind that can fail because the conneciton pool has been shutdown in test cases
* Try my luck with turning on parallelExecution in CI again
* Revert parallelExecution, now testes do not run in parallel on CI
* Only turn off parallelExecution for bitcoindRpcTest
* Adjust build to only have bitcoindRpcTest NOT in run parallel on mac, reduce number of blocks used in BitcoindRpcTestUtil.createNodeSequence
* Run less tests in the rpc test suite as that takes the longest, move them over to node/wallet/dlc test suite on mac osx CI
* Don't run eclair tests in parallel either
* Remove CachedBitcoind from BitcoinSWalletTest
* Fix async bug in test case
* Push to github to force re-run of CI
* Push to github to force re-run of CI
* Push to github to force re-run of CI
2021-03-19 06:37:53 -05:00
|
|
|
skip.in(publish) := true
|
2019-08-30 22:11:52 +02:00
|
|
|
) ++ settings
|
|
|
|
|
|
|
|
lazy val prodSettings: Seq[Setting[_]] = settings
|
2020-02-17 12:07:04 -06:00
|
|
|
|
2021-02-18 13:57:18 -06:00
|
|
|
lazy val appSettings: Seq[Setting[_]] = prodSettings ++ Vector(
|
|
|
|
//gives us the 'universal' directory in build artifacts
|
|
|
|
Compile / unmanagedResourceDirectories += baseDirectory.value / "src" / "universal"
|
|
|
|
)
|
|
|
|
|
|
|
|
lazy val dockerSettings: Seq[Setting[_]] = {
|
|
|
|
Vector(
|
|
|
|
//https://sbt-native-packager.readthedocs.io/en/latest/formats/docker.html
|
2021-03-15 15:33:17 -05:00
|
|
|
dockerBaseImage := "openjdk:15.0.2-jdk-buster",
|
2021-02-19 10:09:40 -06:00
|
|
|
dockerRepository := Some("bitcoinscala"),
|
2021-02-26 07:35:20 -06:00
|
|
|
//set the user to be 'bitcoin-s' rather than
|
|
|
|
//the default provided by sbt native packager
|
|
|
|
//which is 'demiourgos728'
|
|
|
|
daemonUser in Docker := "bitcoin-s",
|
2021-02-18 13:57:18 -06:00
|
|
|
packageName in Docker := packageName.value,
|
2021-03-03 13:58:04 -06:00
|
|
|
version in Docker := version.value,
|
|
|
|
dockerUpdateLatest := isSnapshot.value
|
2021-02-18 13:57:18 -06:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-08-20 12:33:18 -07:00
|
|
|
lazy val binariesPath =
|
|
|
|
Paths.get(Properties.userHome, ".bitcoin-s", "binaries")
|
2019-08-30 22:11:52 +02:00
|
|
|
}
|