Skip to content

Commit

Permalink
Merge pull request #56 from guardian/mm-update-to-213
Browse files Browse the repository at this point in the history
Use scala 2.13 as scalaVersion
  • Loading branch information
michaelwmcnamara authored Nov 22, 2021
2 parents 9703644 + 29552d4 commit 4b441cc
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension
import com.vladsch.flexmark.ext.tables.TablesExtension
import com.vladsch.flexmark.html.HtmlRenderer
import com.vladsch.flexmark.parser.Parser
import com.vladsch.flexmark.util.options.MutableDataSet
import com.vladsch.flexmark.util.data.MutableDataSet
import io.circe.Json

import scala.collection.JavaConverters._

import scala.jdk.CollectionConverters._
import scala.collection.compat._

object Messages {
private[anghammarad] val mdOptions = new MutableDataSet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import com.gu.anghammarad.Enrichments._
import com.gu.anghammarad.models._
import io.circe._
import io.circe.parser._

import scala.collection.JavaConverters._
import scala.util.{Success, Try}
import scala.jdk.CollectionConverters._
import scala.collection.compat._


object Serialization {
def parseConfig(config: String): Try[Configuration] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import com.gu.anghammarad.Contacts._
import com.gu.anghammarad.models._
import com.gu.anghammarad.serialization.Serialization
import com.gu.anghammarad.testutils.TryValues
import org.scalatest.{FreeSpec, Matchers}
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers

import scala.io.Source


class ContactsTest extends FreeSpec with Matchers with TryValues {
class ContactsTest extends AnyFreeSpec with Matchers with TryValues {
val email = EmailMessage("subject", "text", "html")
val emailAddress = EmailAddress("[email protected]")
val hangoutMessage = HangoutMessage("json")
Expand Down
10 changes: 6 additions & 4 deletions anghammarad/src/test/scala/com/gu/anghammarad/MessagesTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import com.gu.anghammarad.messages.Messages._
import com.gu.anghammarad.messages.{HangoutsService, Messages}
import com.gu.anghammarad.models._
import io.circe.parser._
import org.scalatest.{EitherValues, FreeSpec, Matchers}
import org.scalatest.EitherValues
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers

import scala.util.{Failure, Success}


class MessagesTest extends FreeSpec with Matchers with EitherValues {
class MessagesTest extends AnyFreeSpec with Matchers with EitherValues {
"emailMessage" - {
"plain text" - {
"sets the subject" in {
Expand Down Expand Up @@ -123,7 +125,7 @@ class MessagesTest extends FreeSpec with Matchers with EitherValues {

"includes buttons for actions" in {
val message = hangoutMessage(notification)
val json = parse(message.cardJson).right.value
val json = parse(message.cardJson).value
json.\\("textButton") should have length 2
}

Expand Down Expand Up @@ -152,7 +154,7 @@ class MessagesTest extends FreeSpec with Matchers with EitherValues {

"does not include buttons widgets at all" in {
val message = hangoutMessage(notification)
val json = parse(message.cardJson).right.value
val json = parse(message.cardJson).value
json.\\("buttons") shouldBe empty
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.gu.anghammarad

import com.gu.anghammarad.models._
import org.scalatest.{FreeSpec, Matchers}
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers


class TargetsTest extends FreeSpec with Matchers {
class TargetsTest extends AnyFreeSpec with Matchers {
import com.gu.anghammarad.Targets._

"normaliseStages" - {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ import com.amazonaws.services.lambda.runtime.events.SNSEvent.SNSRecord
import com.gu.anghammarad.models._
import io.circe.Json
import io.circe.parser._
import org.scalatest.{EitherValues, FreeSpec, Matchers}

import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers
import com.gu.anghammarad.testutils.TryValues
import org.scalatest.EitherValues

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.collection.compat._
import scala.io.Source

class SerializationTest extends FreeSpec with Matchers with EitherValues with TryValues {

class SerializationTest extends AnyFreeSpec with Matchers with EitherValues with TryValues {

"Notification Serialization" - {
val validJsonString = Source.fromURL(getClass.getResource("/notification.json")).mkString
val validJson = parse(validJsonString).right.value
val validJson = parse(validJsonString).value

val expectedResult = Notification(
"GNU Terry Pratchett",
Expand Down Expand Up @@ -63,7 +66,7 @@ class SerializationTest extends FreeSpec with Matchers with EitherValues with Tr
"will return a failure if the json is missing any required information" in {
val testJson = parse(
"""{"sender": "Terry Pratchett","target": {"Stack": "postal-service"}}"""
).right.value
).value
Serialization.generateNotification("GNU Terry Pratchett", testJson).isFailure shouldEqual true
}
}
Expand All @@ -87,15 +90,15 @@ class SerializationTest extends FreeSpec with Matchers with EitherValues with Tr
"will correct parse an action from valid json" in {
val testJson = parse(
"""{"cta": "keep that name moving in the Overhead","url": "http://www.gnuterrypratchett.com/"}"""
).right.value
).value

Serialization.parseAction(testJson).success shouldEqual Action("keep that name moving in the Overhead", "http://www.gnuterrypratchett.com/")
}

"will return a failure if either the cta or the url is unavailable" in {
val testJson = parse(
"""{"cta": "keep that name moving in the Overhead"}"""
).right.value
).value

Serialization.parseAction(testJson).isFailure shouldEqual true
}
Expand Down Expand Up @@ -136,7 +139,7 @@ class SerializationTest extends FreeSpec with Matchers with EitherValues with Tr
"will parse valid json into a complete mapping" in {
val testJson = parse(
"""{"target":{"AwsAccount":"123456789"},"contacts":{"email":"awsAccount.email"}}"""
).right.value
).value

Serialization.parseMapping(testJson).success shouldEqual Mapping(List(AwsAccount("123456789")), List(EmailAddress("awsAccount.email")))
}
Expand All @@ -157,22 +160,22 @@ class SerializationTest extends FreeSpec with Matchers with EitherValues with Tr
"will correctly return the contacts" in {
val testJson = parse(
"""{"email":"stack.email","hangouts":"stack.room"}"""
).right.value
).value

Serialization.parseAllContacts(testJson).success shouldEqual List(EmailAddress("stack.email"), HangoutsRoom("stack.room"))
}

"will return a failure if it cannot parse the keys" in {
val testJson = parse(
"""{"email":"stack.email","xhangouts":"stack.room"}"""
).right.value
).value
Serialization.parseAllContacts(testJson).isFailure shouldEqual true
}

"will return a failure if there are no contacts listed" in {
val testJson = parse(
"""{}"""
).right.value
).value
Serialization.parseAllContacts(testJson).isFailure shouldEqual true
}
}
Expand All @@ -194,21 +197,21 @@ class SerializationTest extends FreeSpec with Matchers with EitherValues with Tr
"will correctly return the targets" in {
val testJson: Json = parse(
"""{"Stack":"stack-1","App":"app-1"}"""
).right.value
).value
Serialization.parseAllTargets(testJson).success shouldEqual List(Stack("stack-1"), App("app-1"))
}

"will return a failure if it cannot parse the keys" in {
val testJson = parse(
"""{"Stack":"stack-1","xApp":"app-1"}"""
).right.value
).value
Serialization.parseAllTargets(testJson).isFailure shouldEqual true
}

"will return a failure if there are no targets listed" in {
val testJson = parse(
"""{}"""
).right.value
).value
Serialization.parseAllTargets(testJson).isFailure shouldEqual true
}
}
Expand Down
35 changes: 18 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ val compilerOptions = Seq(
)

inThisBuild(Seq(
scalaVersion := "2.12.4",
crossScalaVersions := Seq("2.11.12", scalaVersion.value),
scalaVersion := "2.13.2",
crossScalaVersions := Seq("2.11.8", "2.12.4", scalaVersion.value),
scalacOptions ++= Seq(
"-deprecation",
"-Xfatal-warnings",
Expand All @@ -18,7 +18,7 @@ inThisBuild(Seq(
),
// sonatype metadata
organization := "com.gu",
licenses := Seq("Apache V2" -> url("http://www.apache.org/licenses/LICENSE-2.0.html")),
licenses := Seq("Apache V2" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")),
scmInfo := Some(
ScmInfo(
url("https://github.com/guardian/anghammarad"),
Expand All @@ -31,8 +31,8 @@ inThisBuild(Seq(
)
))

val awsSdkVersion = "1.11.258"
val circeVersion = "0.9.1"
val awsSdkVersion = "1.11.759"
val circeVersion = "0.12.0-M3"

//Projects

Expand All @@ -53,7 +53,7 @@ lazy val common = project
name := "anghammarad-common",
// publish settings
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
publishTo := sonatypePublishTo.value
publishTo := sonatypePublishTo.value,
)

lazy val client = project
Expand All @@ -63,33 +63,34 @@ lazy val client = project
libraryDependencies ++= Seq(
"com.amazonaws" % "aws-java-sdk-sns" % awsSdkVersion,
"org.json" % "json" % "20180130",
"com.typesafe.scala-logging" %% "scala-logging" % "3.8.0",
"org.scalatest" %% "scalatest" % "3.0.5" % Test
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.4",
"org.scalatest" %% "scalatest" % "3.2.9" % Test
),
// publish settings
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
publishTo := sonatypePublishTo.value
publishTo := sonatypePublishTo.value,
)

lazy val anghammarad = project
.enablePlugins(JavaAppPackaging, RiffRaffArtifact)
.enablePlugins(JavaAppPackaging, RiffRaffArtifact, ScalafixPlugin)
.dependsOn(common)
.settings(
name := "anghammarad",
libraryDependencies ++= Seq(
"com.amazonaws" % "aws-lambda-java-events" % "1.3.0",
"com.amazonaws" % "aws-lambda-java-core" % "1.1.0",
"org.scala-lang.modules" %% "scala-collection-compat" % "2.6.0",
"com.amazonaws" % "aws-lambda-java-events" % "3.10.0",
"com.amazonaws" % "aws-lambda-java-core" % "1.2.1",
"com.amazonaws" % "aws-java-sdk-lambda" % awsSdkVersion,
"com.amazonaws" % "aws-java-sdk-ses" % awsSdkVersion,
"com.amazonaws" % "aws-java-sdk-s3" % awsSdkVersion,
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
"com.softwaremill.sttp.client3" %% "core" % "3.3.16",
"com.vladsch.flexmark" % "flexmark-all" % "0.32.18",
"com.typesafe.scala-logging" %% "scala-logging" % "3.8.0",
"ch.qos.logback" % "logback-classic" % "1.1.7",
"org.scalatest" %% "scalatest" % "3.0.5" % Test
"com.vladsch.flexmark" % "flexmark-all" % "0.50.50",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.4",
"ch.qos.logback" % "logback-classic" % "1.2.6",
"org.scalatest" %% "scalatest" % "3.2.9" % Test
),
skip in publish := true,
assemblyJarName := s"${name.value}.jar",
Expand All @@ -104,7 +105,7 @@ lazy val dev = project
.settings(
name := "dev",
libraryDependencies ++= Seq(
"com.github.scopt" %% "scopt" % "3.7.0"
"com.github.scopt" %% "scopt" % "4.0.1"
),
skip in publish := true
)
Expand Down
5 changes: 3 additions & 2 deletions client/src/test/scala/com/gu/anghammarad/JsonTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package com.gu.anghammarad

import com.gu.anghammarad.Json._
import com.gu.anghammarad.models._
import org.scalatest.{FreeSpec, Matchers}
import org.scalatest.matchers.should.Matchers
import org.scalatest.freespec.AnyFreeSpec


class JsonTest extends FreeSpec with Matchers {
class JsonTest extends AnyFreeSpec with Matchers {
"targetJson" - {
"produces valid JSON for a Stack" in {
targetJson(List(Stack("stack"))) shouldEqual """{"Stack":"stack"}"""
Expand Down
4 changes: 2 additions & 2 deletions dev/src/main/scala/com/gu/anghammarad/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object Main {
case s: Specified =>
Fail("No channel provided")
case InitialArgs =>
argParser.showUsageAsError()
argParser.showUsageOnError
Fail("No arguments provided, cannot make a notification")
}
}
Expand All @@ -63,7 +63,7 @@ object Main {
case Specified(_, _, _, _, _, _, configStage) =>
Success(configStage)
case InitialArgs =>
argParser.showUsageAsError()
argParser.showUsageOnError
Fail("No arguments provided, cannot obtain a configuration stage")
}
}
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.1.1
sbt.version=1.5.3
14 changes: 8 additions & 6 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.12")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0")

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

addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.8")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.10")

addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.32")
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "1.1.3-SNAPSHOT"
version in ThisBuild := "1.2.0"

0 comments on commit 4b441cc

Please sign in to comment.