Skip to content

Commit

Permalink
update build infrastructure (#610)
Browse files Browse the repository at this point in the history
* update build infrastructure
* adapt to Scala 3 style (parentheses around lambda arguments)
* adjust code to be Scala 3 compatible
  • Loading branch information
mr-git committed Apr 29, 2024
1 parent 5e8700a commit 2b8f7af
Show file tree
Hide file tree
Showing 58 changed files with 106 additions and 95 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
scala:
- 2.13.12
- 2.13.13

steps:
- uses: actions/checkout@v3
Expand All @@ -20,7 +20,7 @@ jobs:
- name: scala
uses: olafurpg/setup-scala@v11
with:
java-version: openjdk@1.11
java-version: openjdk@1.17

- name: build ${{ matrix.scala }}
run: sbt ++${{ matrix.scala }} clean versionPolicyCheck coverage test
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ project/plugins/project/

# Visual Studio Code
.bloop
.history
.metals
.vscode
metals.sbt
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,11 @@ libraryDependencies += "com.evolutiongaming" %% "kafka-journal-eventual-cassandr

* Jan 2019 [Riga Scala Community](https://www.meetup.com/Riga-Scala-Community/events/257926307)
* Apr 2019 [Amsterdam.scala](https://www.meetup.com/amsterdam-scala/events/260005066/)

## Development

To run unit-test, have to have Docker environment **running** (Docker Desktop, Rancher Desktop etc). Some tests expect to
have `/var/run/docker.sock` available. In case of Rancher Desktop, one has to amend local setup with:
```shell
sudo ln -s $HOME/.rd/docker.sock /var/run/docker.sock
```
21 changes: 14 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import Dependencies._

lazy val commonSettings = Seq(
organization := "com.evolutiongaming",
homepage := Some(new URL("http://github.com/evolution-gaming/kafka-journal")),
startYear := Some(2018),
organizationName := "Evolution",
organizationHomepage := Some(url("http://evolution.com")),
publishTo := Some(Resolver.evolutionReleases),
scalaVersion := crossScalaVersions.value.head,
organizationHomepage := Some(url("https://evolution.com")),
homepage := Some(url("https://github.com/evolution-gaming/kafka-journal")),
startYear := Some(2018),

crossScalaVersions := Seq("2.13.13"),
Compile / doc / scalacOptions ++= Seq("-groups", "-implicits", "-no-link-warnings"),
scalaVersion := crossScalaVersions.value.head,
scalacOptions ++= Seq("-release:17", "-deprecation"), // TODO https://github.com/evolution-gaming/kafka-journal/issues/611
scalacOptsFailOnWarn := Some(false),
Compile / doc / scalacOptions ++= Seq("-groups", "-implicits", "-no-link-warnings"),
publishTo := Some(Resolver.evolutionReleases),
licenses := Seq(("MIT", url("https://opensource.org/licenses/MIT"))),
releaseCrossBuild := true,

Test / testOptions ++= Seq(Tests.Argument(TestFrameworks.ScalaTest, "-oUDNCXEHLOPQRM")),
libraryDependencies += compilerPlugin(`kind-projector` cross CrossVersion.full),
libraryDependencySchemes ++= Seq(
Expand All @@ -22,11 +25,14 @@ lazy val commonSettings = Seq(
versionScheme := Some("early-semver"),
versionPolicyIntention := Compatibility.BinaryCompatible)

val alias: Seq[sbt.Def.Setting[_]] =
addCommandAlias("build", "all compile test")

lazy val root = (project in file(".")
settings (name := "kafka-journal")
settings commonSettings
settings (publish / skip := true)
settings alias
aggregate(
`scalatest-io`,
core,
Expand Down Expand Up @@ -150,7 +156,8 @@ lazy val `tests` = (project in file("tests")
publish / skip := true,
Test / fork := true,
Test / parallelExecution := false,
Test / javaOptions ++= Seq("-Xms3G", "-Xmx3G"))
Test / javaOptions ++= Seq("-Xms3G", "-Xmx3G"),
Test / envVars ++= Map("TESTCONTAINERS_RYUK_DISABLED" -> "true"))
dependsOn (
persistence % "test->test;compile->compile",
`persistence-circe`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ object CreateTables { self =>

object Table {

implicit val orderTable: Order[Table] = Order.by { a: Table => a.name }
implicit val orderTable: Order[Table] = Order.by { (a: Table) => a.name }

def apply(name: String, query: String): Table = Table(name, Nel.of(query))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object SettingStatements {
}

implicit val decodeRowSetting: DecodeRow[Setting] = {
data: GettableByNameData => {
(data: GettableByNameData) => {
Setting(
key = data.decode[Key]("key"),
value = data.decode[Value]("value"),
Expand Down Expand Up @@ -64,7 +64,7 @@ object SettingStatements {
for {
prepared <- query.prepare
} yield {
key: Key =>
(key: Key) =>
val bound = prepared
.bind()
.encode("key", key)
Expand Down Expand Up @@ -121,7 +121,7 @@ object SettingStatements {
for {
prepared <- query.prepare
} yield {
setting: Setting =>
(setting: Setting) =>
val bound = prepared
.bind()
.encode(setting)
Expand All @@ -147,7 +147,7 @@ object SettingStatements {
for {
prepared <- query.prepare
} yield {
setting: Setting =>
(setting: Setting) =>
val bound = prepared
.bind()
.encode(setting)
Expand Down Expand Up @@ -177,7 +177,7 @@ object SettingStatements {
for {
prepared <- query.prepare
} yield {
key: Key =>
(key: Key) =>
val bound = prepared
.bind()
.encode("key", key)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.evolutiongaming.kafka.journal.eventual.cassandra


import cats.Applicative
import cats.data.{NonEmptyList => Nel}
import cats.syntax.all._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ object CassandraSession {
def execute(statement: Statement) = {
self
.execute(statement)
.handleErrorWith { a: Throwable => error[Row](s"execute statement: $statement", a).toStream }
.handleErrorWith { (a: Throwable) => error[Row](s"execute statement: $statement", a).toStream }
}

def unsafe = self.unsafe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ class SettingsCassandraSpec extends AnyFunSuite {
private val settings = {

val statements = SettingsCassandra.Statements(
select = Database.select,
insert = Database.insert,
insertIfEmpty = Database.insertIfEmpty,
select = Database.select(_),
insert = Database.insert(_),
insertIfEmpty = Database.insertIfEmpty(_),
all = Database.all,
delete = Database.delete)
delete = Database.delete(_))

implicit val clock = Clock.const[F](nanos = 0, millis = timestamp.toEpochMilli)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object DeleteTo {
implicit val decodeByNameDeleteTo: DecodeByName[DeleteTo] = DecodeByName[SeqNr].map { _.toDeleteTo }


implicit val encodeByIdxDeleteTo: EncodeByIdx[DeleteTo] = EncodeByIdx[SeqNr].contramap { a: DeleteTo => a.value }
implicit val encodeByIdxDeleteTo: EncodeByIdx[DeleteTo] = EncodeByIdx[SeqNr].contramap { (a: DeleteTo) => a.value }

implicit val decodeByIdxDeleteTo: DecodeByIdx[DeleteTo] = DecodeByIdx[SeqNr].map { _.toDeleteTo }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ object Key {
implicit val showKey: Show[Key] = Show.fromToString

implicit val orderKey: Order[Key] = Order.whenEqual(
Order.by { a: Key => a.topic },
Order.by { a: Key => a.id })
Order.by { (a: Key) => a.topic },
Order.by { (a: Key) => a.id })

implicit val orderingKey: Ordering[Key] = orderKey.toOrdering

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object Payload {

final case class Binary(value: ByteVector) extends Payload {

def payloadType = PayloadType.Binary
def payloadType: PayloadType.Binary.type = PayloadType.Binary

def size: Long = value.length
}
Expand All @@ -41,7 +41,6 @@ object Payload {

val empty: Binary = Binary(ByteVector.empty)


implicit val codecBinary: Codec[Binary] = bytes.as[Binary]

}
Expand All @@ -51,18 +50,18 @@ object Payload {
}

final case class Text(value: String) extends TextOrJson {
def payloadType = PayloadType.Text
def payloadType: PayloadType.Text.type = PayloadType.Text
}

object Text {

implicit val codecText: Codec[Text] = utf8.as[Payload.Text]
implicit val codecText: Codec[Text] = utf8.as[Text]

}


final case class Json(value: JsValue) extends TextOrJson {
def payloadType = PayloadType.Json
def payloadType: PayloadType.Json.type = PayloadType.Json
}

object Json {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import cats.{FlatMap, ~>}
import com.evolutiongaming.catshelper.{Log, MeasureDuration}
import com.evolutiongaming.sstream.Stream

import scala.annotation.nowarn


trait Settings[F[_]] {

Expand Down Expand Up @@ -62,6 +64,7 @@ object Settings {
} yield r
}

@nowarn
def setIfEmpty(key: K, value: V) = {
for {
d <- MeasureDuration[F].start
Expand Down Expand Up @@ -102,6 +105,7 @@ object Settings {

def set(key: K, value: V) = fg(self.set(key, value))

@nowarn
def setIfEmpty(key: K, value: V) = fg(self.setIfEmpty(key, value))

def remove(key: K) = fg(self.remove(key))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object TestTemporal {
}

override def uncancelable[A](body: Poll[StateT[S, *]] => StateT[S, A]): StateT[S, A] = body(new Poll[StateT[S, *]] {
override def apply[X](fa: StateT[S, X]): StateT[S, X] = of { s: S =>
override def apply[X](fa: StateT[S, X]): StateT[S, X] = of { (s: S) =>
fa.run(s).uncancelable
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object ExpireOn {
implicit val orderExpireOn: Order[ExpireOn] = Order.fromOrdering


implicit val encodeByNameExpireOn: EncodeByName[ExpireOn] = EncodeByName[LocalDate].contramap { a: ExpireOn => a.value }
implicit val encodeByNameExpireOn: EncodeByName[ExpireOn] = EncodeByName[LocalDate].contramap { (a: ExpireOn) => a.value }

implicit val decodeByNameExpireOn: DecodeByName[ExpireOn] = DecodeByName[LocalDate].map { a => ExpireOn(a) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object Expiry {
implicit val decodeByNameOptExpireOn: DecodeByName[Option[ExpireOn]] = DecodeByName.optDecodeByName[ExpireOn]


implicit val encodeByNameExpireAfter: EncodeByName[ExpireAfter] = EncodeByName[FiniteDuration].contramap { a: ExpireAfter => a.value }
implicit val encodeByNameExpireAfter: EncodeByName[ExpireAfter] = EncodeByName[FiniteDuration].contramap { (a: ExpireAfter) => a.value }

implicit val decodeByNameExpireAfter: DecodeByName[ExpireAfter] = DecodeByName[FiniteDuration].map { _.toExpireAfter }

Expand All @@ -36,7 +36,7 @@ object Expiry {


implicit val decodeRowExpiryOpt: DecodeRow[Option[Expiry]] = {
row: GettableByNameData => {
(row: GettableByNameData) => {
for {
expireAfter <- row.decode[Option[ExpireAfter]]("expire_after")
expireOn <- row.decode[Option[ExpireOn]]("expire_on")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final case class JournalHead(
object JournalHead {

implicit def decodeRowJournalHead(implicit decode: DecodeRow[Option[Expiry]]): DecodeRow[JournalHead] = {
row: GettableByNameData => {
(row: GettableByNameData) => {
JournalHead(
partitionOffset = row.decode[PartitionOffset],
segmentSize = row.decode[SegmentSize],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final case class MetaJournalEntry(
object MetaJournalEntry {

implicit def decodeRowMetaJournalEntry(implicit decode: DecodeRow[JournalHead]): DecodeRow[MetaJournalEntry] = {
row: GettableByNameData => {
(row: GettableByNameData) => {
MetaJournalEntry(
journalHead = row.decode[JournalHead],
created = row.decode[Instant]("created"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ object Pointer2Statements {

object Result {
implicit val decodeResult: DecodeRow[Result] = {
row: GettableByNameData => {
(row: GettableByNameData) => {
Result(row.decode[Option[Instant]]("created"))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ object PointerStatements {

object Result {
implicit val decodeResult: DecodeRow[Result] = {
row: GettableByNameData => {
(row: GettableByNameData) => {
Result(row.decode[Option[Instant]]("created"))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object SegmentOf {

/** Calculate [[SegmentNr]] value by key using a hashing alorithm */
def apply[F[_]: Applicative](segments: Segments): SegmentOf[F] = {
key: Key => {
(key: Key) => {
val hashCode = key.id.toLowerCase.hashCode
val segmentNr = SegmentNr(hashCode, segments)
segmentNr.pure[F]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object SegmentSize {


implicit val configReaderSegmentSize: ConfigReader[SegmentSize] = {
cursor: ConfigCursor => {
(cursor: ConfigCursor) => {
for {
value <- cursor.asInt
segmentSize = of[Either[String, *]](value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.evolutiongaming.kafka.journal.eventual.cassandra

import cats.data.{NonEmptyList => Nel, State}
import cats.syntax.all._
import com.evolutiongaming.kafka.journal.cassandra.KeyspaceConfig
import com.evolutiongaming.scassandra.TableName
import org.scalatest.funsuite.AnyFunSuite

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ object ActionHeader {
}
}

implicit val writesActionHeader: Writes[ActionHeader] = formatOptActionHeader.contramap { a: ActionHeader => a.some }
implicit val writesActionHeader: Writes[ActionHeader] = formatOptActionHeader.contramap { (a: ActionHeader) => a.some }


implicit def toBytesActionHeader[F[_] : JsonCodec.Encode]: ToBytes[F, ActionHeader] = ToBytes.fromWrites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object AppendMarker {
produce: Produce[F],
): AppendMarker[F] = {

key: Key => {
(key: Key) => {
for {
randomId <- RandomIdOf[F].apply
partitionOffset <- produce.mark(key, randomId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.evolutiongaming.kafka.journal.util.ScodecHelper._
import scodec.bits.ByteVector
import scodec.{Codec, codecs}


final case class Events[A](events: Nel[Event[A]], metadata: PayloadMetadata)

object Events {
Expand Down

0 comments on commit 2b8f7af

Please sign in to comment.