Skip to content

Commit

Permalink
Add sbt-scoverage settings (#30)
Browse files Browse the repository at this point in the history
* Upgrade to latest sbt-auto-build plugin

* Add scoverage settings

* Update README file with sbt-scoverage instructions
  • Loading branch information
pangiole-hmrc authored Feb 21, 2022
1 parent 770d566 commit 46406be
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
emailaddress
==================
#emailaddress

[![Join the chat at https://gitter.im/hmrc/emailaddress](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/hmrc/emailaddress?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/hmrc/emailaddress.svg?branch=master)](https://travis-ci.org/hmrc/emailaddress) [ ![Download](https://api.bintray.com/packages/hmrc/releases/emailaddress/images/download.svg) ](https://bintray.com/hmrc/releases/emailaddress/_latestVersion)

Expand Down Expand Up @@ -113,6 +112,22 @@ resolvers += Resolver.bintrayRepo("hmrc", "releases")
libraryDependencies += "uk.gov.hmrc" %% "emailaddress" % "<INSERT VERSION>"
```

## Run the tests and sbt fmt before raising a PR

Format:

`sbt fmt`

Then run the tests and coverage report:

`sbt clean coverage test coverageReport`

If your build fails due to poor test coverage, *DO NOT* lower the test coverage threshold, instead inspect the generated report located here on your local repo: `/target/scala-2.12/scoverage-report/index.html`

Then run the integration tests:

`sbt it:test`

## License ##

This code is open source software licensed under the [Apache 2.0 License]("http://www.apache.org/licenses/LICENSE-2.0.html").
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
val appName = "emailaddress"

lazy val emailaddress = Project(appName, file("."))
.enablePlugins(SbtAutoBuildPlugin, SbtGitVersioning, SbtArtifactory)
.settings(majorVersion := 3)
.settings(makePublicallyAvailableOnBintray := true)
.settings(isPublicArtefact := true)
.settings(ScoverageSettings.apply(): _*)
.settings(
scalacOptions ++= Seq(
"-feature",
Expand Down
32 changes: 32 additions & 0 deletions project/ScoverageSettings.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2021 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import sbt.Keys.parallelExecution
import sbt._
import scoverage.ScoverageKeys

object ScoverageSettings {
def apply(): Seq[Def.Setting[_ >: String with Double with Boolean]] =
Seq(
// Semicolon-separated list of regexes matching classes to exclude
ScoverageKeys.coverageExcludedPackages := "<empty>;.*Reverse.*;.*(config|testonly).*;.*(BuildInfo|Routes).*",
// TODO Use the ScoverageKeys.coverageMinimumStmtTotal if sbt-scoverage plugin is version 1.9.x
ScoverageKeys.coverageMinimum := 97.00,
ScoverageKeys.coverageFailOnMinimum := true,
ScoverageKeys.coverageHighlighting := true,
parallelExecution in ConfigKey.configurationToKey(Test) := false
)
}
10 changes: 4 additions & 6 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
resolvers += Resolver.url("HMRC Sbt Plugin Releases", url("https://dl.bintray.com/hmrc/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
resolvers += "HMRC Releases" at "https://dl.bintray.com/hmrc/releases"
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)

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "1.16.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "1.19.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-artifactory" % "0.20.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.0.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")

0 comments on commit 46406be

Please sign in to comment.