Skip to content

Commit

Permalink
APIS-6903: Subprojects for integration and component tests (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsgp authored Mar 6, 2024
1 parent 43c244c commit f51d308
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version="3.5.3"
version="3.7.17"
runner.dialect = "scala213"

maxColumn = 180
Expand Down
58 changes: 31 additions & 27 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import uk.gov.hmrc.DefaultBuildSettings.integrationTestSettings
import uk.gov.hmrc.DefaultBuildSettings
import uk.gov.hmrc.DefaultBuildSettings._

val appName = "api-platform-outbound-soap"

val silencerVersion = "1.7.9"

scalaVersion := "2.13.12"
Global / bloopAggregateSourceDependencies := true
Global / bloopExportJarClassifiers := Some(Set("sources"))

ThisBuild / scalaVersion := "2.13.12"
ThisBuild / majorVersion := 0
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
Expand All @@ -14,35 +16,37 @@ lazy val microservice = Project(appName, file("."))
.enablePlugins(PlayScala, SbtDistributablesPlugin)
.disablePlugins(JUnitXmlReportPlugin)
.settings(
majorVersion := 0,
PlayKeys.playDefaultPort := 6703,
libraryDependencies ++= AppDependencies.compile ++ AppDependencies.test,
dependencyOverrides ++= AppDependencies.axiomOverrides,
PlayKeys.playDefaultPort := 6703,
libraryDependencies ++= AppDependencies(),
dependencyOverrides ++= AppDependencies.axiomOverrides,
retrieveManaged := true,
// https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html
// suppress warnings in generated routes files
scalacOptions += "-Wconf:src=routes/.*:s"
)
.settings(ScoverageSettings())
.configs(IntegrationTest)
.settings(integrationTestSettings(): _*)
.settings(scalafixConfigSettings(IntegrationTest))
.settings(
IntegrationTest / unmanagedResourceDirectories += baseDirectory.value / "test" / "resources"
)
.settings(
Compile / unmanagedResourceDirectories += baseDirectory.value / "app" / "resources"
Compile / unmanagedResourceDirectories += baseDirectory.value / "app" / "resources",
Test / unmanagedResourceDirectories += baseDirectory.value / "test" / "resources"
)

lazy val it = (project in file("it"))
.enablePlugins(PlayScala)
.dependsOn(microservice % "test->test")
.settings(
scalacOptions ++= Seq(
"-Wconf:cat=unused&src=views/.*\\.scala:s",
"-Wconf:cat=unused&src=.*RoutesPrefix\\.scala:s",
"-Wconf:cat=unused&src=.*Routes\\.scala:s",
"-Wconf:cat=unused&src=.*ReverseRoutes\\.scala:s"
)
name := "integration-tests",
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-eT"),
DefaultBuildSettings.itSettings(),
addTestReportOption(Test, "int-test-reports")
)

commands ++= Seq(
Command.command("run-all-tests") { state => "test" :: "it:test" :: state },

Command.command("clean-and-test") { state => "clean" :: "compile" :: "run-all-tests" :: state },

// Coverage does not need compile !
Command.command("pre-commit") { state => "clean" :: "scalafmtAll" :: "scalafixAll" :: "coverage" :: "run-all-tests" :: "coverageOff" :: "coverageAggregate" :: state }
Command.command("cleanAll") { state => "clean" :: "it/clean" :: state },
Command.command("fmtAll") { state => "scalafmtAll" :: "it/scalafmtAll" :: state },
Command.command("fixAll") { state => "scalafixAll" :: "it/scalafixAll" :: state },
Command.command("testAll") { state => "test" :: "it/test" :: state },

Command.command("run-all-tests") { state => "testAll" :: state },
Command.command("clean-and-test") { state => "cleanAll" :: "compile" :: "run-all-tests" :: state },
Command.command("pre-commit") { state => "cleanAll" :: "fmtAll" :: "fixAll" :: "coverage" :: "testAll" :: "coverageOff" :: "coverageAggregate" :: state }
)
16 changes: 9 additions & 7 deletions project/AppDependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ object AppDependencies {
val bootstrapPlayVersion = "8.4.0"
val mongoVersion = "1.7.0"

def apply(): Seq[ModuleID] = compile ++ test

val compile = Seq(
"uk.gov.hmrc" %% "bootstrap-backend-play-30" % bootstrapPlayVersion,
"uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % mongoVersion,
"org.apache.pekko" %% "pekko-connectors-mongodb" % "1.0.2",
"org.apache.axis2" % "axis2-kernel" % "1.8.0",
"org.apache.wss4j" % "wss4j-ws-security-dom" % "2.4.1",
"org.apache.axis2" % "axis2-kernel" % "1.8.2",
"org.apache.wss4j" % "wss4j-ws-security-dom" % "2.4.3",
caffeine
)

val test = Seq(
"uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapPlayVersion % "test, it",
"org.mockito" %% "mockito-scala-scalatest" % "1.17.29" % "test, it",
"org.xmlunit" % "xmlunit-core" % "2.9.0" % "test, it",
"uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-30" % mongoVersion % "it"
)
"uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapPlayVersion,
"org.mockito" %% "mockito-scala-scalatest" % "1.17.30",
"org.xmlunit" % "xmlunit-core" % "2.9.0",
"uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-30" % mongoVersion
).map(_ % "test")

val axiomVersion = "1.4.0"
val axiomOverrides = Seq(
Expand Down
25 changes: 10 additions & 15 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
resolvers ++= Seq(
Resolver.url("HMRC-open-artefacts-ivy", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns),
"hmrc-releases" at "https://artefacts.tax.service.gov.uk/artifactory/hmrc-releases/",
"third-party-maven-releases" at "https://artefacts.tax.service.gov.uk/artifactory/third-party-maven-releases/",
"HMRC-open-artefacts-maven" at "https://open.artefacts.tax.service.gov.uk/maven2")

resolvers += MavenRepository("HMRC-open-artefacts-maven2", "https://open.artefacts.tax.service.gov.uk/maven2")
resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns)
resolvers += Resolver.typesafeRepo("releases")

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.20.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0")
addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")

addDependencyTreePlugin
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.20.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0")
addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")
addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "1.0.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.15")

ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always

0 comments on commit f51d308

Please sign in to comment.