Skip to content

Commit

Permalink
feat(mercury): Add plugin sbt-scoverage (#133)
Browse files Browse the repository at this point in the history
Update scala version to 3.2.1 and/or 3.2.2-RC1-bin-20221026-a210b7f-NIGHTLY
Add plugin sbt-scoverage (version 2.0.6)
Update sbt-native-packager version to 1.9.11
Enable plugins if certain environment variables are define
Add env to the github workflaws
ci(mercury): add code coverage report publishing
ci(mercury): test another action for coverage
ci(mercury): add min coverage as 10 for now
ci(mercury): set min to 1% for now
ci(mercury): dont fail ci if coverage is less than min

Co-authored-by: Anton Baliasnikov <anton.baliasnikov@iohk.io>
  • Loading branch information
FabioPinheiro and Anton Baliasnikov committed Nov 17, 2022
1 parent 93b33a8 commit fcaaeda
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 15 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/mercury.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ on:

env:
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
SBT_PACKAGER: "enable" #just to test it loads
SBT_SCOVERAGE: "enable"

defaults:
run:
Expand Down Expand Up @@ -49,14 +51,30 @@ jobs:
sbt scalafmtCheckAll
- name: Build and test Mercury
run: sbt test
run: SBT_SCOVERAGE=enable sbt clean coverage test coverageAggregate

- name: Aggregate test reports
if: always()
uses: ./.github/actions/aggregate-test-reports
with:
tests-dir: "mercury/mercury-library"

- name: Code coverage report
if: always()
uses: 5monkeys/cobertura-action@master
with:
path: "mercury/mercury-library/target/coverage/coverage-report/cobertura.xml"
report_name: "Mercury Code Coverage"
minimum_coverage: 10
fail_below_threshold: false

- name: Artifact coverage HTML
uses: actions/upload-artifact@v2
if: always()
with:
name: code-coverage-report-mercury
path: "mercury/mercury-library/target/coverage/scoverage-report"

- name: Publish test results
# Publish even if the test step fails
if: always()
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SBT_PACKAGER: "enable" # To enable the packager plugin on Mercury

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
38 changes: 25 additions & 13 deletions mercury/mercury-library/build.sbt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._
val SCALA_VERSION = sys.env.get("SBT_SCOVERAGE") match {
case None => "3.2.1"
case Some(_) => "3.2.2-RC1-bin-20221026-a210b7f-NIGHTLY" // Needed for sbt-scoverage
}

inThisBuild(
Seq(
organization := "io.iohk.atala",
scalaVersion := "3.2.0",
scalaVersion := SCALA_VERSION,
fork := true,
run / connectInput := true,
releaseUseGlobalVersion := false,
versionScheme := Some("semver-spec"),
githubOwner := "input-output-hk",
githubRepository := "atala-prism-building-blocks",
githubTokenSource := TokenSource.Environment("GITHUB_TOKEN")
githubRepository := "atala-prism-building-blocks"
)
)

Expand Down Expand Up @@ -69,6 +71,8 @@ lazy val D = new {

publish / skip := true

coverageDataDir := target.value / "coverage"

// #########################
// ### Models & Services ###
// #########################
Expand Down Expand Up @@ -245,12 +249,20 @@ lazy val agentDidScala =
.dependsOn(agent)

// ### ReleaseStep ###
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
publishArtifacts,
setNextVersion
)
sys.env
.get("SBT_SCOVERAGE") // SEE also plugin.sbt
.map { _ =>
println("### Config sbt-scoverage (releaseProcess) ###")
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._

releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
publishArtifacts,
setNextVersion
)
}
.toSeq
23 changes: 22 additions & 1 deletion mercury/mercury-library/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9") // TODO DO NOT USE 1.9.10 or 1.9.11
addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3")

// USE> GITHUB_TOKEN=??? SBT_PACKAGER=enable sbt publish
new sbt.Def.SettingList(
sys.env
.get("SBT_PACKAGER")
.map { _ =>
println("### Enable sbt-native-packager ###")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.11")
}
.toSeq
)

// USE> SBT_SCOVERAGE=enable sbt clean coverage test coverageAggregate
new sbt.Def.SettingList(
sys.env
.get("SBT_SCOVERAGE") // SEE also build.sbt
.map { _ =>
println("### Enable sbt-scoverage ###")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.6") // Needs scala version 3.2.2
}
.toSeq
)

0 comments on commit fcaaeda

Please sign in to comment.