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 to Play v2.9, Scala 2.13, Java 11 #349

Merged
merged 7 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 4 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,11 @@ jobs:
aws-region: eu-west-1
- uses: guardian/actions-setup-node@v2.4.1
- name: Set up JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 8
distribution: adopt
- name: Cache SBT
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
Comment on lines -31 to -37
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setup-java GHA now has built-in support for sbt caching (added with actions/setup-java#302) so we don't need to try to provide our own definition for caching sbt resources.

distribution: corretto
java-version: 11
cache: sbt
- name: CI yarn
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ node_modules/
public/build
ensime-langserver.log
pc.stdout.log
.bsp/
1 change: 0 additions & 1 deletion .java-version

This file was deleted.

1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java corretto-11.0.22.7.1
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ for both the composer and capi AWS accounts from [janus](https://janus.gutools.c

This project requires Node, so we recommend you use [node version manager](https://github.com/nvm-sh/nvm) `nvm`. Run `brew install nvm` if you do not have it. Run `nvm use` in the root of the project to ensure you are using the right version of node. The project's node version is set in the `.nvmrc` file.

The project also requires Java version `1.8.0.232` (or lower). The easiest way to set this is with `jenv`:
- `brew install jenv`
- Download and install the appopriate Java version: [jdk8u232-b09](https://adoptopenjdk.net/archive.html)
- `jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/`
The project also requires Java 11. The [easiest](https://docs.google.com/document/d/1ZR-YnaXCT5_gLVmTCeGs0mWd3KPaAozPjQK8uUzHZ9w/edit#heading=h.kgqqi53p3ltt)
way to install this is with `asdf install`, which will install the version of `java` specified in our
[.tool-versions](.tool-versions) file:
Comment on lines -12 to +14
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm dropping jenv here in favour of asdf, as that's what DevX currently recommend. Consequently, .java-version becomes .tool-versions and changes format slightly.


```shell
$ brew install asdf
$ asdf plugin add java
$ asdf install
```

You will then need to:

Expand Down
2 changes: 1 addition & 1 deletion app/AppLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AppLoader extends ApplicationLoader {
FileConfigurationLocation(new File(s"$home/.gu/$appName.conf"))
}

new AppComponents(context.copy(initialConfiguration = context.initialConfiguration ++ Configuration(loadedConfig)), identity).application
new AppComponents(context.copy(initialConfiguration = context.initialConfiguration.withFallback(Configuration(loadedConfig))), identity).application
}

private def startLogging(context: Context): Unit = {
Expand Down
3 changes: 1 addition & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Dependencies._
name := "atom-workshop"
version := "1.0"

scalaVersion := "2.12.16"
scalaVersion := "2.13.12"

libraryDependencies ++= dependencies

Expand All @@ -22,7 +22,6 @@ lazy val root = (project in file(".")).enablePlugins(PlayScala, RiffRaffArtifact

riffRaffPackageType := (Debian / packageBin).value,

debianPackageDependencies := Seq("openjdk-8-jre-headless"),
maintainer := "Editorial Tools <digitalcms.dev@guardian.co.uk>",
packageSummary := "Atom Workshop",
packageDescription := """A single place for atoms of all types""",
Expand Down
4 changes: 2 additions & 2 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ play.application.name="atom-workshop"

play.application.loader=AppLoader

play.http.secret.key="changeme"
play.http.secret.key="Value must be >9 chars. If the PLAY_SESSION cookie is *used*, use https://github.com/guardian/play-secret-rotation"

panda.system="atom-workshop"

parsers.text.maxLength=200kB
play.http.parser.maxMemoryBuffer=200K
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prompted by this error message in the logs:

application.conf @ file:/usr/share/atom-workshop/conf/application.conf: 9: parsers.text.maxLength is deprecated, use play.http.parser.maxMemoryBuffer instead

Apparently the parsers.text.maxLength property has been deprecated since Play 2.4 and playframework/playframework#4093 - play.http.parser.maxMemoryBuffer is preferred.

In atom-workshop, the increased size was set to allow bigger chart atoms: #272


play.filters.headers.contentSecurityPolicy="default-src 'self' 'unsafe-eval' 'unsafe-inline' data: https: wss:"
6 changes: 2 additions & 4 deletions conf/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
<contextName>atom-workshop</contextName>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${application.home}/logs/application.log</file>
<file>logs/application.log</file>

<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>
${application.home}/logs/application.log.%i
</fileNamePattern>
<fileNamePattern>logs/application.log.%i</fileNamePattern>
Comment on lines -5 to +8
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was prompted by this error in the logs:

Jan 26, 2024 @ 12:06:34.865 12:06:32,373 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - openFile(application.home_IS_UNDEFINED/logs/application.log,true) call failed. java.io.FileNotFoundException: application.home_IS_UNDEFINED/logs/application.log (No such file or directory)

Whatever ${application.home} was, it's not available anymore! With the updated settings (copied from Ophan) the error message is gone, and we still get log messages in the https://logs.gutools.co.uk/ ELK, where it matters.

See also https://stackoverflow.com/a/47331903, though I don't think we really needed the fallback.

<minIndex>1</minIndex>
<maxIndex>30</maxIndex>
</rollingPolicy>
Expand Down
8 changes: 4 additions & 4 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sbt._

object Dependencies {
lazy val awsVersion = "1.11.678"
lazy val atomLibVersion = "1.4.0"
lazy val atomLibVersion = "2.0.0"
lazy val jacksonVersion = "2.13.4"
lazy val jacksonDatabindVersion = "2.13.4.2"

Expand All @@ -30,10 +30,10 @@ object Dependencies {
"com.amazonaws" % "aws-java-sdk-kinesis" % awsVersion,
"com.gu" %% "atom-manager-play" % atomLibVersion,
"com.gu" %% "atom-publisher-lib" % atomLibVersion,
"com.gu" %% "editorial-permissions-client" % "2.0",
"com.gu" %% "editorial-permissions-client" % "2.15",
"com.gu" %% "simple-configuration-ssm" % "1.5.6",
"com.gu" %% "fezziwig" % "1.2",
"com.gu" %% "pan-domain-auth-play_2-8" % "1.2.0",
"com.gu" %% "fezziwig" % "1.6",
"com.gu" %% "pan-domain-auth-play_2-9" % "3.0.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially forgot to update this, but crucially, as we're updating to Play 2.9, we need to use pan-domain-auth-play_2-9!

Otherwise we get a NoSuchMethodError in the logs:

Jan 26, 2024 @ 16:44:08.273 java.lang.NoSuchMethodError: 'void play.api.mvc.DiscardingCookie.(java.lang.String, java.lang.String, scala.Option, boolean)'
Jan 26, 2024 @ 16:44:08.273 at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
Jan 26, 2024 @ 16:44:08.273 at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656
Jan 26, 2024 @ 16:44:08.271 at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
Jan 26, 2024 @ 16:44:08.271 at com.gu.pandomainauth.action.AuthActions.com$gu$pandomainauth$action$AuthActions$$discardCookies$(Actions.scala:102)

"io.circe" %% "circe-parser" % "0.14.5",
"net.logstash.logback" % "logstash-logback-encoder" % "6.6",
"com.gu" %% "content-api-client-aws" % "0.7",
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.8.0
sbt.version=1.9.8
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ logLevel := Level.Warn

libraryDependencies += "org.vafer" % "jdeb" % "1.6" artifacts Artifact("jdeb", "jar", "jar")

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.8")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.1")

addSbtPlugin("com.gu" % "sbt-riffraff-artifact" % "1.1.18")

Expand Down
2 changes: 1 addition & 1 deletion riff-raff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ deployments:
parameters:
amiTags:
BuiltBy: amigo
Recipe: editorial-tools-focal-java8-ARM-WITH-cdk-base
Recipe: editorial-tools-focal-java11-ARM-WITH-cdk-base
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we're changing AMIgo recipes, from:

editorial-tools-focal-java8-ARM-WITH-cdk-base

...to:

editorial-tools-focal-java11-ARM-WITH-cdk-base

The newer recipe already exists, and is in use for Composer, editorial feeds, etc.

AmigoStage: PROD
amiEncrypted: true
amiParameter: ImageId
Loading