Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare CI #425

Merged
merged 4 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
name: Build

on: [push, pull_request]
name: CI
on:
pull_request:
branches: ['*']
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: olafurpg/setup-scala@v13
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Java And Sbt
uses: olafurpg/setup-scala@v14
with:
java-version: openjdk@1.11
java-version: corretto@1.17
- name: Cache SBT
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cache/coursier/v1
~/.sbt
key: sbt-${{ hashFiles('**/build.sbt') }}
- name: Run tests
run: sbt clean test
run: sbt +clean +test +doc

12 changes: 5 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
name: Release
on:
push:
branches: [master]
branches: [main]
tags: ["*"]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: olafurpg/setup-scala@v13
- uses: actions/checkout@v4
with:
java-version: [email protected]
- uses: olafurpg/setup-gpg@v3
- name: Publish
run: sbt ci-release
fetch-depth: 0
- uses: olafurpg/setup-scala@v14
- run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.laserdisc.mysql.binlog

import cats.data.Kleisli
import cats.implicits.*
import io.circe.Json
import io.laserdisc.mysql.binlog.event.EventMessage
import io.laserdisc.mysql.json

import scala.collection.mutable
import cats.implicits.*
import io.laserdisc.mysql.json

package object compaction {
def compact(transaction: Seq[EventMessage]): Seq[EventMessage] =
Expand All @@ -15,7 +15,7 @@ package object compaction {
val emId = calcIdentity(evt)
acc
.get(emId)
.fold[Unit](acc.put(emId, evt)) { latest =>
.fold(acc.put(emId, evt)) { latest =>
mkNewEvent(evt)
.andThen(finalizeNewEvent)
.run(latest) match {
Expand All @@ -25,12 +25,6 @@ package object compaction {
case None => acc.remove(emId)
}
}
// TODO: use this code, once Scala 2.12 support ends, or updateWith back ported to 2.12A
// acc.updateWith(evt.pk) {
// case Some(latest) =>
// mkNewEvent(evt).andThen(finalizeNewEvent).run(latest)
// case None => Some(evt)
// }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this, it puts events in reverse order - I think the existing impl is fine

acc
}
.values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ package object config {

// ServerID should be set, (see mysql-binlog-connector-java / BinaryLogClient.setServerId for documentation)
v.serverId match {
case Some(sid) => blc.setServerId(sid)
case Some(sid) => blc.setServerId(sid.longValue())
case None =>
logger.warn(
s"ServerID is not provided, so ${blc.getServerId} will be the default. This will cause issues if running multiple binlog services with this value!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import org.scalatest.wordspec.AnyWordSpec
import org.typelevel.log4cats.SelfAwareStructuredLogger
import org.typelevel.log4cats.slf4j.Slf4jLogger

import scala.language.reflectiveCalls

class MysqlBinlogStreamTest extends AnyWordSpec with ForAllTestContainer with MySqlContainerTest with Matchers {

implicit val logger: SelfAwareStructuredLogger[IO] = Slf4jLogger.getLogger[IO]
Expand All @@ -41,6 +39,7 @@ class MysqlBinlogStreamTest extends AnyWordSpec with ForAllTestContainer with My
)
.transact(xa)
)
.map(_ => ())
.unsafeRunSync()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import io.laserdisc.mysql.binlog.config.BinLogConfigOps

import scala.language.reflectiveCalls
import scala.util.control

class PipesTest extends AnyWordSpec with Matchers with ForAllTestContainer with MySqlContainerTest {
Expand All @@ -29,7 +28,7 @@ class PipesTest extends AnyWordSpec with Matchers with ForAllTestContainer with
val client: BinaryLogClient = binlogConfig.mkBinaryLogClient()

client.registerLifecycleListener(new BinaryLogClient.AbstractLifecycleListener {
override def onConnect(client: BinaryLogClient): Unit =
override def onConnect(client: BinaryLogClient): Unit = {
control.Exception.allCatch.opt {
testTransactor
.use { xa =>
Expand All @@ -49,6 +48,8 @@ class PipesTest extends AnyWordSpec with Matchers with ForAllTestContainer with
}
.unsafeRunSync()
}
()
}
})

val events = testTransactor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import io.laserdisc.mysql.binlog.config.BinLogConfig
import io.laserdisc.mysql.binlog.models.SchemaMetadata
import io.laserdisc.mysql.binlog.stream.{MysqlBinlogStream, TransactionState, streamEvents}
import io.laserdisc.mysql.binlog.{client, database}
import org.typelevel.log4cats.Logger
import org.typelevel.log4cats.slf4j.Slf4jLogger

object BinLogListener extends IOApp {
Expand Down Expand Up @@ -52,7 +51,7 @@ object BinLogListener extends IOApp {
_ <- MysqlBinlogStream
.rawEvents[IO](binlogClient)
.through(streamEvents[IO](transactionState, config.schema))
.evalTap(msg => summon[Logger[IO]].info(s"received $msg"))
.evalTap(msg => logger.info(s"received $msg"))
// Here you should do the checkpoint
.compile
.drain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import java.net.URI
import scala.concurrent.ExecutionContext
import scala.concurrent.ExecutionContext.Implicits
import scala.jdk.CollectionConverters.*
import scala.language.existentials

trait MySqlContainerTest extends TestContainersForAll with BeforeAndAfterEach {
self: Suite =>
Expand Down
Loading