From 6716668ab5dbb38ff6ae6287cacf8f8579c90221 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Thu, 18 Jan 2024 11:18:26 +0000 Subject: [PATCH 1/7] Upgrade to Play v2.9, Scala 2.13, Java 11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These upgrades were prompted by https://github.com/guardian/atom-maker/pull/94, but they're all a good idea anyway: * Play: 2.8 → 2.9 * Scala: 2.12 → 2.13 * Java: 8 → 11 --- .github/workflows/ci.yml | 14 ++++---------- .gitignore | 1 + .java-version | 1 - .tool-versions | 1 + README.md | 13 +++++++++---- app/AppLoader.scala | 2 +- build.sbt | 2 +- project/Dependencies.scala | 6 +++--- project/build.properties | 2 +- project/plugins.sbt | 2 +- riff-raff.yaml | 2 +- 11 files changed, 23 insertions(+), 23 deletions(-) delete mode 100644 .java-version create mode 100644 .tool-versions diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cb1c3b7..6e10e29a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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') }} + distribution: corretto + java-version: 17 + cache: sbt - name: CI yarn shell: bash run: | diff --git a/.gitignore b/.gitignore index 28f39653..56a414d0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ node_modules/ public/build ensime-langserver.log pc.stdout.log +.bsp/ diff --git a/.java-version b/.java-version deleted file mode 100644 index 1f233b46..00000000 --- a/.java-version +++ /dev/null @@ -1 +0,0 @@ -1.8.0.232 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..8079c02f --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +java corretto-11.0.22.7.1 diff --git a/README.md b/README.md index 17e14d83..dc082f1c 100644 --- a/README.md +++ b/README.md @@ -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: + +```shell +$ brew install asdf +$ asdf plugin add java +$ asdf install +``` You will then need to: diff --git a/app/AppLoader.scala b/app/AppLoader.scala index 4fc6494c..093d8d2d 100644 --- a/app/AppLoader.scala +++ b/app/AppLoader.scala @@ -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 = { diff --git a/build.sbt b/build.sbt index d409dd54..3df87a47 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ import Dependencies._ name := "atom-workshop" version := "1.0" -scalaVersion := "2.12.16" +scalaVersion := "2.13.12" libraryDependencies ++= dependencies diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 07210130..156bd020 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -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-PREVIEW.fix-tests-under-java-17.2024-01-18T1039.b4d55b3d" lazy val jacksonVersion = "2.13.4" lazy val jacksonDatabindVersion = "2.13.4.2" @@ -30,9 +30,9 @@ 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.14", "com.gu" %% "simple-configuration-ssm" % "1.5.6", - "com.gu" %% "fezziwig" % "1.2", + "com.gu" %% "fezziwig" % "1.6", "com.gu" %% "pan-domain-auth-play_2-8" % "1.2.0", "io.circe" %% "circe-parser" % "0.14.5", "net.logstash.logback" % "logstash-logback-encoder" % "6.6", diff --git a/project/build.properties b/project/build.properties index 8b9a0b0a..abbbce5d 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.0 +sbt.version=1.9.8 diff --git a/project/plugins.sbt b/project/plugins.sbt index bf992677..af7db2eb 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -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") diff --git a/riff-raff.yaml b/riff-raff.yaml index e8e9444c..069e5866 100644 --- a/riff-raff.yaml +++ b/riff-raff.yaml @@ -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 AmigoStage: PROD amiEncrypted: true amiParameter: ImageId From 6c52f1a8c9cae7f557d9514bc106f387b898f104 Mon Sep 17 00:00:00 2001 From: Rebecca Thompson <33927854+rebecca-thompson@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:57:41 +0000 Subject: [PATCH 2/7] remove outdated java 8 requirement from build.sbt --- build.sbt | 1 - 1 file changed, 1 deletion(-) diff --git a/build.sbt b/build.sbt index 3df87a47..c0fabf7f 100644 --- a/build.sbt +++ b/build.sbt @@ -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 ", packageSummary := "Atom Workshop", packageDescription := """A single place for atoms of all types""", From 8ed37f86feaa004b31d96dd9a6cc4d43524416f1 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Fri, 26 Jan 2024 11:46:16 +0000 Subject: [PATCH 3/7] Use a longer stub value for play.http.secret.key https://www.playframework.com/documentation/2.9.x/ApplicationSecret Note that as atom-workshop currently doesn't _use_ the PLAY_SESSION cookie for anything (mainly because it uses https://github.com/guardian/pan-domain-authentication for authentication) it's probably okay for play.http.secret.key to _not_ be secret (which it isn't, being in this public repo) - but it _does_ need to be long enough to satisfy the Playframework and JJWT: https://github.com/playframework/playframework/pull/10726 If atom-workshop ever _does_ use the PLAY_SESSION cookie, it should adopt https://github.com/guardian/play-secret-rotation to stay secure. --- conf/application.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/application.conf b/conf/application.conf index 1d03d65a..9685214d 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -2,7 +2,7 @@ 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" From e0e1db4a84c9002ae0e0f399ba19dbd7a3e48b0a Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Fri, 26 Jan 2024 16:23:20 +0000 Subject: [PATCH 4/7] Use play.http.parser.maxMemoryBuffer config 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 https://github.com/playframework/playframework/pull/4093 https://www.playframework.com/documentation/2.9.x/ScalaBodyParsers#Max-content-length In atom-workshop, the increased size was set to allow bigger chart atoms: https://github.com/guardian/atom-workshop/pull/272 --- conf/application.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/application.conf b/conf/application.conf index 9685214d..0a40af26 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -6,6 +6,6 @@ play.http.secret.key="Value must be >9 chars. If the PLAY_SESSION cookie is *use panda.system="atom-workshop" -parsers.text.maxLength=200kB +play.http.parser.maxMemoryBuffer=200K play.filters.headers.contentSecurityPolicy="default-src 'self' 'unsafe-eval' 'unsafe-inline' data: https: wss:" From 9f013aad5c4a52502dc2fe987646c316dd9035ef Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Fri, 26 Jan 2024 16:34:22 +0000 Subject: [PATCH 5/7] Fix application.home problem in logback config 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) See also: * https://stackoverflow.com/a/47331903 * https://github.com/guardian/ophan/blob/2ecb80da40915ce097e4a1de0e29b352b396323e/dashboard/conf/logback.xml#L16-L19 --- conf/logback.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/conf/logback.xml b/conf/logback.xml index f9368c3a..4e7fb6b6 100644 --- a/conf/logback.xml +++ b/conf/logback.xml @@ -2,12 +2,10 @@ atom-workshop - ${application.home}/logs/application.log + logs/application.log - - ${application.home}/logs/application.log.%i - + logs/application.log.%i 1 30 From 459b5bf3268294135fa6d1a742104adbecd7e0c1 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Fri, 26 Jan 2024 16:51:57 +0000 Subject: [PATCH 6/7] Fix NoSuchMethodError for DiscardingCookie Prompted by this 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) I had forgotten to update the version of Panda used - we're upgrading to Play 2.9, so we need pan-domain-auth-play_2-9. --- project/Dependencies.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 156bd020..d44a29d3 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -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.14", + "com.gu" %% "editorial-permissions-client" % "2.15", "com.gu" %% "simple-configuration-ssm" % "1.5.6", "com.gu" %% "fezziwig" % "1.6", - "com.gu" %% "pan-domain-auth-play_2-8" % "1.2.0", + "com.gu" %% "pan-domain-auth-play_2-9" % "3.0.1", "io.circe" %% "circe-parser" % "0.14.5", "net.logstash.logback" % "logstash-logback-encoder" % "6.6", "com.gu" %% "content-api-client-aws" % "0.7", From 6eee1b8debd678ab33dd4fed4ee910ef04a53859 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Fri, 26 Jan 2024 17:06:16 +0000 Subject: [PATCH 7/7] Set CI Java version to match AMI Java version (11) I'm not sure why I set the CI Java version to 17 (other than I have started using that Java version elsewhere) - but as the AMI is only `editorial-tools-focal-java11-ARM-WITH-cdk-base`, when the server tried to run code that had been compiled with Java 17, it gave an UnsupportedClassVersionError like this in the logs: play.api.UnexpectedException: Unexpected exception[RuntimeException: java.lang.UnsupportedClassVersionError: controllers/routes has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0] at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:384) --- .github/workflows/ci.yml | 2 +- project/Dependencies.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e10e29a..aea1958e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: corretto - java-version: 17 + java-version: 11 cache: sbt - name: CI yarn shell: bash diff --git a/project/Dependencies.scala b/project/Dependencies.scala index d44a29d3..3d7b4562 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -3,7 +3,7 @@ import sbt._ object Dependencies { lazy val awsVersion = "1.11.678" - lazy val atomLibVersion = "2.0.0-PREVIEW.fix-tests-under-java-17.2024-01-18T1039.b4d55b3d" + lazy val atomLibVersion = "2.0.0" lazy val jacksonVersion = "2.13.4" lazy val jacksonDatabindVersion = "2.13.4.2"