Skip to content

Commit

Permalink
Merge pull request #455 from CleverCloud/breaking/migrate-to-scala-3
Browse files Browse the repository at this point in the history
[Breaking] Migrate to scala 3

Lot of thanks to @RemiBardon for the hard work! 🙇
  • Loading branch information
judu authored Jan 8, 2023
2 parents 08dcbab + 4d9a270 commit 168ff06
Show file tree
Hide file tree
Showing 31 changed files with 422 additions and 288 deletions.
86 changes: 82 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ jobs:
echo "name: ${{ steps.import_gpg.outputs.name }}"
echo "email: ${{ steps.import_gpg.outputs.email }}"
- name: run tests
run: sbt ++2.12.16 test
run: sbt ++2.12.17 test

- name: publish snapshot
run: sbt ++2.12.16 publish
run: sbt ++2.12.17 publish
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
Expand Down Expand Up @@ -81,10 +81,88 @@ jobs:
echo "email: ${{ steps.import_gpg.outputs.email }}"
- name: run tests
run: sbt ++2.13.8 test
run: sbt ++2.13.10 test

- name: publish snapshot
run: sbt ++2.13.8 publish
run: sbt ++2.13.10 publish
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

scala-3:
runs-on: ubuntu-latest
steps:
- name: checkout the repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11

- name: Launch pulsar docker
run: docker-compose up -d

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PGP_PASSPHRASE }}

- name: GPG user IDs
run: |
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
echo "name: ${{ steps.import_gpg.outputs.name }}"
echo "email: ${{ steps.import_gpg.outputs.email }}"
- name: run tests
run: sbt ++3.2.1 test

- name: publish snapshot
run: sbt ++3.2.1 publish
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

scala-3:
runs-on: ubuntu-latest
steps:
- name: checkout the repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11

- name: Launch pulsar docker
run: docker-compose up -d

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PGP_PASSPHRASE }}

- name: GPG user IDs
run: |
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
echo "name: ${{ steps.import_gpg.outputs.name }}"
echo "email: ${{ steps.import_gpg.outputs.email }}"
- name: run tests
run: sbt ++3.2.0 test

- name: publish snapshot
run: sbt ++3.2.0 publish
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
23 changes: 21 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: docker-compose up -d

- name: run tests
run: sbt ++2.12.16 test
run: sbt ++2.12.17 test

scala-2_13:
runs-on: ubuntu-latest
Expand All @@ -44,4 +44,23 @@ jobs:
run: docker-compose up -d

- name: run tests
run: sbt ++2.13.8 test
run: sbt ++2.13.10 test

scala-3:
runs-on: ubuntu-latest
steps:
- name: checkout the repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11

- name: Launch pulsar docker
run: docker-compose up -d

- name: run tests
run: sbt ++3.2.1 test
88 changes: 84 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ jobs:
echo "email: ${{ steps.import_gpg.outputs.email }}"
- name: run tests
run: sbt ++2.12.16 test
run: sbt ++2.12.17 test

- name: publish release
run: sbt ++2.12.16 publishSigned
run: sbt ++2.12.17 publishSigned
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
Expand Down Expand Up @@ -83,11 +83,91 @@ jobs:
echo "email: ${{ steps.import_gpg.outputs.email }}"
- name: run tests
run: sbt ++2.13.8 test
run: sbt ++2.13.10 test

- name: publish release
run: sbt ++2.13.8 publishSigned
run: sbt ++2.13.10 publishSigned
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}

release-scala-3:
runs-on: ubuntu-latest
steps:
- name: checkout the repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11

- name: Launch pulsar docker
run: docker-compose up -d

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PGP_PASSPHRASE }}

- name: GPG user IDs
run: |
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
echo "name: ${{ steps.import_gpg.outputs.name }}"
echo "email: ${{ steps.import_gpg.outputs.email }}"
- name: run tests
run: sbt ++3.2.1 test

- name: publish release
run: sbt ++3.2.1 publishSigned
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}

release-scala-3:
runs-on: ubuntu-latest
steps:
- name: checkout the repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11

- name: Launch pulsar docker
run: docker-compose up -d

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PGP_PASSPHRASE }}

- name: GPG user IDs
run: |
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
echo "name: ${{ steps.import_gpg.outputs.name }}"
echo "email: ${{ steps.import_gpg.outputs.email }}"
- name: run tests
run: sbt ++3.2.0 test

- name: publish release
run: sbt ++3.2.0 publishSigned
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
pulsar4s - Apache Pulsar Scala Client
==================================================
# pulsar4s - Apache Pulsar Scala Client

![build](https://github.com/CleverCloud/pulsar4s/workflows/build/badge.svg)
[<img src="https://img.shields.io/maven-central/v/com.clever-cloud.pulsar4s/pulsar4s-core_3.svg?label=latest%20release%20for%203"/>](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22pulsar4s-core_3%22)
[<img src="https://img.shields.io/maven-central/v/com.clever-cloud.pulsar4s/pulsar4s-core_2.13.svg?label=latest%20release%20for%202.13"/>](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22pulsar4s-core_2.13%22)
[<img src="https://img.shields.io/maven-central/v/com.clever-cloud.pulsar4s/pulsar4s-core_2.12.svg?label=latest%20release%20for%202.12"/>](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22pulsar4s-core_2.12%22)
[<img src="https://img.shields.io/nexus/s/https/oss.sonatype.org/com.clever-cloud.pulsar4s/pulsar4s-core_3.svg?label=latest%20snapshot&style=plastic"/>](https://oss.sonatype.org/content/repositories/snapshots/com/sksamuel/pulsar4s/)
[<img src="https://img.shields.io/nexus/s/https/oss.sonatype.org/com.clever-cloud.pulsar4s/pulsar4s-core_2.13.svg?label=latest%20snapshot&style=plastic"/>](https://oss.sonatype.org/content/repositories/snapshots/com/sksamuel/pulsar4s/)

pulsar4s is a concise, idiomatic, reactive, type safe Scala client for [Apache Pulsar](https://pulsar.apache.org/).
Expand All @@ -19,6 +20,28 @@ As a simple wrapper over the Java client, we benefit from the reliability and pe
* [FS2](https://github.com/typelevel/fs2) Reader and Writer
* Circe, SprayJson, PlayJson and Jackson implementations of Schema typeclass

## Warning!!

(This disclaimer was written on 2023-01-05.)

Starting in version 2.9.0, we support scala 3. This means we had to perform some
"aggressive" bumps on libs:

Libs that were bumped for everyone:
- play-json 2.10 (Currently in RC7)
- cats-effect 3.3 (was 2.x)
- ZIO 2.0 (was 1.x) & zio-cats-interop 23.0.0

Libs that come in different versions across scala versions:
- avro4s
- for Scala 3: 5.0+
- for Scala 2: 4.1+
- scala-java8-compat
- for Scala ≥2.13: 1.0.2
- for Scala 2.12: 0.8.0 (Was already the case before scala 3)

Check carefully that bumping pulsar4s will not break, especially with **cats-effect**!

## Using the client

The first step is to create a client attached to the pulsar cluster, providing the service url.
Expand Down
59 changes: 37 additions & 22 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,44 @@ def isRelease = releaseVersion != ""
def githubRunNumber = sys.env.getOrElse("GITHUB_RUN_NUMBER", "")
def ossrhUsername = sys.env.getOrElse("OSSRH_USERNAME", "")
def ossrhPassword = sys.env.getOrElse("OSSRH_PASSWORD", "")
def publishVersion = if (isRelease) releaseVersion else if (isGithubActions) "2.8.2." + githubRunNumber + "-SNAPSHOT" else "0.0.0-LOCAL"
def publishVersion = if (isRelease) releaseVersion else if (isGithubActions) "2.9.0." + githubRunNumber + "-SNAPSHOT" else "0.0.0-LOCAL"

val org = "com.clever-cloud.pulsar4s"
val AkkaStreamVersion = "2.6.19" // compatible with Akka 2.5.x and 2.6.x
val CatsEffectVersion = "3.3.14"
val CirceVersion = "0.14.2"
val AkkaStreamVersion = "2.6.20" // compatible with Akka 2.5.x and 2.6.x
val CatsEffectVersion = "3.4.4"
val CirceVersion = "0.14.3"
val CommonsIoVersion = "2.4"
val ExtsVersion = "1.61.1"
val JacksonVersion = "2.13.3"
val Log4jVersion = "2.17.2"
val JacksonVersion = "2.14.1"
val Log4jVersion = "2.19.0"
val MonixVersion = "3.4.1"
val PlayJsonVersion = "2.8.2" // compatible with 2.7.x and 2.8.x
val PulsarVersion = "2.10.1"
val PlayJsonVersion = "2.10.0-RC7"
val PulsarVersion = "2.10.3"
val ReactiveStreamsVersion = "1.0.2"
val FunctionalStreamsVersion = "3.2.14"
val Json4sVersion = "4.0.5"
val Avro4sVersion = "4.0.13"
val ScalaVersion = "2.13.8"
val ScalatestVersion = "3.2.13"
val ScalazVersion = "7.2.34"
val Slf4jVersion = "1.7.36"
val FunctionalStreamsVersion = "3.4.0"
val Json4sVersion = "4.0.6"
// Version of Avro4s for Scala 2.X
val Avro4sVersionFor2 = "4.1.0"
// Version of Avro4s for Scala 3.X
val Avro4sVersionFor3 = "5.0.3"
val ScalaVersion = "3.2.1"
val ScalatestVersion = "3.2.15"
val ScalazVersion = "7.2.35"
val Slf4jVersion = "2.0.6"
val SprayJsonVersion = "1.3.6"
val ZIOVersion = "1.0.16"
val ZIOInteropCatsVersion = "3.2.9.1"
val ZIOVersion = "2.0.5"
val ZIOInteropCatsVersion = "23.0.0.0"

lazy val commonScalaVersionSettings = Seq(
scalaVersion := ScalaVersion,
crossScalaVersions := Seq("2.12.16", "2.13.8")
crossScalaVersions := Seq("2.12.17", "2.13.10", ScalaVersion)
)

lazy val warnUnusedImport = Seq(
scalacOptions ++= Seq("-Ywarn-unused:imports"),
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq()
case _ => Seq("-Ywarn-unused:imports")
}),
Compile / console / scalacOptions ~= {
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports"))
},
Expand All @@ -50,7 +56,13 @@ lazy val commonSettings = Seq(
Global / parallelExecution := false,
Global / concurrentRestrictions += Tags.limit(Tags.Test, 1),
Compile / doc / scalacOptions := (Compile / doc / scalacOptions).value.filter(_ != "-Xfatal-warnings"),
scalacOptions ++= Seq("-unchecked", "-deprecation", "-encoding", "utf8")
scalacOptions ++= Seq("-unchecked", "-encoding", "utf8")
++ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) => Seq(
"-deprecation",
)
case _ => Seq()
})
)

lazy val publishSettings = Seq(
Expand Down Expand Up @@ -85,7 +97,7 @@ lazy val commonJvmSettings = Seq(

lazy val commonDeps = Seq(
libraryDependencies ++= Seq(
"com.sksamuel.exts" %% "exts" % ExtsVersion,
"com.sksamuel.exts" %% "exts" % ExtsVersion cross CrossVersion.for3Use2_13,
"org.slf4j" % "slf4j-api" % Slf4jVersion,
"org.scalatest" %% "scalatest" % ScalatestVersion % "test",
"org.apache.logging.log4j" % "log4j-api" % Log4jVersion % "test",
Expand Down Expand Up @@ -275,7 +287,10 @@ lazy val avro = Project("pulsar4s-avro", file("pulsar4s-avro"))
.settings(name := "pulsar4s-avro")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"com.sksamuel.avro4s" %% "avro4s-core" % Avro4sVersion
"com.sksamuel.avro4s" %% "avro4s-core" % (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Avro4sVersionFor3
case _ => Avro4sVersionFor2
})
))

lazy val akka_streams = Project("pulsar4s-akka-streams", file("pulsar4s-akka-streams"))
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.7.1
sbt.version=1.7.3
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
Loading

0 comments on commit 168ff06

Please sign in to comment.