Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Play 2.9.0 and drop Java 8 #479

Merged
merged 43 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
37d4560
Drop Java 8
mkurz Sep 29, 2022
44e2b5f
First unstable milestone for next major release
mkurz Oct 3, 2022
a89791e
scalatestplus-play 6 milestone
mkurz Oct 12, 2022
f068b2c
Latest ScalaTest
mkurz Oct 12, 2022
2d61db1
Upgrade logback
mkurz Oct 16, 2022
4fe35be
Mention OpenJDK 11
mkurz Mar 9, 2023
71ea7fa
sbt-twirl 1.6.4 (was 1.5.1)
scala-steward Nov 17, 2023
992dfa0
sbt 1.9.8
mkurz Dec 19, 2023
bbc2df2
formatting
mkurz Dec 19, 2023
2a6feeb
Update versions
mkurz Dec 20, 2023
2b2552d
Fix cross dependency
Dec 12, 2023
3df4ffa
Upgrade Scala version and SBT
Dec 14, 2023
9d5b024
Upgrade github scripts
Dec 14, 2023
93966bb
Downgrade scalatestplus
Dec 14, 2023
62448ec
Downgrade workflow versions
Dec 14, 2023
52d63e0
Play 2.9
Dec 14, 2023
15875e8
Add SslTestServerFactory for Test RunningServer
Dec 15, 2023
845c65b
chore: formatting
Dec 15, 2023
9ecbed4
chore: reformat headers
Dec 15, 2023
3bb532e
Reformatted
Dec 15, 2023
0887dee
chore: reformat
sentenza Dec 18, 2023
b83226f
Fix missing SSL endpoint
sentenza Dec 19, 2023
f710fef
chore: reformat
sentenza Dec 19, 2023
4ff1012
Upgrade github scripts
Dec 14, 2023
b9773aa
Downgrade scalatestplus
Dec 14, 2023
e68834b
Downgrade workflow versions
Dec 14, 2023
e4a9d01
Play 2.9
Dec 14, 2023
999ca49
Add SslTestServerFactory for Test RunningServer
Dec 15, 2023
aded651
chore: formatting
Dec 15, 2023
23efc03
chore: reformat headers
Dec 15, 2023
bcebf0a
Reformatted
Dec 15, 2023
55936e6
Target HTTPS endpoint
sentenza Dec 20, 2023
c3a12f4
No docs project anymore (incorrect rebase...)
mkurz Dec 20, 2023
1e845e8
Override testServerFactory
mkurz Dec 21, 2023
156f7b5
Don't override newServerForTest anymore
mkurz Dec 21, 2023
65f156e
Upgrade scalaTestPlusPlay which provides https support
mkurz Dec 21, 2023
a024b3a
Update .gitignore
mkurz Dec 21, 2023
4e3ba7f
Set acceptAnyCertificate to true for tests
mkurz Dec 21, 2023
f2fc5ab
Add logback configs to avoid noise in tests
mkurz Dec 21, 2023
c7ad264
Move Test / javaOptions to common plugin + fork needed
mkurz Dec 21, 2023
045b5bf
Typo
mkurz Dec 21, 2023
646dc0d
Downgrade sbt-akka-grpc because of IllegalArgumentException
mkurz Dec 21, 2023
58ac5f8
Formating
mkurz Dec 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/scala-steward.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ updates.pin = [
# Prevent updates to 3.2.x and beyond
{ groupId = "org.scalatest", artifactId = "scalatest", version = "3.1."}
]

updatePullRequests = false
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
- "check-docs"
uses: playframework/.github/.github/workflows/cmd.yml@v3
with:
java: 11, 8
scala: 2.12.x, 2.13.x
java: 17, 11
scala: 2.13.x
cmd: sbt ++$MATRIX_SCALA test

finish:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ on:
jobs:
publish-artifacts:
name: Publish / Artifacts
uses: playframework/.github/.github/workflows/publish.yml@v2
uses: playframework/.github/.github/workflows/publish.yml@v3
secrets: inherit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ target
node_modules/
/docs/build/
/docs/package*.json
logs/
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ val playGenerators = Project(id = "play-grpc-generators", file("play-generators"
buildInfoPackage := "play.grpc.gen",
// Only used in build tools (like sbt), so only 2.12 is needed:
crossScalaVersions := Seq(scala212),
scalaVersion := scala212,
)

val playTestkit = Project("play-grpc-testkit", file("play-testkit"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,4 @@ trait ServerGrpcClient extends AkkaGrpcClientHelpers { this: BaseOneServerPerTes
): AkkaGrpcClientFactory.Configured[T] = {
AkkaGrpcClientHelpers.factoryForAppEndpoints(running.app, running.endpoints)
}

protected override def newServerForTest(app: Application, testData: TestData): RunningServer =
DefaultTestServerFactory.start(app)

}
1 change: 1 addition & 0 deletions play-scalatest/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
play.ws.ssl.loose.acceptAnyCertificate = true
50 changes: 50 additions & 0 deletions play-scalatest/src/test/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" ?>

<!-- https://www.playframework.com/documentation/latest/SettingsLogger -->

<!DOCTYPE configuration>

<configuration>
<import class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"/>
<import class="ch.qos.logback.classic.AsyncAppender"/>
<import class="ch.qos.logback.core.FileAppender"/>
<import class="ch.qos.logback.core.ConsoleAppender"/>

<appender name="FILE" class="FileAppender">
<file>${application.home:-.}/logs/application.log</file>
<encoder class="PatternLayoutEncoder">
<charset>UTF-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss} %highlight(%-5level) %cyan(%logger{36}) %magenta(%X{pekkoSource}) %msg%n</pattern>
</encoder>
</appender>

<appender name="STDOUT" class="ConsoleAppender">
<!--
On Windows, enabling Jansi is recommended to benefit from color code interpretation on DOS command prompts,
which otherwise risk being sent ANSI escape sequences that they cannot interpret.
See https://logback.qos.ch/manual/layouts.html#coloring
-->
<!-- <withJansi>true</withJansi> -->
<encoder class="PatternLayoutEncoder">
<charset>UTF-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss} %highlight(%-5level) %cyan(%logger{36}) %magenta(%X{pekkoSource}) %msg%n</pattern>
</encoder>
</appender>

<appender name="ASYNCFILE" class="AsyncAppender">
<appender-ref ref="FILE"/>
</appender>

<appender name="ASYNCSTDOUT" class="AsyncAppender">
<appender-ref ref="STDOUT"/>
</appender>

<logger name="play" level="INFO"/>
<logger name="application" level="DEBUG"/>

<root level="WARN">
<appender-ref ref="ASYNCFILE"/>
<appender-ref ref="ASYNCSTDOUT"/>
</root>

</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import play.api.inject.guice.GuiceApplicationBuilder
import play.api.libs.ws.WSClient
import play.api.routing.Router
import play.api.Application
import play.grpc.testkit.SslTestServerFactory

/**
* Test for the Play gRPC ScalaTest APIs
Expand All @@ -26,6 +27,8 @@ class PlayActionsScalaTestSpec
with ScalaFutures
with IntegrationPatience {

override def testServerFactory = new SslTestServerFactory

override def fakeApplication(): Application = {
GuiceApplicationBuilder()
.overrides(bind[Router].to[GreeterServiceWithActionsImpl])
Expand All @@ -36,7 +39,7 @@ class PlayActionsScalaTestSpec

"A Play server bound to a gRPC router using actions" must {
"give a 404 when routing a non-gRPC request" in {
val result = wsUrl("/").get.futureValue
val result = wsUrl("/", true).get.futureValue
result.status must be(404) // Maybe should be a 426, see #396
}
// this test results in a 500
Expand All @@ -54,7 +57,7 @@ class PlayActionsScalaTestSpec
// result.header("grpc-status") mustEqual Some(Status.Code.UNIMPLEMENTED.value().toString)
// }
"give a grpc 'invalid argument' error when routing an empty request to a gRPC method" in {
val result = wsUrl(s"/${GreeterService.name}/SayHello")
val result = wsUrl(s"/${GreeterService.name}/SayHello", true)
.addHttpHeaders("Content-Type" -> GrpcProtocolNative.contentType.toString)
.get
.futureValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import play.api.inject.guice.GuiceApplicationBuilder
import play.api.libs.ws.WSClient
import play.api.routing.Router
import play.api.Application
import play.grpc.testkit.SslTestServerFactory

/**
* Test for the Play gRPC ScalaTest APIs
Expand All @@ -26,6 +27,8 @@ class PlayScalaTestSpec
with ScalaFutures
with IntegrationPatience {

override def testServerFactory = new SslTestServerFactory
sentenza marked this conversation as resolved.
Show resolved Hide resolved

override def fakeApplication(): Application = {
GuiceApplicationBuilder()
.overrides(bind[Router].to[GreeterServiceImpl])
Expand All @@ -36,23 +39,23 @@ class PlayScalaTestSpec

"A Play server bound to a gRPC router" must {
"give a 404 when routing a non-gRPC request" in {
val result = wsUrl("/").get.futureValue
val result = wsUrl("/", true).get.futureValue
result.status must be(404) // Maybe should be a 426, see #396
}
"give a 415 error when not using a gRPC content-type" in {
val result = wsUrl(s"/${GreeterService.name}/FooBar").get.futureValue
val result = wsUrl(s"/${GreeterService.name}/FooBar", true).get.futureValue
result.status must be(415)
}
"give a grpc 'unimplemented' error when routing a non-existent gRPC method" in {
val result = wsUrl(s"/${GreeterService.name}/FooBar")
val result = wsUrl(s"/${GreeterService.name}/FooBar", true)
.addHttpHeaders("Content-Type" -> GrpcProtocolNative.contentType.toString)
.get
.futureValue
result.status must be(200) // Maybe should be a 426, see #396
result.header("grpc-status") mustEqual Some(Status.Code.UNIMPLEMENTED.value().toString)
}
"give a grpc 'invalid argument' error when routing an empty request to a gRPC method" in {
val result = wsUrl(s"/${GreeterService.name}/SayHello")
val result = wsUrl(s"/${GreeterService.name}/SayHello", true)
.addHttpHeaders("Content-Type" -> GrpcProtocolNative.contentType.toString)
.get
.futureValue
Expand Down
1 change: 1 addition & 0 deletions play-specs2/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
play.ws.ssl.loose.acceptAnyCertificate = true
50 changes: 50 additions & 0 deletions play-specs2/src/test/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" ?>

<!-- https://www.playframework.com/documentation/latest/SettingsLogger -->

<!DOCTYPE configuration>

<configuration>
<import class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"/>
<import class="ch.qos.logback.classic.AsyncAppender"/>
<import class="ch.qos.logback.core.FileAppender"/>
<import class="ch.qos.logback.core.ConsoleAppender"/>

<appender name="FILE" class="FileAppender">
<file>${application.home:-.}/logs/application.log</file>
<encoder class="PatternLayoutEncoder">
<charset>UTF-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss} %highlight(%-5level) %cyan(%logger{36}) %magenta(%X{pekkoSource}) %msg%n</pattern>
</encoder>
</appender>

<appender name="STDOUT" class="ConsoleAppender">
<!--
On Windows, enabling Jansi is recommended to benefit from color code interpretation on DOS command prompts,
which otherwise risk being sent ANSI escape sequences that they cannot interpret.
See https://logback.qos.ch/manual/layouts.html#coloring
-->
<!-- <withJansi>true</withJansi> -->
<encoder class="PatternLayoutEncoder">
<charset>UTF-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss} %highlight(%-5level) %cyan(%logger{36}) %magenta(%X{pekkoSource}) %msg%n</pattern>
</encoder>
</appender>

<appender name="ASYNCFILE" class="AsyncAppender">
<appender-ref ref="FILE"/>
</appender>

<appender name="ASYNCSTDOUT" class="AsyncAppender">
<appender-ref ref="STDOUT"/>
</appender>

<logger name="play" level="INFO"/>
<logger name="application" level="DEBUG"/>

<root level="WARN">
<appender-ref ref="ASYNCFILE"/>
<appender-ref ref="ASYNCSTDOUT"/>
</root>

</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@ import play.api.libs.ws.WSClient
import play.api.libs.ws.WSRequest
import play.api.routing.Router
import play.api.test._
import play.grpc.testkit.SslTestServerFactory

/**
* Test for the Play gRPC Specs2 APIs
*/
@RunWith(classOf[JUnitRunner])
class PlaySpecs2Spec extends ForServer with ServerGrpcClient with PlaySpecification with ApplicationFactories {

override def testServerFactory = new SslTestServerFactory

protected def applicationFactory: ApplicationFactory =
withGuiceApp(GuiceApplicationBuilder().overrides(bind[Router].to[GreeterServiceImpl]))

// RICH: Still need to work out how to make WSClient work properly with endpoints
def wsUrl(path: String)(implicit running: RunningServer): WSRequest = {
val ws = running.app.injector.instanceOf[WSClient]
val url = running.endpoints.httpEndpoint.get.pathUrl(path)
val url = running.endpoints.httpsEndpoint.get.pathUrl(path)
ws.url(url)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static ServerEndpoint getHttp2Endpoint(final ServerEndpoints serverEndpoi
.endpoints()
.filter(e -> e.protocols().contains("HTTP/2.0" /* Play's HttpProtocol.HTTP_2_0 */))
.toIterable();
if (possibleEndpoints.size() == 0) {
if (possibleEndpoints.isEmpty()) {
throw new IllegalArgumentException(
String.format(
"gRPC client can't automatically find HTTP/2 connection: "
Expand Down Expand Up @@ -60,7 +60,7 @@ public static GrpcClientSettings grpcClientSettings(
.getOrElse(
() -> {
throw new IllegalArgumentException(
"GrpcClientSettings requires a server endpoint with ssl, but non provided");
"GrpcClientSettings requires a server endpoint with ssl, but none provided");
});

return grpcClientSettings(http2Endpoint, sslContext, actorSystem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import play.libs.ws.*;

public final class PlayJavaFunctionalTest {
private final TestServerFactory testServerFactory = new DefaultTestServerFactory();
private final TestServerFactory testServerFactory = new SslTestServerFactory();

private Application app;
private RunningServer runningServer;
Expand Down Expand Up @@ -49,7 +49,7 @@ public void stopServer() throws Exception {

private WSResponse wsGet(final String path) throws Exception {
final WSClient wsClient = app.injector().instanceOf(WSClient.class);
final String url = runningServer.endpoints().httpEndpoint().get().pathUrl(path);
final String url = runningServer.endpoints().httpsEndpoint().get().pathUrl(path);
return wsClient
.url(url)
.addHeader("Content-Type", GrpcProtocolNative.contentType().toString())
Expand Down
4 changes: 3 additions & 1 deletion play-testkit/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
play.server.provider = play.core.server.AkkaHttpServerProvider
play.server.provider = play.core.server.AkkaHttpServerProvider

play.ws.ssl.loose.acceptAnyCertificate = true
50 changes: 50 additions & 0 deletions play-testkit/src/test/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" ?>

<!-- https://www.playframework.com/documentation/latest/SettingsLogger -->

<!DOCTYPE configuration>

<configuration>
<import class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"/>
<import class="ch.qos.logback.classic.AsyncAppender"/>
<import class="ch.qos.logback.core.FileAppender"/>
<import class="ch.qos.logback.core.ConsoleAppender"/>

<appender name="FILE" class="FileAppender">
<file>${application.home:-.}/logs/application.log</file>
<encoder class="PatternLayoutEncoder">
<charset>UTF-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss} %highlight(%-5level) %cyan(%logger{36}) %magenta(%X{pekkoSource}) %msg%n</pattern>
</encoder>
</appender>

<appender name="STDOUT" class="ConsoleAppender">
<!--
On Windows, enabling Jansi is recommended to benefit from color code interpretation on DOS command prompts,
which otherwise risk being sent ANSI escape sequences that they cannot interpret.
See https://logback.qos.ch/manual/layouts.html#coloring
-->
<!-- <withJansi>true</withJansi> -->
<encoder class="PatternLayoutEncoder">
<charset>UTF-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss} %highlight(%-5level) %cyan(%logger{36}) %magenta(%X{pekkoSource}) %msg%n</pattern>
</encoder>
</appender>

<appender name="ASYNCFILE" class="AsyncAppender">
<appender-ref ref="FILE"/>
</appender>

<appender name="ASYNCSTDOUT" class="AsyncAppender">
<appender-ref ref="STDOUT"/>
</appender>

<logger name="play" level="INFO"/>
<logger name="application" level="DEBUG"/>

<root level="WARN">
<appender-ref ref="ASYNCFILE"/>
<appender-ref ref="ASYNCSTDOUT"/>
</root>

</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com>
*/
package play.grpc.testkit

import akka.annotation.ApiMayChange
import play.api.test.DefaultTestServerFactory
import play.api.Application
import play.core.server.ServerConfig

/**
* A test server factory that configures the server to use SSL.
*/
@ApiMayChange class SslTestServerFactory extends DefaultTestServerFactory {
override def serverConfig(app: Application): ServerConfig = {
super
.serverConfig(app)
.copy(
port = None,
sslPort = Some(0),
)
}
}
5 changes: 4 additions & 1 deletion project/CommonPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ object CommonPlugin extends AutoPlugin {
Nil
},
doc / javacOptions --= Seq("-Xlint:unchecked", "-Xlint:deprecation"),
crossScalaVersions := Seq(scala212, scala213),
Test / javaOptions ++= Seq("--add-exports=java.base/sun.security.x509=ALL-UNNAMED"),
Test / fork := true,
crossScalaVersions := Seq(scala213),
scalaVersion := scala213,
)

val scalaVersionNumber = Def.setting(VersionNumber(scalaVersion.value))
Expand Down
Loading
Loading