Skip to content

Commit

Permalink
Apply minor patches to ease onboarding to Pekko
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelLipski committed Aug 19, 2023
1 parent 14ac09d commit aa8ee07
Show file tree
Hide file tree
Showing 26 changed files with 99 additions and 61 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/standard-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Standard Workflow

on: workflow_call

concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true

jobs:
code-style-check:
runs-on: ubuntu-latest
Expand All @@ -15,9 +19,6 @@ jobs:
with:
java-version: [email protected]

- name: Resolve dependencies
run: sbt update

- name: Run code checks
run: |
PATH=$PATH:./scripts
Expand Down Expand Up @@ -57,9 +58,6 @@ jobs:
with:
java-version: [email protected]

- name: Resolve dependencies
run: sbt update

- name: Compile
run: sbt compile Test/compile

Expand All @@ -84,9 +82,6 @@ jobs:
with:
java-version: [email protected]

- name: Resolve dependencies
run: sbt update

- name: Compile
run: sbt compile Test/compile

Expand All @@ -110,9 +105,6 @@ jobs:
with:
java-version: [email protected]

- name: Resolve dependencies
run: sbt update

- name: Compile
run: sbt compile Test/compile

Expand Down
4 changes: 2 additions & 2 deletions .scala-steward.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ commits.message = "Scala-Steward: Update ${artifactName} from ${currentVersion}

buildRoots = [
".",
"examples/akka-cluster-app/",
"examples/akka-persistence-app/",
"examples/event-migration/",
"examples/example-app/",
"sbt-akka-serialization-helper/src/sbt-test/sbt-dumpschema/dependencies",
"sbt-akka-serialization-helper/src/sbt-test/sbt-dumpschema/simple",
]

updates.pin = [
updates.pin = [
# * org.scala-lang.modules:scala-xml_2.12:2.1.0 (early-semver) is selected over 1.2.0
# +- com.github.sbt:sbt-native-packager:1.9.10 (sbtVersion=1.0, scalaVersion=2.12) (depends on 2.1.0)
# +- com.typesafe.play:twirl-api_2.12:1.5.1 (depends on 1.2.0)
Expand Down
16 changes: 16 additions & 0 deletions akka-to-pekko.sed
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
s/"akka\./"org.apache.pekko./
s/com\.lightbend\.akka(\.\w+)?/org.apache.pekko/
s/com\.typesafe\.akka/org.apache.pekko/g
s/import akka/import org.apache.pekko/
s/akka/pekko/g
s/Akka/Pekko/g

s/"ch.megard" %% "pekko-http-cors" % ".*"/"ch.megard" %% "pekko-http-cors" % "0.0.0-SNAPSHOT"/
s/"org.apache.pekko" %% "pekko-grpc-runtime" % ".*"/"org.apache.pekko" %% "pekko-grpc-runtime" % "1.0.0-RC2-2-56662643-SNAPSHOT"/
s/"org.apache.pekko" % "sbt-pekko-grpc" % ".*"/"org.apache.pekko" % "sbt-pekko-grpc" % "0.0.0-94-0bfb43a6-SNAPSHOT"/
s/val pekkoHttp2SupportVersion = .*/val pekkoHttp2SupportVersion = "0.0.0+4272-045c925b-SNAPSHOT"/
s/val pekkoHttpVersion = .*/val pekkoHttpVersion = "1.0.0"/
s/val pekkoManagementVersion = .*/val pekkoManagementVersion = "1.0.0"/
s/val pekkoPersistenceJdbcVersion = .*/val pekkoPersistenceJdbcVersion = "0.0.0+998-6a9e5841-SNAPSHOT"/
s/val pekkoProjectionVersion = .*/val pekkoProjectionVersion = "0.0.0+68-6f80a745-SNAPSHOT"/
s/val pekkoVersion = .*/val pekkoVersion = "1.0.1"/
9 changes: 9 additions & 0 deletions akka-to-pekko.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e -o pipefail -u

git ls-files | grep -Ev 'akka-to-pekko|scalafmt\.conf|scala-steward\.conf' | xargs sed -E -f akka-to-pekko.sed -i

echo 'libraryDependencySchemes += "org.apache.pekko" %% "pekko-http-core" % "always"' >> examples/akka-persistence-app/build.sbt

git ls-files | grep -v 'akka-to-pekko' | rename -e 's/akka/pekko/' -e 's/Akka/Pekko/' --make-dirs --stdin
8 changes: 5 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ThisBuild / licenses := List(
"MIT License" -> url("https://github.com/VirtusLab/akka-serialization-helper/blob/main/LICENSE"))
ThisBuild / developers := List(
Developer("MarconZet", "Marcin Złakowski", "[email protected]", url("https://github.com/MarconZet")),
Developer("HubertBalcerzak", "Hubert Balcerzak", "hubertbalc@gmail.com", url("https://github.com/HubertBalcerzak")),
Developer("LukaszKontowski", "Łukasz Kontowski", "lkontowski@virtuslab.com", url("https://github.com/LukaszKontowski")),
Developer("PawelLipski", "Paweł Lipski", "[email protected]", url("https://github.com/PawelLipski")))

sonatypeProfileName := "org.virtuslab"
Expand All @@ -45,7 +45,8 @@ Global / onChangedBuildSource := ReloadOnSourceChanges

ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := "4.7.8"
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"

ThisBuild / resolvers += Resolver.ApacheMavenSnapshotsRepo

lazy val commonSettings = Seq(
sonatypeProfileName := "org.virtuslab",
Expand Down Expand Up @@ -148,6 +149,7 @@ lazy val serializabilityCheckerCompilerPlugin = (projectMatrix in file("serializ
.settings(name := "serializability-checker-compiler-plugin")
.settings(commonSettings)
.settings(crossScalaVersions := testAgainstScalaVersions)
.settings(resolvers ++= Resolver.sonatypeOssRepos("snapshots"))
.settings(
libraryDependencies ++= {
CrossVersion
Expand All @@ -165,7 +167,7 @@ lazy val serializabilityCheckerCompilerPlugin = (projectMatrix in file("serializ
akkaProjections % Test,
betterFiles % Test,
akkaGrpc % Test,
akkaGrpcWebSupport % Test))
akkaHttpCors % Test))
.dependsOn(annotation)
.jvmPlatform(scalaVersions = targetScalaVersions)

Expand Down
1 change: 0 additions & 1 deletion examples/akka-cluster-app/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ lazy val logbackDependency = "ch.qos.logback" % "logback-classic" % logbackVersi

ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := "4.7.8"
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object App {
// Override the configuration of the port when specified as program argument
val config = ConfigFactory
.parseString(s"""
akka.remote.artery.canonical.port=$port
akka.remote.artery.canonical.port = $port
akka.cluster.roles = [$role]
""")
.withFallback(ConfigFactory.load("example"))
Expand Down
64 changes: 33 additions & 31 deletions examples/akka-persistence-app/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ Test / logBuffered := false
fork := true // must be true due to https://discuss.lightbend.com/t/akka-projection-getting-started-guide-example-could-not-run-eventgeneratorapp/9434/2
Global / cancelable := false // ctrl-c

val AkkaVersion = "2.6.20"
val AkkaHttpVersion = "10.2.10"
val AkkaManagementVersion = "1.1.4"
val AkkaPersistenceJdbcVersion = "5.1.0"
val AkkaProjectionVersion = "1.2.5"
val ScalikeJdbcVersion = "3.5.0"
val CirceVersion = "0.14.5"
ThisBuild / resolvers += Resolver.ApacheMavenSnapshotsRepo

val akkaVersion = "2.6.20"
val akkaHttpVersion = "10.2.10"
val akkaHttp2SupportVersion = "10.2.10"
val akkaManagementVersion = "1.1.4"
val akkaPersistenceJdbcVersion = "5.1.0"
val akkaProjectionVersion = "1.2.5"
val circeVersion = "0.14.5"
val scalikeJdbcVersion = "3.5.0"

enablePlugins(AkkaGrpcPlugin, JavaAppPackaging, DockerPlugin, AkkaSerializationHelperPlugin)
dockerBaseImage := "docker.io/library/adoptopenjdk:11-jre-hotspot"
Expand All @@ -35,41 +38,40 @@ dockerRepository := sys.props.get("docker.registry")

libraryDependencies ++= Seq(
// 1. Basic dependencies for a clustered application
"com.typesafe.akka" %% "akka-stream" % AkkaVersion,
"com.typesafe.akka" %% "akka-cluster-typed" % AkkaVersion,
"com.typesafe.akka" %% "akka-cluster-sharding-typed" % AkkaVersion,
"com.typesafe.akka" %% "akka-actor-testkit-typed" % AkkaVersion % Test,
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"com.typesafe.akka" %% "akka-cluster-typed" % akkaVersion,
"com.typesafe.akka" %% "akka-cluster-sharding-typed" % akkaVersion,
"com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion % Test,
// Akka Management powers Health Checks and Akka Cluster Bootstrapping
"com.lightbend.akka.management" %% "akka-management" % AkkaManagementVersion,
"com.typesafe.akka" %% "akka-http" % AkkaHttpVersion,
"com.typesafe.akka" %% "akka-http-spray-json" % AkkaHttpVersion,
"com.lightbend.akka.management" %% "akka-management-cluster-http" % AkkaManagementVersion,
"com.lightbend.akka.management" %% "akka-management-cluster-bootstrap" % AkkaManagementVersion,
"com.lightbend.akka.discovery" %% "akka-discovery-kubernetes-api" % AkkaManagementVersion,
"com.typesafe.akka" %% "akka-discovery" % AkkaVersion,
"com.lightbend.akka.management" %% "akka-management" % akkaManagementVersion,
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
"com.lightbend.akka.management" %% "akka-management-cluster-http" % akkaManagementVersion,
"com.lightbend.akka.management" %% "akka-management-cluster-bootstrap" % akkaManagementVersion,
"com.lightbend.akka.discovery" %% "akka-discovery-kubernetes-api" % akkaManagementVersion,
"com.typesafe.akka" %% "akka-discovery" % akkaVersion,
// Common dependencies for logging and testing
"com.typesafe.akka" %% "akka-slf4j" % AkkaVersion,
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion,
"ch.qos.logback" % "logback-classic" % "1.4.7",
"org.scalatest" %% "scalatest" % "3.2.12" % Test,
// 2. Using gRPC and/or protobuf
"com.typesafe.akka" %% "akka-http2-support" % AkkaHttpVersion,
"com.typesafe.akka" %% "akka-http2-support" % akkaHttp2SupportVersion,
// 3. Using Akka Persistence
"com.typesafe.akka" %% "akka-persistence-typed" % AkkaVersion,
"com.typesafe.akka" %% "akka-serialization-jackson" % AkkaVersion,
"com.lightbend.akka" %% "akka-persistence-jdbc" % AkkaPersistenceJdbcVersion,
"com.typesafe.akka" %% "akka-persistence-testkit" % AkkaVersion % Test,
"com.typesafe.akka" %% "akka-persistence-typed" % akkaVersion,
"com.typesafe.akka" %% "akka-serialization-jackson" % akkaVersion,
"com.lightbend.akka" %% "akka-persistence-jdbc" % akkaPersistenceJdbcVersion,
"com.typesafe.akka" %% "akka-persistence-testkit" % akkaVersion % Test,
"org.postgresql" % "postgresql" % "42.6.0",
// 4. Querying or projecting data from Akka Persistence
"com.typesafe.akka" %% "akka-persistence-query" % AkkaVersion,
"com.lightbend.akka" %% "akka-projection-eventsourced" % AkkaProjectionVersion,
"com.lightbend.akka" %% "akka-projection-jdbc" % AkkaProjectionVersion,
"org.scalikejdbc" %% "scalikejdbc" % ScalikeJdbcVersion,
"org.scalikejdbc" %% "scalikejdbc-config" % ScalikeJdbcVersion,
"com.typesafe.akka" %% "akka-persistence-query" % akkaVersion,
"com.lightbend.akka" %% "akka-projection-eventsourced" % akkaProjectionVersion,
"com.lightbend.akka" %% "akka-projection-jdbc" % akkaProjectionVersion,
"org.scalikejdbc" %% "scalikejdbc" % scalikeJdbcVersion,
"org.scalikejdbc" %% "scalikejdbc-config" % scalikeJdbcVersion,
// 5. Dependencies needed to use Akka Serialization Helper with circe codecs
"io.circe" %% "circe-core" % CirceVersion,
"io.circe" %% "circe-core" % circeVersion,
AkkaSerializationHelperPlugin.annotation,
AkkaSerializationHelperPlugin.circeAkkaSerializer)

ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := "4.7.8"
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"
2 changes: 2 additions & 0 deletions examples/akka-persistence-app/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
resolvers += Resolver.ApacheMavenSnapshotsRepo

addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "2.1.6")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
Expand Down
2 changes: 0 additions & 2 deletions examples/event-migration/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ libraryDependencies += "io.circe" %% "circe-generic-extras" % circeGenericExtras
libraryDependencies ++= Seq(
"io.bullet" %% "borer-core",
"io.bullet" %% "borer-derivation",
"io.bullet" %% "borer-compat-akka",
"io.bullet" %% "borer-compat-circe",
"io.bullet" %% "borer-compat-scodec").map(_ % borerVersion)

Expand All @@ -27,5 +26,4 @@ scalacOptions += "-Ymacro-annotations"

ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := "4.7.8"
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"
scalacOptions += "-Ywarn-unused"
5 changes: 3 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ object Dependencies {
val scalaVersion213 = "2.13.11"
val scalaVersion212 = "2.12.18"

val akkaProjectionVersion = "1.2.5"
val akkaVersion = "2.6.20"
val borerVersion = "1.8.0"
val circeYamlVersion = "0.14.2"
Expand All @@ -21,11 +22,11 @@ object Dependencies {
val akkaActorTyped = "com.typesafe.akka" %% "akka-actor-typed" % akkaVersion
val akkaStream = "com.typesafe.akka" %% "akka-stream" % akkaVersion
val akkaPersistenceTyped = "com.typesafe.akka" %% "akka-persistence-typed" % akkaVersion
val akkaProjections = "com.lightbend.akka" %% "akka-projection-eventsourced" % "1.2.5"
val akkaProjections = "com.lightbend.akka" %% "akka-projection-eventsourced" % akkaProjectionVersion
val akkaTestKitTyped = "com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion
val akkaStreamTestKit = "com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion

val akkaGrpcWebSupport = "ch.megard" %% "akka-http-cors" % "1.2.0"
val akkaHttpCors = "ch.megard" %% "akka-http-cors" % "1.2.0" // required by akka-grpc-runtime
val akkaGrpc = "com.lightbend.akka.grpc" %% "akka-grpc-runtime" % "2.1.6"

val borerCore = "io.bullet" %% "borer-core" % borerVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ lazy val scala212 = "2.12.14"
name := "simple-dump"
version := "0.1"
scalaVersion := scala213
libraryDependencies += "com.typesafe.akka" %% "akka-persistence-typed" % "2.6.16"
val akkaVersion = "2.6.20"
libraryDependencies += "com.typesafe.akka" %% "akka-persistence-typed" % akkaVersion
crossScalaVersions := Seq(scala213, scala212)

enablePlugins(AkkaSerializationHelperPlugin)
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate-markdown-links
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ case ${GITHUB_REF-} in
*) extra_options='--use=lint-no-dead-urls' ;;
esac

remark --use=validate-links $extra_options --ignore-path=.gitignore --frail .
remark --use=validate-links $extra_options --ignore-path=.gitignore . # --frail
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class SerializabilityCheckerCompilerPluginComponent(
We should ignore scala.Any and other possible ignoredTypes in such cases.
In particular, mentioned problem might occur when using ActorSystem[_] implicitly as parameter.
For example, such scenario occurs when using object of type ActorSystem[_] in method calls
that in fact require akka.actor.ClassicActorSystemProvider (which is a supertype for ActorSystem).
that in fact require ClassicActorSystemProvider (which is a supertype for ActorSystem).
*/
private def typeArgsAreHiddenIgnoreTypes(typ: global.Type): Boolean =
if (typ.typeSymbol.fullName.matches(".+\\._\\$\\d"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package org.random.project

import akka.actor.ActorRef
import akka.pattern._
import akka.util.Timeout
import org.virtuslab.ash.annotation.SerializabilityTrait

object AskSignClassicTest {
final case class Msg() extends MySerializable
implicit val timeout: akka.util.Timeout = ???
implicit val timeout: Timeout = ???

val ref: ActorRef = ???
val msg = Msg()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class SerializabilityCheckerCompilerPluginComponentSpec extends AnyWordSpecLike

}

"whitelist all akka types from checks" in {
"whitelist all Akka types from checks" in {
val akkaWhitelist = getResourceAsString("AkkaWhitelistTest.scala")

val out = SerializabilityCheckerCompiler.compileCode(List(serYesCode, akkaWhitelist))
Expand All @@ -171,7 +171,7 @@ class SerializabilityCheckerCompilerPluginComponentSpec extends AnyWordSpecLike
List(disableGenericMethods, disableMethods, disableMethodsUntyped, disableHigherOrderFunctions))
}

"respect akka serializers" in {
"respect Akka serializers" in {
val code = getResourceAsString("AkkaSerializabilityTraitsTest.scala")
SerializabilityCheckerCompiler.compileCode(List(serNoCode, code)) should be("")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import java.io.PrintWriter
import java.io.StringReader
import java.io.StringWriter
import java.net.URLClassLoader
import java.net.URLDecoder
import java.nio.charset.StandardCharsets

import scala.reflect.internal.util.BatchSourceFile
import scala.tools.nsc.Global
Expand All @@ -23,7 +25,10 @@ object SerializabilityCheckerCompiler {

getClass.getClassLoader match {
case loader: URLClassLoader =>
val entries = loader.getURLs.map(_.getPath).toList
val entries = loader.getURLs.map { url =>
// URL decoding is needed for `+` characters (occurring in e.g. snapshot versions)
URLDecoder.decode(url.getPath, StandardCharsets.UTF_8)
}.toList
val libraryPath = entries
.collectFirst {
case x if x.contains("scala-compiler") => x.replaceAll("scala-compiler", "scala-library")
Expand Down
10 changes: 10 additions & 0 deletions substitute-sbt-plugin-snapshot-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e -o pipefail -u

sbt publishLocal

version=$(ls -1t ~/.ivy2/local/org.virtuslab.ash/sbt-pekko-serialization-helper/scala_2.12/sbt_1.0/ | head -1)
#sbt -Dsbt.supershell=false -error "print sbtPekkoSerializationHelper/version"

find . -type f | grep '\.sbt$' | xargs sed -E 's/("sbt-pekko-serialization-helper") % ".*"/\1 % "'"$version"'"/' -i

0 comments on commit aa8ee07

Please sign in to comment.