From 533f6608e8b7e67a3d242d55378cc8ec085d1b89 Mon Sep 17 00:00:00 2001 From: Roberto Tyley <52038+rtyley@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:28:21 +0100 Subject: [PATCH] Add Prout to know when PRs are deployed or overdue Adds [Prout](https://www.theguardian.com/info/developer-blog/2015/feb/03/prout-is-your-pull-request-out), to let us know when our changes don't ship as expected, or when they are ready to check in Production! This PR uses https://github.com/guardian/permissions/pull/174 as a recent example of adding Prout, other examples include: * https://github.com/guardian/typerighter/pull/465 * https://github.com/guardian/dotcom-rendering/pull/9692 --- .prout.json | 5 +++++ app/controllers/Management.scala | 4 +++- build.sbt | 9 ++++++++- conf/routes | 1 + project/plugins.sbt | 2 ++ 5 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .prout.json diff --git a/.prout.json b/.prout.json new file mode 100644 index 00000000..2fcf696b --- /dev/null +++ b/.prout.json @@ -0,0 +1,5 @@ +{ + "checkpoints": { + "PROD": { "url": "https://tagmanager.gutools.co.uk/management/healthcheck", "overdue": "30M" } + } +} diff --git a/app/controllers/Management.scala b/app/controllers/Management.scala index 5ee6b97b..b10d0e88 100644 --- a/app/controllers/Management.scala +++ b/app/controllers/Management.scala @@ -1,5 +1,6 @@ package controllers +import com.gu.tagmanager.BuildInfo import play.api.Logging import play.api.libs.ws.WSClient import play.api.mvc.{BaseController, ControllerComponents} @@ -16,8 +17,9 @@ class Management( extends BaseController with Logging { + def manifest = Action { _ => Ok(BuildInfo.toJson) } + def healthCheck = Action { Ok("OK") } - } diff --git a/build.sbt b/build.sbt index f02af4b5..1357eec4 100644 --- a/build.sbt +++ b/build.sbt @@ -48,7 +48,7 @@ lazy val dependencies = Seq( dependencyOverrides += "org.bouncycastle" % "bcprov-jdk15on" % "1.67" -lazy val root = (project in file(".")).enablePlugins(PlayScala, SbtWeb, JDebPackaging, SystemdPlugin) +lazy val root = (project in file(".")).enablePlugins(PlayScala, SbtWeb, JDebPackaging, SystemdPlugin, BuildInfoPlugin) .settings(Defaults.coreDefaultSettings: _*) .settings( playDefaultPort := 8247, @@ -67,6 +67,13 @@ lazy val root = (project in file(".")).enablePlugins(PlayScala, SbtWeb, JDebPack scalaVersion := scalaVer, ThisBuild / scalaVersion := scalaVer, libraryDependencies ++= dependencies, + buildInfoKeys := Seq( + name, + BuildInfoKey.sbtbuildinfoConstantEntry("buildTime", System.currentTimeMillis), + "gitCommitId" -> Option(System.getenv("GITHUB_SHA")).getOrElse("Unknown") + ), + buildInfoPackage := "com.gu.tagmanager", + buildInfoOptions := Seq(BuildInfoOption.ToJson), gzip / includeFilter := "*.html" || "*.css" || "*.js", pipelineStages := Seq(digest, gzip), diff --git a/conf/routes b/conf/routes index 6b91d076..37f3b7f0 100644 --- a/conf/routes +++ b/conf/routes @@ -106,6 +106,7 @@ GET /reauth controlle # Management +anyhost +GET /management/manifest controllers.Management.manifest() GET /management/healthcheck controllers.Management.healthCheck # Map static resources from the /public folder to the /assets URL path diff --git a/project/plugins.sbt b/project/plugins.sbt index 0db6a98f..5f8ec782 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,6 +7,8 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.3") addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.2") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0") + // need to add jdeb dependency explicitly because https://github.com/sbt/sbt-native-packager/issues/1053 libraryDependencies += "org.vafer" % "jdeb" % "1.3" artifacts (Artifact("jdeb", "jar", "jar"))