Skip to content

Commit

Permalink
Merge pull request #425 from laserdisc-io/ci
Browse files Browse the repository at this point in the history
prepare CI
  • Loading branch information
barryoneill authored May 16, 2024
2 parents 130fec6 + 513513d commit 5827ed7
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @semenodm
* @semenodm @barryoneill @jennyleahy
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)
// }
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 @@ -351,10 +351,9 @@ object TransactionState {

def mapRawToMeta(table: TableMetadata): ((ColumnMetadata, Option[Serializable])) => (String, Json) = {
case (column, Some(value)) =>
/** At some point, Scala will drop ClassTag, so we should be prepared to either drop cross compilation for 2.13,
* else add an alternative implementation that uses TypeTest. At the current time, I don't want to introduce
* any potential bugs into _this_ at the same time that I'm introducing Scala 3..
*/
/* At some point, Scala will drop ClassTag, so we should be prepared to either drop cross compilation for 2.13,
* else add an alternative implementation that uses TypeTest. At the current time, I don't want to introduce
* any potential bugs into _this_ at the same time that I'm introducing Scala 3.. */
@annotation.nowarn(
"msg=Use of `scala.reflect.ClassTag` for type testing may be unsound. Consider using `scala.reflect.TypeTest` instead."
)
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

0 comments on commit 5827ed7

Please sign in to comment.