diff --git a/.github/workflows/standard-workflow.yml b/.github/workflows/standard-workflow.yml index 6c703097..28e3de35 100644 --- a/.github/workflows/standard-workflow.yml +++ b/.github/workflows/standard-workflow.yml @@ -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 @@ -15,9 +19,6 @@ jobs: with: java-version: adopt@1.11 - - name: Resolve dependencies - run: sbt update - - name: Run code checks run: | PATH=$PATH:./scripts @@ -33,6 +34,9 @@ jobs: # Curiously, scalafmtCheckAll doesn't cover *.sbt files, hence scalafmtSbtCheck is needed as well run: sbt scalafmtCheckAll scalafmtSbtCheck "scalafixAll --check" + - name: Substitute sbt plugin snapshot version + run: ./scripts/substitute-sbt-plugin-snapshot-version + - name: Check code style - examples/event-migration run: sbt scalafmtCheckAll scalafmtSbtCheck "scalafixAll --check" working-directory: examples/event-migration @@ -57,9 +61,6 @@ jobs: with: java-version: adopt@1.11 - - name: Resolve dependencies - run: sbt update - - name: Compile run: sbt compile Test/compile @@ -84,9 +85,6 @@ jobs: with: java-version: adopt@1.11 - - name: Resolve dependencies - run: sbt update - - name: Compile run: sbt compile Test/compile @@ -110,9 +108,6 @@ jobs: with: java-version: adopt@1.11 - - name: Resolve dependencies - run: sbt update - - name: Compile run: sbt compile Test/compile @@ -151,6 +146,9 @@ jobs: with: java-version: adopt@1.11 + - name: Substitute sbt plugin snapshot version + run: ./scripts/substitute-sbt-plugin-snapshot-version + - name: Test event-migration-examples run: sbt test working-directory: examples/event-migration diff --git a/.remarkrc.yml b/.remarkrc.yml new file mode 100644 index 00000000..f0217eef --- /dev/null +++ b/.remarkrc.yml @@ -0,0 +1,5 @@ +plugins: + lint-no-dead-urls: + skipUrlPatterns: + # TODO (#325): remove these patterns + - https://github.com/VirtusLab/pekko-serialization-helper diff --git a/.scala-steward.conf b/.scala-steward.conf index 1e6c18f7..ae1fda32 100644 --- a/.scala-steward.conf +++ b/.scala-steward.conf @@ -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) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4a0d05ab..ccc785aa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -73,18 +73,10 @@ You might as well use any other profiler, but using https://github.com/jvm-profi ### Code quality -Before committing, don't forget to type -```shell -sbt scalafmtAll scalafixAll scalafmtSbt -``` -to format the code, .sbt files and check imports. Run this command in the following directories: -- the base directory (`.`) -- `examples/akka-cluster-app` -- `examples/akka-persistence-app` -- `examples/event-migration` -You can use `pre-commit` hook, provided in `./pre-commit`, to do the formatting and checking automatically. - -Additionally, all warnings locally are escalated to errors in CI, so make sure there are none. +Don't forget to run `./scripts/format-code` before opening a pull request. +You can symlink this file as git `pre-commit` hook, but beware that it runs quite long. + +All local Scala compilation warnings are escalated to errors in CI, so make sure there are none. ### Compatible JDK versions diff --git a/build.sbt b/build.sbt index f3b6b1bd..f941d418 100644 --- a/build.sbt +++ b/build.sbt @@ -36,7 +36,11 @@ ThisBuild / licenses := List( "MIT License" -> url("https://github.com/VirtusLab/akka-serialization-helper/blob/main/LICENSE")) ThisBuild / developers := List( Developer("MarconZet", "Marcin Złakowski", "mzlakowski@virtuslab.com", 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", "plipski@virtuslab.com", url("https://github.com/PawelLipski"))) sonatypeProfileName := "org.virtuslab" @@ -45,7 +49,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", @@ -148,6 +153,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 @@ -165,7 +171,7 @@ lazy val serializabilityCheckerCompilerPlugin = (projectMatrix in file("serializ akkaProjections % Test, betterFiles % Test, akkaGrpc % Test, - akkaGrpcWebSupport % Test)) + akkaHttpCors % Test)) .dependsOn(annotation) .jvmPlatform(scalaVersions = targetScalaVersions) diff --git a/examples/akka-cluster-app/build.sbt b/examples/akka-cluster-app/build.sbt index 9a2d749d..6b4e5c07 100644 --- a/examples/akka-cluster-app/build.sbt +++ b/examples/akka-cluster-app/build.sbt @@ -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" diff --git a/examples/akka-cluster-app/src/main/scala/org/virtuslab/example/App.scala b/examples/akka-cluster-app/src/main/scala/org/virtuslab/example/App.scala index 4b6e318d..f1d0939e 100644 --- a/examples/akka-cluster-app/src/main/scala/org/virtuslab/example/App.scala +++ b/examples/akka-cluster-app/src/main/scala/org/virtuslab/example/App.scala @@ -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")) diff --git a/examples/akka-persistence-app/build.sbt b/examples/akka-persistence-app/build.sbt index 82e7053a..569f24b5 100644 --- a/examples/akka-persistence-app/build.sbt +++ b/examples/akka-persistence-app/build.sbt @@ -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" @@ -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" diff --git a/examples/akka-persistence-app/project/plugins.sbt b/examples/akka-persistence-app/project/plugins.sbt index 8ff9d3cf..c9bd395d 100644 --- a/examples/akka-persistence-app/project/plugins.sbt +++ b/examples/akka-persistence-app/project/plugins.sbt @@ -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") diff --git a/examples/akka-persistence-app/src/main/scala/org.virtuslab/example/CirceAkkaSerializable.scala b/examples/akka-persistence-app/src/main/scala/org/virtuslab/example/CirceAkkaSerializable.scala similarity index 100% rename from examples/akka-persistence-app/src/main/scala/org.virtuslab/example/CirceAkkaSerializable.scala rename to examples/akka-persistence-app/src/main/scala/org/virtuslab/example/CirceAkkaSerializable.scala diff --git a/examples/akka-persistence-app/src/main/scala/org.virtuslab/example/ExampleSerializer.scala b/examples/akka-persistence-app/src/main/scala/org/virtuslab/example/ExampleSerializer.scala similarity index 100% rename from examples/akka-persistence-app/src/main/scala/org.virtuslab/example/ExampleSerializer.scala rename to examples/akka-persistence-app/src/main/scala/org/virtuslab/example/ExampleSerializer.scala diff --git a/examples/akka-persistence-app/src/main/scala/org.virtuslab/example/Main.scala b/examples/akka-persistence-app/src/main/scala/org/virtuslab/example/Main.scala similarity index 100% rename from examples/akka-persistence-app/src/main/scala/org.virtuslab/example/Main.scala rename to examples/akka-persistence-app/src/main/scala/org/virtuslab/example/Main.scala diff --git a/examples/akka-persistence-app/src/main/scala/org.virtuslab/example/ShoppingCart.scala b/examples/akka-persistence-app/src/main/scala/org/virtuslab/example/ShoppingCart.scala similarity index 100% rename from examples/akka-persistence-app/src/main/scala/org.virtuslab/example/ShoppingCart.scala rename to examples/akka-persistence-app/src/main/scala/org/virtuslab/example/ShoppingCart.scala diff --git a/examples/akka-persistence-app/src/main/scala/org.virtuslab/example/ShoppingCartServer.scala b/examples/akka-persistence-app/src/main/scala/org/virtuslab/example/ShoppingCartServer.scala similarity index 100% rename from examples/akka-persistence-app/src/main/scala/org.virtuslab/example/ShoppingCartServer.scala rename to examples/akka-persistence-app/src/main/scala/org/virtuslab/example/ShoppingCartServer.scala diff --git a/examples/akka-persistence-app/src/main/scala/org.virtuslab/example/ShoppingCartServiceImpl.scala b/examples/akka-persistence-app/src/main/scala/org/virtuslab/example/ShoppingCartServiceImpl.scala similarity index 100% rename from examples/akka-persistence-app/src/main/scala/org.virtuslab/example/ShoppingCartServiceImpl.scala rename to examples/akka-persistence-app/src/main/scala/org/virtuslab/example/ShoppingCartServiceImpl.scala diff --git a/examples/akka-persistence-app/src/main/scala/org.virtuslab/example/repository/ScalikeJdbcSession.scala b/examples/akka-persistence-app/src/main/scala/org/virtuslab/example/repository/ScalikeJdbcSession.scala similarity index 100% rename from examples/akka-persistence-app/src/main/scala/org.virtuslab/example/repository/ScalikeJdbcSession.scala rename to examples/akka-persistence-app/src/main/scala/org/virtuslab/example/repository/ScalikeJdbcSession.scala diff --git a/examples/akka-persistence-app/src/main/scala/org.virtuslab/example/repository/ScalikeJdbcSetup.scala b/examples/akka-persistence-app/src/main/scala/org/virtuslab/example/repository/ScalikeJdbcSetup.scala similarity index 100% rename from examples/akka-persistence-app/src/main/scala/org.virtuslab/example/repository/ScalikeJdbcSetup.scala rename to examples/akka-persistence-app/src/main/scala/org/virtuslab/example/repository/ScalikeJdbcSetup.scala diff --git a/examples/event-migration/build.sbt b/examples/event-migration/build.sbt index 5c4db250..004cc5e5 100644 --- a/examples/event-migration/build.sbt +++ b/examples/event-migration/build.sbt @@ -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) @@ -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" diff --git a/project/Dependencies.scala b/project/Dependencies.scala index eef42d24..1d5c491e 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -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" @@ -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 diff --git a/sbt-akka-serialization-helper/src/sbt-test/sbt-dumpschema/simple/build.sbt b/sbt-akka-serialization-helper/src/sbt-test/sbt-dumpschema/simple/build.sbt index 69148fae..a31ac1b9 100644 --- a/sbt-akka-serialization-helper/src/sbt-test/sbt-dumpschema/simple/build.sbt +++ b/sbt-akka-serialization-helper/src/sbt-test/sbt-dumpschema/simple/build.sbt @@ -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) diff --git a/scripts/akka-to-pekko b/scripts/akka-to-pekko new file mode 100755 index 00000000..7b4fcf40 --- /dev/null +++ b/scripts/akka-to-pekko @@ -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 diff --git a/scripts/akka-to-pekko.sed b/scripts/akka-to-pekko.sed new file mode 100644 index 00000000..87c04ab1 --- /dev/null +++ b/scripts/akka-to-pekko.sed @@ -0,0 +1,17 @@ +s/"akka\./"org.apache.pekko./ +s/doc\.akka\.io/pekko.apache.org/g +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"/ diff --git a/pre-commit b/scripts/format-code similarity index 62% rename from pre-commit rename to scripts/format-code index 7f88fc8d..b47f35dc 100755 --- a/pre-commit +++ b/scripts/format-code @@ -1,8 +1,6 @@ #!/bin/sh -# This can be symlinked from .git/hooks/pre-commit in the repo with: -# ln -s ../../pre-commit .git/hooks/pre-commit -# Make sure the file is executable. +set -e sbt scalafmtAll scalafixAll scalafmtSbt diff --git a/scripts/substitute-sbt-plugin-snapshot-version b/scripts/substitute-sbt-plugin-snapshot-version new file mode 100755 index 00000000..13c6c90b --- /dev/null +++ b/scripts/substitute-sbt-plugin-snapshot-version @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e -o pipefail -u + +sbt publishLocal + +version=$(ls -1t ~/.ivy2/local/org.virtuslab.ash/sbt-akka-serialization-helper/scala_2.12/sbt_1.0/ | head -1) +# Version can be more elegantly extracted using: +# sbt -Dsbt.supershell=false -error "print sbtPekkoSerializationHelper/version" +# but the problem is that snapshot versions include minute-resolution timestamp, +# which is likely to change from the preceding `sbt publishLocal`. + +find . -type f | grep '\.sbt$' | xargs sed -E 's/("sbt-akka-serialization-helper") % ".*"/\1 % "'"$version"'"/' -i diff --git a/scripts/validate-markdown-links b/scripts/validate-markdown-links index ad5a030b..9e3cd442 100755 --- a/scripts/validate-markdown-links +++ b/scripts/validate-markdown-links @@ -9,7 +9,7 @@ case ${GITHUB_REF-} in # We don't want a main branch/tag build to fail because some linked website has a random downtime. refs/heads/main) extra_options='' ;; refs/tags/*) extra_options='' ;; - *) extra_options='--use=lint-no-dead-urls' ;; + *) extra_options='--use=lint-no-dead-urls --rc-path=.remarkrc.yml' ;; esac remark --use=validate-links $extra_options --ignore-path=.gitignore --frail . diff --git a/serializability-checker-compiler-plugin/src/main/scala/org/virtuslab/ash/SerializabilityCheckerCompilerPluginComponent.scala b/serializability-checker-compiler-plugin/src/main/scala/org/virtuslab/ash/SerializabilityCheckerCompilerPluginComponent.scala index 0b116dd3..2fda54b9 100644 --- a/serializability-checker-compiler-plugin/src/main/scala/org/virtuslab/ash/SerializabilityCheckerCompilerPluginComponent.scala +++ b/serializability-checker-compiler-plugin/src/main/scala/org/virtuslab/ash/SerializabilityCheckerCompilerPluginComponent.scala @@ -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")) diff --git a/serializability-checker-compiler-plugin/src/test/resources/AskSignClassicTest.scala b/serializability-checker-compiler-plugin/src/test/resources/AskSignClassicTest.scala index a1c85359..25ebc713 100644 --- a/serializability-checker-compiler-plugin/src/test/resources/AskSignClassicTest.scala +++ b/serializability-checker-compiler-plugin/src/test/resources/AskSignClassicTest.scala @@ -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() diff --git a/serializability-checker-compiler-plugin/src/test/scala/org/virtuslab/ash/SerializabilityCheckerCompilerPluginComponentSpec.scala b/serializability-checker-compiler-plugin/src/test/scala/org/virtuslab/ash/SerializabilityCheckerCompilerPluginComponentSpec.scala index 9353d815..3316c399 100644 --- a/serializability-checker-compiler-plugin/src/test/scala/org/virtuslab/ash/SerializabilityCheckerCompilerPluginComponentSpec.scala +++ b/serializability-checker-compiler-plugin/src/test/scala/org/virtuslab/ash/SerializabilityCheckerCompilerPluginComponentSpec.scala @@ -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)) @@ -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("") } diff --git a/serializability-checker-compiler-plugin/src/test/scala/org/virtuslab/ash/compiler/SerializabilityCheckerCompiler.scala b/serializability-checker-compiler-plugin/src/test/scala/org/virtuslab/ash/compiler/SerializabilityCheckerCompiler.scala index 5fa47817..07938786 100644 --- a/serializability-checker-compiler-plugin/src/test/scala/org/virtuslab/ash/compiler/SerializabilityCheckerCompiler.scala +++ b/serializability-checker-compiler-plugin/src/test/scala/org/virtuslab/ash/compiler/SerializabilityCheckerCompiler.scala @@ -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 @@ -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")