diff --git a/.gitignore b/.gitignore index b39bc31..dbdc7fa 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,8 @@ tmp .idea_modules bin .bsp + +.metals/ +.vscode/ +project/.bloop/ + diff --git a/README.md b/README.md index 0b37cc6..c6b9b87 100644 --- a/README.md +++ b/README.md @@ -33,3 +33,7 @@ NB: If an exchange rate file cannot be found, an error will be logged and a `WAR ## Testing To run the tests locally, simply run `./run_all_tests.sh` + +## License + +This code is open source software licensed under the [Apache 2.0 License]("http://www.apache.org/licenses/LICENSE-2.0.html"). diff --git a/app/uk/gov/hmrc/currencyconversion/binders/DateBinder.scala b/app/uk/gov/hmrc/currencyconversion/binders/DateBinder.scala index 170a974..2be39ae 100644 --- a/app/uk/gov/hmrc/currencyconversion/binders/DateBinder.scala +++ b/app/uk/gov/hmrc/currencyconversion/binders/DateBinder.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/config/DesCircuitBreakerProvider.scala b/app/uk/gov/hmrc/currencyconversion/config/DesCircuitBreakerProvider.scala index 5ec5675..70b61d7 100644 --- a/app/uk/gov/hmrc/currencyconversion/config/DesCircuitBreakerProvider.scala +++ b/app/uk/gov/hmrc/currencyconversion/config/DesCircuitBreakerProvider.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package uk.gov.hmrc.currencyconversion.config -import akka.actor.ActorSystem -import akka.pattern.CircuitBreaker +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.pattern.CircuitBreaker import com.google.inject.{Inject, Provider, Singleton} import play.api.Configuration diff --git a/app/uk/gov/hmrc/currencyconversion/config/HmrcModule.scala b/app/uk/gov/hmrc/currencyconversion/config/HmrcModule.scala index 33d6d62..7fef2d6 100644 --- a/app/uk/gov/hmrc/currencyconversion/config/HmrcModule.scala +++ b/app/uk/gov/hmrc/currencyconversion/config/HmrcModule.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package uk.gov.hmrc.currencyconversion.config -import akka.pattern.CircuitBreaker +import org.apache.pekko.pattern.CircuitBreaker import play.api.inject.{Binding, Module} import play.api.{Configuration, Environment} import uk.gov.hmrc.currencyconversion.workers.XrsExchangeRateRequestWorker diff --git a/app/uk/gov/hmrc/currencyconversion/connectors/HODConnector.scala b/app/uk/gov/hmrc/currencyconversion/connectors/HODConnector.scala index 4f5fd5d..fae0634 100644 --- a/app/uk/gov/hmrc/currencyconversion/connectors/HODConnector.scala +++ b/app/uk/gov/hmrc/currencyconversion/connectors/HODConnector.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package uk.gov.hmrc.currencyconversion.connectors -import akka.pattern.CircuitBreaker +import org.apache.pekko.pattern.CircuitBreaker import com.google.inject.Inject import com.google.inject.name.Named import play.api.Configuration diff --git a/app/uk/gov/hmrc/currencyconversion/connectors/HttpDate.scala b/app/uk/gov/hmrc/currencyconversion/connectors/HttpDate.scala index 48cf97c..b098058 100644 --- a/app/uk/gov/hmrc/currencyconversion/connectors/HttpDate.scala +++ b/app/uk/gov/hmrc/currencyconversion/connectors/HttpDate.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/controllers/ExchangeRateController.scala b/app/uk/gov/hmrc/currencyconversion/controllers/ExchangeRateController.scala index d76ef25..d9a8ce5 100644 --- a/app/uk/gov/hmrc/currencyconversion/controllers/ExchangeRateController.scala +++ b/app/uk/gov/hmrc/currencyconversion/controllers/ExchangeRateController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/models/ConversionRatePeriod.scala b/app/uk/gov/hmrc/currencyconversion/models/ConversionRatePeriod.scala index 9112c7d..c40d3fa 100644 --- a/app/uk/gov/hmrc/currencyconversion/models/ConversionRatePeriod.scala +++ b/app/uk/gov/hmrc/currencyconversion/models/ConversionRatePeriod.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/models/Currency.scala b/app/uk/gov/hmrc/currencyconversion/models/Currency.scala index c6de701..a56c355 100644 --- a/app/uk/gov/hmrc/currencyconversion/models/Currency.scala +++ b/app/uk/gov/hmrc/currencyconversion/models/Currency.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/models/ExchangeRate.scala b/app/uk/gov/hmrc/currencyconversion/models/ExchangeRate.scala index 91db739..90e4bfd 100644 --- a/app/uk/gov/hmrc/currencyconversion/models/ExchangeRate.scala +++ b/app/uk/gov/hmrc/currencyconversion/models/ExchangeRate.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/models/ExchangeRateObject.scala b/app/uk/gov/hmrc/currencyconversion/models/ExchangeRateObject.scala index 4489afb..d96b22e 100644 --- a/app/uk/gov/hmrc/currencyconversion/models/ExchangeRateObject.scala +++ b/app/uk/gov/hmrc/currencyconversion/models/ExchangeRateObject.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/models/ExchangeRateResult.scala b/app/uk/gov/hmrc/currencyconversion/models/ExchangeRateResult.scala index 8cc6118..c57d3ea 100644 --- a/app/uk/gov/hmrc/currencyconversion/models/ExchangeRateResult.scala +++ b/app/uk/gov/hmrc/currencyconversion/models/ExchangeRateResult.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/models/Service.scala b/app/uk/gov/hmrc/currencyconversion/models/Service.scala index fb36d00..6169850 100644 --- a/app/uk/gov/hmrc/currencyconversion/models/Service.scala +++ b/app/uk/gov/hmrc/currencyconversion/models/Service.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/repositories/ConversionRatePeriodJson.scala b/app/uk/gov/hmrc/currencyconversion/repositories/ConversionRatePeriodJson.scala index 1d6cb3d..743fad8 100644 --- a/app/uk/gov/hmrc/currencyconversion/repositories/ConversionRatePeriodJson.scala +++ b/app/uk/gov/hmrc/currencyconversion/repositories/ConversionRatePeriodJson.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/repositories/ConversionRatePeriodRepository.scala b/app/uk/gov/hmrc/currencyconversion/repositories/ConversionRatePeriodRepository.scala index 261b9e8..7e01c55 100644 --- a/app/uk/gov/hmrc/currencyconversion/repositories/ConversionRatePeriodRepository.scala +++ b/app/uk/gov/hmrc/currencyconversion/repositories/ConversionRatePeriodRepository.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/repositories/ExchangeRateRepository.scala b/app/uk/gov/hmrc/currencyconversion/repositories/ExchangeRateRepository.scala index 1337939..17f2ac0 100644 --- a/app/uk/gov/hmrc/currencyconversion/repositories/ExchangeRateRepository.scala +++ b/app/uk/gov/hmrc/currencyconversion/repositories/ExchangeRateRepository.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/services/ExchangeRateService.scala b/app/uk/gov/hmrc/currencyconversion/services/ExchangeRateService.scala index 4e10e96..6090a91 100644 --- a/app/uk/gov/hmrc/currencyconversion/services/ExchangeRateService.scala +++ b/app/uk/gov/hmrc/currencyconversion/services/ExchangeRateService.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/utils/MongoIdHelper.scala b/app/uk/gov/hmrc/currencyconversion/utils/MongoIdHelper.scala index b7c68f1..2789b64 100644 --- a/app/uk/gov/hmrc/currencyconversion/utils/MongoIdHelper.scala +++ b/app/uk/gov/hmrc/currencyconversion/utils/MongoIdHelper.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/workers/XrsDelayHelper.scala b/app/uk/gov/hmrc/currencyconversion/workers/XrsDelayHelper.scala index 7592fb5..8964b7b 100644 --- a/app/uk/gov/hmrc/currencyconversion/workers/XrsDelayHelper.scala +++ b/app/uk/gov/hmrc/currencyconversion/workers/XrsDelayHelper.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/uk/gov/hmrc/currencyconversion/workers/XrsExchangeRateRequestWorker.scala b/app/uk/gov/hmrc/currencyconversion/workers/XrsExchangeRateRequestWorker.scala index 4076da7..71d5916 100644 --- a/app/uk/gov/hmrc/currencyconversion/workers/XrsExchangeRateRequestWorker.scala +++ b/app/uk/gov/hmrc/currencyconversion/workers/XrsExchangeRateRequestWorker.scala @@ -1,5 +1,5 @@ /* - * Copyright 2023 HM Revenue & Customs + * Copyright 2024 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,9 @@ package uk.gov.hmrc.currencyconversion.workers -import akka.stream.scaladsl.{Keep, Sink, SinkQueueWithCancel, Source} -import akka.stream.{ActorAttributes, Materializer, Supervision} import com.google.inject.{Inject, Singleton} +import org.apache.pekko.stream.scaladsl.{Keep, Sink, SinkQueueWithCancel, Source} +import org.apache.pekko.stream.{ActorAttributes, Materializer, Supervision} import play.api.Configuration import play.api.http.Status.SERVICE_UNAVAILABLE import play.api.i18n.Lang.logger.logger diff --git a/build.sbt b/build.sbt index 2a8c2de..ec3657d 100644 --- a/build.sbt +++ b/build.sbt @@ -1,10 +1,13 @@ val appName = "currency-conversion" +ThisBuild / majorVersion := 1 +ThisBuild / scalaVersion := "2.13.12" + lazy val microservice = Project(appName, file(".")) - .enablePlugins(play.sbt.PlayScala, SbtDistributablesPlugin) + .enablePlugins(PlayScala, SbtDistributablesPlugin) + .disablePlugins(JUnitXmlReportPlugin) + .settings(CodeCoverageSettings.settings) .settings( - // To resolve a bug with version 2.x.x of the scoverage plugin - https://github.com/sbt/sbt/issues/6997 - libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always, libraryDependencies ++= AppDependencies(), scalacOptions ++= Seq( "-feature", @@ -14,17 +17,10 @@ lazy val microservice = Project(appName, file(".")) "-language:postfixOps" ) ) - .settings(scalaVersion := "2.13.12") - .settings(majorVersion := 1) .settings( routesImport ++= Seq("uk.gov.hmrc.currencyconversion.binders.DateBinder._", "java.time._") ) - .settings( - coverageExcludedFiles := ";.*Routes.*;", - coverageMinimumStmtTotal := 96, - coverageFailOnMinimum := true - ) .settings(PlayKeys.playDefaultPort := 9016) addCommandAlias("scalafmtAll", "all scalafmtSbt scalafmt Test/scalafmt") -addCommandAlias("scalastyleAll", "all scalastyle Test/scalastyle") +addCommandAlias("scalastyleAll", "all scalastyle Test/scalastyle ") diff --git a/conf/application.conf b/conf/application.conf index e60a7d9..e29b1b5 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -1,4 +1,4 @@ -# Copyright 2023 HM Revenue & Customs +# Copyright 2024 HM Revenue & Customs # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/conf/prod.routes b/conf/prod.routes index d81968f..5eb7aa4 100644 --- a/conf/prod.routes +++ b/conf/prod.routes @@ -1,5 +1,3 @@ # Add all the application routes to the app.routes file -> /currency-conversion app.Routes -> / health.Routes - -GET /admin/metrics com.kenshoo.play.metrics.MetricsController.metrics diff --git a/conf/testOnlyDoNotUseInAppConf.routes b/conf/testOnlyDoNotUseInAppConf.routes deleted file mode 100644 index b98c783..0000000 --- a/conf/testOnlyDoNotUseInAppConf.routes +++ /dev/null @@ -1,13 +0,0 @@ -# IF THE MICRO-SERVICE DOES NOT NEED ANY TEST-ONLY END-POINTS (ALWAYS PREFERRED) DELETE THIS FILE. - -# !!!WARNING!!! This file MUST NOT be referenced in the "application.conf" file to avoid risk of rolling test routes in the production environment. -# If you need test routes when running tests in CI make sure that the profile for this micro-service (used by service-manager) defines this router as parameter. -# To do so add the following line to the micro-service profile: "-Dapplication.router=testOnlyDoNotUseInAppConf.Routes" -# To start the micro-service locally using the test routes run the following command: "sbt run -Dapplication.router=testOnlyDoNotUseInAppConf.Routes" - -# Any test-only end-point should be defined here. -# !!!WARNING!!! Every route defined in this file MUST be prefixed with "/test-only/". This is because NGINX is blocking every uri containing the string "test-only" in production. -# Failing to follow this rule may result in test routes deployed in production. - -# Add all the application routes to the prod.routes file --> / prod.Routes diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala index 96c935b..8384751 100644 --- a/project/AppDependencies.scala +++ b/project/AppDependencies.scala @@ -2,20 +2,18 @@ import sbt.* object AppDependencies { - private lazy val bootstrapPlayVersion = "7.23.0" - private lazy val hmrcMongoVersion = "1.6.0" + private lazy val bootstrapPlayVersion = "8.4.0" + private lazy val hmrcMongoVersion = "1.7.0" private lazy val compile: Seq[ModuleID] = Seq( - "uk.gov.hmrc" %% "bootstrap-backend-play-28" % bootstrapPlayVersion, - "uk.gov.hmrc.mongo" %% "hmrc-mongo-play-28" % hmrcMongoVersion + "uk.gov.hmrc" %% "bootstrap-backend-play-30" % bootstrapPlayVersion, + "uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % hmrcMongoVersion ) private lazy val test: Seq[ModuleID] = Seq( - "uk.gov.hmrc" %% "bootstrap-test-play-28" % bootstrapPlayVersion, - "uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-28" % hmrcMongoVersion, - "org.scalatest" %% "scalatest" % "3.2.17", - "org.mockito" %% "mockito-scala-scalatest" % "1.17.30", - "com.vladsch.flexmark" % "flexmark-all" % "0.64.8" + "uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapPlayVersion, + "uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-30" % hmrcMongoVersion, + "org.mockito" %% "mockito-scala-scalatest" % "1.17.30" ).map(_ % Test) def apply(): Seq[ModuleID] = compile ++ test diff --git a/project/CodeCoverageSettings.scala b/project/CodeCoverageSettings.scala new file mode 100644 index 0000000..77a8f00 --- /dev/null +++ b/project/CodeCoverageSettings.scala @@ -0,0 +1,12 @@ +import sbt.Setting +import scoverage.ScoverageKeys.* + +object CodeCoverageSettings { + + val settings: Seq[Setting[?]] = Seq( + coverageExcludedFiles := ";.*Routes.*;", + coverageMinimumStmtTotal := 96, + coverageFailOnMinimum := true, + coverageHighlighting := true + ) +} diff --git a/project/build.properties b/project/build.properties index 8b9a0b0..e8a1e24 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.0 +sbt.version=1.9.7 diff --git a/project/plugins.sbt b/project/plugins.sbt index 6401840..1f255f5 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,14 +3,10 @@ resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefact Resolver.ivyStylePatterns ) -// To resolve a bug with version 2.x.x of the scoverage plugin - https://github.com/sbt/sbt/issues/6997 -// Try to remove when sbt 1.8.0+ and scoverage is 2.0.7+ -ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always - -addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.15.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.20.0") addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.4.0") -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.21") -addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "1.0.0") +addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.1") +addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "1.0.0" exclude ("org.scala-lang.modules", "scala-xml_2.12")) addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") diff --git a/scalastyle-config.xml b/scalastyle-config.xml index 94d6891..3827d10 100644 --- a/scalastyle-config.xml +++ b/scalastyle-config.xml @@ -9,7 +9,7 @@