Skip to content

Commit fc7b42c

Browse files
committed
prepare PR
1 parent 1863107 commit fc7b42c

File tree

9 files changed

+178
-128
lines changed

9 files changed

+178
-128
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ jobs:
3838
java-version: '8'
3939
distribution: 'temurin'
4040
# cache: 'sbt'
41+
- name: Setup sbt launcher
42+
uses: sbt/setup-sbt@v1
4143
- name: Run tests & Coverage Report
4244
run: sbt coverage test coverageReport
4345
- name: Upload coverage to Codecov
4446
uses: codecov/codecov-action@v3
4547
with:
46-
files: common/target/scala-2.12/coverage-report/cobertura.xml,core/target/scala-2.12/coverage-report/cobertura.xml,teskit/target/scala-2.12/coverage-report/cobertura.xml
48+
files: common/target/scala-2.12/coverage-report/cobertura.xml,common/testkit/target/scala-2.12/coverage-report/cobertura.xml,core/target/scala-2.12/coverage-report/cobertura.xml,core/teskit/target/scala-2.12/coverage-report/cobertura.xml,jdbc/target/scala-2.12/coverage-report/cobertura.xml,jdbc/teskit/target/scala-2.12/coverage-report/cobertura.xml,counter/target/scala-2.12/coverage-report/cobertura.xml,kv/target/scala-2.12/coverage-report/cobertura.xml,kv/target/scala-2.12/coverage-report/cobertura.xml,session/testkit/target/scala-2.12/coverage-report/cobertura.xml
4749
flags: unittests
4850
fail_ci_if_error: true
4951
verbose: true
@@ -59,5 +61,7 @@ jobs:
5961
java-version: '8'
6062
distribution: 'temurin'
6163
# cache: 'sbt'
64+
- name: Setup sbt launcher
65+
uses: sbt/setup-sbt@v1
6266
- name: Formatting
63-
run: sbt scalafmtSbtCheck scalafmtCheck test:scalafmtCheck
67+
run: sbt scalafmtSbtCheck scalafmtCheck Test/scalafmtCheck

.github/workflows/release.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,19 @@ jobs:
3535
java-version: '8'
3636
distribution: 'temurin'
3737
# cache: 'sbt'
38+
- name: Setup sbt launcher
39+
uses: sbt/setup-sbt@v1
3840
- name: Run tests & Coverage Report
3941
run: sbt coverage test coverageReport coverageAggregate
4042
- name: Upload coverage to Codecov
4143
uses: codecov/codecov-action@v3
4244
with:
43-
files: common/target/scala-2.12/coverage-report/cobertura.xml,common/testkit/target/scala-2.12/coverage-report/cobertura.xml,core/target/scala-2.12/coverage-report/cobertura.xml,core/teskit/target/scala-2.12/coverage-report/cobertura.xml,jdbc/target/scala-2.12/coverage-report/cobertura.xml,jdbc/teskit/target/scala-2.12/coverage-report/cobertura.xml,elastic/target/scala-2.12/coverage-report/cobertura.xml,elastic/teskit/target/scala-2.12/coverage-report/cobertura.xml,counter/target/scala-2.12/coverage-report/cobertura.xml,server/testkit/target/scala-2.12/coverage-report/cobertura.xml,session/testkit/target/scala-2.12/coverage-report/cobertura.xml
45+
files: common/target/scala-2.12/coverage-report/cobertura.xml,common/testkit/target/scala-2.12/coverage-report/cobertura.xml,core/target/scala-2.12/coverage-report/cobertura.xml,core/teskit/target/scala-2.12/coverage-report/cobertura.xml,jdbc/target/scala-2.12/coverage-report/cobertura.xml,jdbc/teskit/target/scala-2.12/coverage-report/cobertura.xml,counter/target/scala-2.12/coverage-report/cobertura.xml,kv/target/scala-2.12/coverage-report/cobertura.xml,kv/target/scala-2.12/coverage-report/cobertura.xml,session/testkit/target/scala-2.12/coverage-report/cobertura.xml
4446
flags: unittests
4547
fail_ci_if_error: false
4648
verbose: true
4749
- name: Publish
48-
run: sbt publish
50+
run: sbt + publish
4951

5052
lint:
5153
runs-on: ubuntu-latest
@@ -58,5 +60,7 @@ jobs:
5860
java-version: '8'
5961
distribution: 'temurin'
6062
# cache: 'sbt'
63+
- name: Setup sbt launcher
64+
uses: sbt/setup-sbt@v1
6165
- name: Formatting
62-
run: sbt scalafmtSbtCheck scalafmtCheck test:scalafmtCheck
66+
run: sbt scalafmtSbtCheck scalafmtCheck Test/scalafmtCheck

build.sbt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import app.softnetwork.*
22

3-
lazy val scala212 = "2.12.20"
4-
lazy val scala213 = "2.13.16"
5-
63
/////////////////////////////////
74
// Defaults
85
/////////////////////////////////
96

7+
lazy val scala212 = "2.12.20"
8+
lazy val scala213 = "2.13.16"
9+
lazy val javacCompilerVersion = "1.8"
10+
lazy val scalacCompilerOptions = Seq(
11+
"-deprecation",
12+
"-feature",
13+
s"-target:jvm-$javacCompilerVersion"
14+
)
15+
1016
ThisBuild / organization := "app.softnetwork"
1117

1218
name := "generic-persistence-api"
@@ -17,19 +23,19 @@ lazy val moduleSettings = Seq(
1723
crossScalaVersions := Seq(scala212, scala213),
1824
scalacOptions ++= {
1925
CrossVersion.partialVersion(scalaVersion.value) match {
20-
case Some((2, 12)) => Seq("-deprecation", "-feature", "-target:jvm-1.8", "-Ypartial-unification")
21-
case Some((2, 13)) => Seq("-deprecation", "-feature", "-target:jvm-1.8")
26+
case Some((2, 12)) => scalacCompilerOptions :+ "-Ypartial-unification"
27+
case Some((2, 13)) => scalacCompilerOptions
2228
case _ => Seq.empty
2329
}
2430
}
2531
)
2632

33+
ThisBuild / javacOptions ++= Seq("-source", javacCompilerVersion, "-target", javacCompilerVersion)
34+
2735
ThisBuild / scalaVersion := scala212
2836

2937
//ThisBuild / versionScheme := Some("early-semver")
3038

31-
ThisBuild / javacOptions ++= Seq("-source", "1.8", "-target", "1.8")
32-
3339
ThisBuild / resolvers ++= Seq(
3440
"Softnetwork Server" at "https://softnetwork.jfrog.io/artifactory/releases/",
3541
"Maven Central Server" at "https://repo1.maven.org/maven2",

common/testkit/src/main/scala/app/softnetwork/concurrent/scalatest/CompletionTestKit.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import scala.util.{Failure, Success, Try}
1212
import scala.language.reflectiveCalls
1313

1414
/** Created by smanciot on 12/04/2021.
15-
*/
16-
trait CompletionTestKit extends Completion with Assertions { _: { def log: Logger } =>
15+
*/
16+
trait CompletionTestKit extends Completion with Assertions {
17+
_: {def log: Logger} =>
1718

1819
implicit class AwaitAssertion[T](future: Future[T])(implicit atMost: Duration = defaultTimeout) {
1920
def assert(fun: T => Assertion): Assertion =
@@ -42,13 +43,14 @@ trait CompletionTestKit extends Completion with Assertions { _: { def log: Logge
4243
var done = false
4344

4445
while (tries <= maxTries && !done) {
45-
if (tries > 0) Thread.sleep(sleep * tries)
46-
tries = tries + 1
4746
try {
47+
tries = tries + 1
48+
log.info(s"Waiting for $explain, try $tries/$maxTries")
49+
Thread.sleep(sleep * tries)
4850
done = predicate()
4951
} catch {
5052
case e: Throwable =>
51-
log.warn(s"problem while testing predicate ${e.getMessage}")
53+
log.warn(s"problem while waiting for $explain: ${e.getMessage}")
5254
}
5355
}
5456

core/src/main/scala/app/softnetwork/persistence/package.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ import java.time.Instant
88
import scala.language.implicitConversions
99

1010
/** Created by smanciot on 13/04/2020.
11-
*/
11+
*/
1212
package object persistence {
1313

1414
trait ManifestWrapper[T] {
1515
protected case class ManifestW()(implicit val wrapped: Manifest[T])
16+
1617
protected val manifestWrapper: ManifestW
1718
}
1819

1920
def generateUUID(key: Option[String] = None): String =
2021
key match {
2122
case Some(clearText) => sha256(clearText)
22-
case _ => UUID.randomUUID().toString
23+
case _ => UUID.randomUUID().toString
2324
}
2425

2526
def now(): Date = Date.from(Instant.now())
@@ -29,8 +30,8 @@ package object persistence {
2930
}
3031

3132
/** Used for akka and elastic persistence ids, one per targeted environment (development,
32-
* production, ...)
33-
*/
33+
* production, ...)
34+
*/
3435
val version: String = sys.env.getOrElse("VERSION", PersistenceCoreBuildInfo.version)
3536

3637
val environment: String = sys.env.getOrElse(

core/testkit/src/main/scala/app/softnetwork/persistence/person/query/PersonToJsonProcessorStream.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import app.softnetwork.persistence.query.{InMemoryJournalProvider, InMemoryOffse
66
import java.nio.file.{Files, Paths}
77

88
trait PersonToJsonProcessorStream
9-
extends PersonToExternalProcessorStream
9+
extends PersonToExternalProcessorStream
1010
with InMemoryJournalProvider
1111
with InMemoryOffsetProvider
1212
with JsonProvider[Person] {

core/testkit/src/main/scala/app/softnetwork/persistence/scalatest/PersistenceTestKit.scala

Lines changed: 87 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import scala.language.implicitConversions
2323
import scala.reflect.ClassTag
2424

2525
/** Created by smanciot on 04/01/2020.
26-
*/
26+
*/
2727
trait PersistenceTestKit
28-
extends PersistenceGuardian
28+
extends PersistenceGuardian
2929
with BeforeAndAfterAll
3030
with Eventually
3131
with CompletionTestKit
@@ -61,91 +61,92 @@ trait PersistenceTestKit
6161
}
6262

6363
/** @return
64-
* roles associated with this node
65-
*/
64+
* roles associated with this node
65+
*/
6666
def roles: Seq[String] = Seq.empty
6767

68-
final lazy val akka: String = s"""
69-
|akka {
70-
| stdout-loglevel = off // defaults to WARNING can be disabled with off. The stdout-loglevel is only in effect during system startup and shutdown
71-
| log-dead-letters-during-shutdown = on
72-
| loglevel = debug
73-
| log-dead-letters = on
74-
| log-config-on-start = off // Log the complete configuration at INFO level when the actor system is started
75-
| loggers = ["akka.event.slf4j.Slf4jLogger"]
76-
| logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
77-
|}
78-
|
79-
|clustering.cluster.name = $systemName
80-
|
81-
|akka.cluster.roles = [${roles.mkString(",")}]
82-
|
83-
|akka.discovery {
84-
| config.services = {
85-
| $systemName = {
86-
| endpoints = [
87-
| {
88-
| host = "$hostname"
89-
| port = $managementPort
90-
| }
91-
| ]
92-
| }
93-
| }
94-
|}
95-
|
96-
|akka.management {
97-
| http {
98-
| hostname = $hostname
99-
| port = $managementPort
100-
| }
101-
| cluster.bootstrap {
102-
| contact-point-discovery {
103-
| service-name = $systemName
104-
| }
105-
| }
106-
|}
107-
|
108-
|akka.remote.artery.canonical.hostname = $hostname
109-
|akka.remote.artery.canonical.port = 0
110-
|
111-
|akka.coordinated-shutdown.exit-jvm = off
112-
|
113-
|akka.actor.testkit.typed {
114-
| # Factor by which to scale timeouts during tests, e.g. to account for shared
115-
| # build system load.
116-
| timefactor = 1.0
117-
|
118-
| # Duration to wait in expectMsg and friends outside of within() block
119-
| # by default.
120-
| # Dilated by the timefactor.
121-
| single-expect-default = 10s
122-
|
123-
| # Duration to wait in expectNoMessage by default.
124-
| # Dilated by the timefactor.
125-
| expect-no-message-default = 1000ms
126-
|
127-
| # The timeout that is used as an implicit Timeout.
128-
| # Dilated by the timefactor.
129-
| default-timeout = 5s
130-
|
131-
| # Default timeout for shutting down the actor system (used when no explicit timeout specified).
132-
| # Dilated by the timefactor.
133-
| system-shutdown-default=60s
134-
|
135-
| # Throw an exception on shutdown if the timeout is hit, if false an error is printed to stdout instead.
136-
| throw-on-shutdown-timeout=false
137-
|
138-
| # Duration to wait for all required logging events in LoggingTestKit.expect.
139-
| # Dilated by the timefactor.
140-
| filter-leeway = 3s
141-
|
142-
|}
143-
|
144-
|""".stripMargin + additionalConfig
68+
final lazy val akka: String =
69+
s"""
70+
|akka {
71+
| stdout-loglevel = off // defaults to WARNING can be disabled with off. The stdout-loglevel is only in effect during system startup and shutdown
72+
| log-dead-letters-during-shutdown = on
73+
| loglevel = debug
74+
| log-dead-letters = on
75+
| log-config-on-start = off // Log the complete configuration at INFO level when the actor system is started
76+
| loggers = ["akka.event.slf4j.Slf4jLogger"]
77+
| logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
78+
|}
79+
|
80+
|clustering.cluster.name = $systemName
81+
|
82+
|akka.cluster.roles = [${roles.mkString(",")}]
83+
|
84+
|akka.discovery {
85+
| config.services = {
86+
| $systemName = {
87+
| endpoints = [
88+
| {
89+
| host = "$hostname"
90+
| port = $managementPort
91+
| }
92+
| ]
93+
| }
94+
| }
95+
|}
96+
|
97+
|akka.management {
98+
| http {
99+
| hostname = $hostname
100+
| port = $managementPort
101+
| }
102+
| cluster.bootstrap {
103+
| contact-point-discovery {
104+
| service-name = $systemName
105+
| }
106+
| }
107+
|}
108+
|
109+
|akka.remote.artery.canonical.hostname = $hostname
110+
|akka.remote.artery.canonical.port = 0
111+
|
112+
|akka.coordinated-shutdown.exit-jvm = off
113+
|
114+
|akka.actor.testkit.typed {
115+
| # Factor by which to scale timeouts during tests, e.g. to account for shared
116+
| # build system load.
117+
| timefactor = 1.0
118+
|
119+
| # Duration to wait in expectMsg and friends outside of within() block
120+
| # by default.
121+
| # Dilated by the timefactor.
122+
| single-expect-default = 10s
123+
|
124+
| # Duration to wait in expectNoMessage by default.
125+
| # Dilated by the timefactor.
126+
| expect-no-message-default = 1000ms
127+
|
128+
| # The timeout that is used as an implicit Timeout.
129+
| # Dilated by the timefactor.
130+
| default-timeout = 5s
131+
|
132+
| # Default timeout for shutting down the actor system (used when no explicit timeout specified).
133+
| # Dilated by the timefactor.
134+
| system-shutdown-default=60s
135+
|
136+
| # Throw an exception on shutdown if the timeout is hit, if false an error is printed to stdout instead.
137+
| throw-on-shutdown-timeout=false
138+
|
139+
| # Duration to wait for all required logging events in LoggingTestKit.expect.
140+
| # Dilated by the timefactor.
141+
| filter-leeway = 3s
142+
|
143+
|}
144+
|
145+
|""".stripMargin + additionalConfig
145146

146147
/** @return
147-
* additional configuration
148-
*/
148+
* additional configuration
149+
*/
149150
def additionalConfig: String = ""
150151

151152
lazy val akkaConfig: Config = ConfigFactory.parseString(akka)
@@ -159,7 +160,7 @@ trait PersistenceTestKit
159160
def typedSystem(): ActorSystem[Nothing] = system
160161

161162
/** `PatienceConfig` from [[_root_.akka.actor.testkit.typed.TestKitSettings#DefaultTimeout]]
162-
*/
163+
*/
163164
implicit val patience: PatienceConfig =
164165
PatienceConfig(Settings.DefaultTimeout, Span(100, org.scalatest.time.Millis))
165166

@@ -174,11 +175,11 @@ trait PersistenceTestKit
174175
}
175176

176177
/** init and join cluster
177-
*/
178+
*/
178179
final def initAndJoinCluster(): Unit = {
179180
testKit.spawn(setup(), "guardian")
180181
// let the nodes join and become Up
181-
blockUntil("let the nodes join and become Up", 30, 2000)(() =>
182+
blockUntil("the nodes join and become Up", 30, 2000)(() =>
182183
Cluster(system).selfMember.status == MemberStatus.Up
183184
)
184185
}

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ addDependencyTreePlugin
1818

1919
//addSbtPlugin("com.typesafe.sbt" % "sbt-multi-jvm" % "0.4.0")
2020

21-
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.8")
21+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.3.0")

0 commit comments

Comments
 (0)