From 8e965565a17816779e6f85f630c70d493df16722 Mon Sep 17 00:00:00 2001 From: Renato Cavalcanti Date: Mon, 26 Jul 2021 14:21:10 +0200 Subject: [PATCH] use GH Actions to compile and tests with Scala 3 (#30427) * use GH Actions to compile and tests with Scala 3 * Update .github/workflows/scala3-build.yml Co-authored-by: Andrea Peruffo * rename .jvmopts-travis to .jvmopts-ci * Restore the whitesource stage * Small updates to gh action workflow * Mark BoundedBlockingQueueSpec timing-sensitive and exclude * Avoid race condition stopping/starting test actors Co-authored-by: Andrea Peruffo Co-authored-by: Ignasi Marimon-Clos Co-authored-by: Arnout Engelen --- .github/workflows/scala3-build.yml | 47 +++++++++++++++++++ .jvmopts-travis => .jvmopts-ci | 0 .travis.yml | 8 +--- .../akka/util/BoundedBlockingQueueSpec.scala | 3 +- .../javadsl/ActorContextPipeToSelfTest.java | 10 ++-- .../scaladsl/ActorContextPipeToSelfSpec.scala | 10 ++-- 6 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/scala3-build.yml rename .jvmopts-travis => .jvmopts-ci (100%) diff --git a/.github/workflows/scala3-build.yml b/.github/workflows/scala3-build.yml new file mode 100644 index 0000000000..ffa2b1b2a7 --- /dev/null +++ b/.github/workflows/scala3-build.yml @@ -0,0 +1,47 @@ +name: Build Akka with Scala 3 + +on: + pull_request: + push: + branches: + - master + tags-ignore: [ v.* ] + +jobs: + compile-and-test-with-scala3: + name: Compile and test with Scala 3 + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up JDK 11 + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.11.0-9 + + - name: Cache Coursier cache + uses: coursier/cache-action@v6.2 + + - name: Compile and test selected modules on Scala 3 + run: | + sbt -jvm-opts .jvmopts-ci \ + -Dakka.build.scalaVersion=3.0 \ + -Dakka.test.tags.exclude=performance,timing,long-running \ + akka-actor-tests/test \ + akka-actor-testkit-typed/test \ + akka-actor-typed/compile \ + akka-actor-typed-tests/test \ + akka-discovery/test \ + akka-pki/test \ + akka-protobuf/test \ + akka-protobuf-v3/test \ + akka-slf4j/test \akka-stream/test \ + akka-stream-tests-tck/test \ + akka-coordination/test \ + akka-serialization-jackson/test:compile \ + akka-testkit/test \ + akka-stream-testkit/test \ + akka-remote/compile diff --git a/.jvmopts-travis b/.jvmopts-ci similarity index 100% rename from .jvmopts-travis rename to .jvmopts-ci diff --git a/.travis.yml b/.travis.yml index 2b4814232e..2b6686b5e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,25 +28,19 @@ cache: - $HOME/.jabba/jdk # script for the default 'test' stage: -script: sbt -jvm-opts .jvmopts-travis -Dakka.build.scalaVersion=$TRAVIS_SCALA_VERSION ";update ;mimaReportBinaryIssues ;test:compile ;validateCompile ;headerCheckAll" +script: sbt -jvm-opts .jvmopts-ci -Dakka.build.scalaVersion=$TRAVIS_SCALA_VERSION ";update ;mimaReportBinaryIssues ;test:compile ;validateCompile ;headerCheckAll" jobs: include: - stage: whitesource name: whitesource script: git branch -f "$TRAVIS_BRANCH" && git checkout "$TRAVIS_BRANCH" && sbt whitesourceCheckPolicies whitesourceUpdate - - stage: scala3 - name: scala3 - # separate job since only a few modules compile with Scala 3 yet - script: jabba install adopt@1.11-0 && jabba use adopt@1.11-0 && sbt -jvm-opts .jvmopts-travis -Dakka.build.scalaVersion=3.0 akka-actor-tests/test akka-actor-testkit-typed/test akka-actor-typed/compile akka-actor-typed-tests/test akka-discovery/test akka-pki/test akka-protobuf/test akka-protobuf-v3/test akka-slf4j/test akka-stream/test akka-stream-tests-tck/test akka-coordination/test akka-serialization-jackson/test:compile akka-testkit/test akka-stream-testkit/test akka-remote/compile stages: - name: whitesource if: repo = akka/akka AND ((branch = master AND type != pull_request) OR tag =~ ^v) - name: test if: type == pull_request OR NOT tag =~ ^v - - name: scala3 - if: type == pull_request OR NOT tag =~ ^v env: global: diff --git a/akka-actor-tests/src/test/scala/akka/util/BoundedBlockingQueueSpec.scala b/akka-actor-tests/src/test/scala/akka/util/BoundedBlockingQueueSpec.scala index 4ab64a0946..f82651133a 100644 --- a/akka-actor-tests/src/test/scala/akka/util/BoundedBlockingQueueSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/util/BoundedBlockingQueueSpec.scala @@ -21,6 +21,7 @@ import org.scalatest.time.Span import org.scalatest.time.SpanSugar._ import org.scalatest.wordspec.AnyWordSpec +import akka.testkit.TimingTest import akka.util.DefaultExecutionContext._ import akka.util.ccompat.JavaConverters._ @@ -123,7 +124,7 @@ class BoundedBlockingQueueSpec (events should contain).inOrder(offer("a"), poll, offer("b")) } - "check the backing queue size before offering" in { + "check the backing queue size before offering" taggedAs TimingTest in { val TestContext(queue, events, _, notFull, lock, _) = newBoundedBlockingQueue(1) queue.offer("a") diff --git a/akka-actor-typed-tests/src/test/java/akka/actor/typed/javadsl/ActorContextPipeToSelfTest.java b/akka-actor-typed-tests/src/test/java/akka/actor/typed/javadsl/ActorContextPipeToSelfTest.java index e7cb9baf9c..181489f4a3 100644 --- a/akka-actor-typed-tests/src/test/java/akka/actor/typed/javadsl/ActorContextPipeToSelfTest.java +++ b/akka-actor-typed-tests/src/test/java/akka/actor/typed/javadsl/ActorContextPipeToSelfTest.java @@ -49,12 +49,12 @@ public final class ActorContextPipeToSelfTest extends JUnitSuite { @Test public void handlesSuccess() { - assertEquals("ok: hi", responseFrom(CompletableFuture.completedFuture("hi"))); + assertEquals("ok: hi", responseFrom(CompletableFuture.completedFuture("hi"), "success")); } @Test public void handlesFailure() { - assertEquals("ko: boom", responseFrom(failedFuture(new RuntimeException("boom")))); + assertEquals("ko: boom", responseFrom(failedFuture(new RuntimeException("boom")), "failure")); } @Test @@ -110,7 +110,7 @@ public final class ActorContextPipeToSelfTest extends JUnitSuite { return future; } - private String responseFrom(final CompletionStage future) { + private String responseFrom(final CompletionStage future, String postfix) { final TestProbe probe = testKit.createTestProbe(); final Behavior behavior = Behaviors.setup( @@ -134,14 +134,14 @@ public final class ActorContextPipeToSelfTest extends JUnitSuite { return Behaviors.stopped(); }); }); - final String name = "pipe-to-self-spec"; + final String name = "pipe-to-self-spec-" + postfix; final Props props = Props.empty().withDispatcherFromConfig("pipe-to-self-spec-dispatcher"); testKit.spawn(behavior, name, props); final Msg msg = probe.expectMessageClass(Msg.class); - assertEquals("pipe-to-self-spec", msg.selfName); + assertEquals(name, msg.selfName); assertThat( msg.threadName, startsWith("ActorContextPipeToSelfTest-pipe-to-self-spec-dispatcher")); return msg.response; diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/ActorContextPipeToSelfSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/ActorContextPipeToSelfSpec.scala index 9a41f3fe70..57b5322b8c 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/ActorContextPipeToSelfSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/ActorContextPipeToSelfSpec.scala @@ -32,8 +32,8 @@ final class ActorContextPipeToSelfSpec with LogCapturing { "The Scala DSL ActorContext pipeToSelf" must { - "handle success" in { responseFrom(Future.successful("hi")) should ===("ok: hi") } - "handle failure" in { responseFrom(Future.failed(Fail)) should ===(s"ko: $Fail") } + "handle success" in { responseFrom(Future.successful("hi"), "success") should ===("ok: hi") } + "handle failure" in { responseFrom(Future.failed(Fail), "failure") should ===(s"ko: $Fail") } "handle adapted null" in { val probe = testKit.createTestProbe[String]() val promise = Promise[String]() @@ -63,7 +63,7 @@ final class ActorContextPipeToSelfSpec object Fail extends NoStackTrace - private def responseFrom(future: Future[String]) = { + private def responseFrom(future: Future[String], postfix: String) = { final case class Msg(response: String, selfName: String, threadName: String) val probe = TestProbe[Msg]() @@ -77,14 +77,14 @@ final class ActorContextPipeToSelfSpec Behaviors.stopped } } - val name = "pipe-to-self-spec" + val name = s"pipe-to-self-spec-$postfix" val props = Props.empty.withDispatcherFromConfig("pipe-to-self-spec-dispatcher") spawn(behavior, name, props) val msg = probe.expectMessageType[Msg] - msg.selfName should ===("pipe-to-self-spec") + msg.selfName should ===(name) msg.threadName should startWith("ActorContextPipeToSelfSpec-pipe-to-self-spec-dispatcher") msg.response }