Skip to content
Permalink
Browse files

Add codecov

  • Loading branch information...
mhamilton723 committed Jul 7, 2019
1 parent 7e8225f commit 7940967acb21c6fc77a05537c6cbdeb9db55da42
Showing with 75 additions and 4 deletions.
  1. +43 −1 build.sbt
  2. +31 −3 pipeline.yaml
  3. +1 −0 project/plugins.sbt
@@ -1,5 +1,6 @@
import java.io.{File, PrintWriter}
import java.net.URL
import java.util.{Random, UUID}

import org.apache.commons.io.FileUtils
import sbt.internal.util.ManagedLogger
@@ -107,6 +108,18 @@ def uploadToBlob(source: String, dest: String,
Process(osPrefix ++ command) ! log
}

def downloadFromBlob(source: String, dest: String,
container: String, log: ManagedLogger,
accountName: String="mmlspark"): Int = {
val command = Seq("az", "storage", "blob", "download-batch",
"--destination", dest,
"--pattern", source,
"--source", container,
"--account-name", accountName,
"--account-key", Secrets.storageKey)
Process(osPrefix ++ command) ! log
}

val publishDocs = TaskKey[Unit]("publishDocs", "publish docs for scala and python")
publishDocs := {
val s = streams.value
@@ -126,6 +139,34 @@ publishDocs := {
uploadToBlob(unifiedDocDir.toString, version.value, "docs", s.log)
}

val uploadRawCodeCov = TaskKey[Unit]("uploadRawCodeCov",
"upload raw code coverage to blob for aggregation later")
uploadRawCodeCov := {
val s = streams.value
val scoverageDir = join("target", "scala-2.11", "scoverage-data")
uploadToBlob(scoverageDir.toString, version.value + "/" + UUID.randomUUID().toString, "coverage", s.log)
}

val downloadCloudCodeCov = TaskKey[Unit]("downloadCloudCodeCov",
"download code coverage files from blob")
downloadCloudCodeCov := {
val s = streams.value
val scoverageDir = join("target", "scala-2.11", "scoverage-data")
val v = version.value
downloadFromBlob(v + "/**/scoverage.measurements.*", scoverageDir.toString, "coverage", s.log)
join(scoverageDir.toString, v).listFiles().foreach { d =>
d.listFiles().foreach { f =>
val fileParts = f.getName.split(".".head)
println(fileParts.toList, s.log)
val newInt = fileParts.last.toInt + Math.abs(d.toString.hashCode)
val newName = (fileParts.dropRight(1) ++ Seq(newInt.toString)).mkString(".")
FileUtils.moveFile(f, join(scoverageDir.toString, newName))
}
FileUtils.forceDelete(d)
}
FileUtils.forceDelete(join(scoverageDir.toString, v))
}

def pythonizeVersion(v: String): String = {
if (v.contains("+")){
v.split("+".head).head + ".dev1"
@@ -265,6 +306,7 @@ developers := List(
"mmlspark-support@microsoft.com", url("https://github.com/drdarshan"))
)

/*
credentials += Credentials("Sonatype Nexus Repository Manager",
"oss.sonatype.org",
Secrets.nexusUsername,
@@ -284,7 +326,7 @@ pgpPublicRing := {
write(Secrets.pgpPublic); close()
}
temp
}
}*/

licenses += ("MIT", url("https://github.com/Azure/mmlspark/blob/master/LICENSE"))
publishMavenStyle := true
@@ -35,6 +35,27 @@ jobs:
scriptLocation: inlineScript
inlineScript: 'sbt scalastyle test:scalastyle it:scalastyle'

- job: CodeCoverage
condition: eq(variables.runTests, 'True')
pool:
vmImage: ubuntu-16.04
dependsOn: UnitTests
steps:
- task: AzureCLI@1
displayName: 'Codecov Aggregate'
inputs:
azureSubscription: 'Findable Incubation(ca9d21ff-2a46-4e8b-bf06-8d65242342e5)'
scriptLocation: inlineScript
inlineScript: |
sbt coverage compile
sbt downloadCloudCodeCov
sbt coverageReport
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '**/coverage-report/*.xml'
failIfCoverageEmpty: true

- job: PublishAndE2E
pool:
vmImage: ubuntu-16.04
@@ -139,17 +160,24 @@ jobs:
inputs:
azureSubscription: 'Findable Incubation(ca9d21ff-2a46-4e8b-bf06-8d65242342e5)'
scriptLocation: inlineScript
inlineScript: 'sbt "testOnly com.microsoft.ml.spark.$(PACKAGE).**" '
inlineScript: 'sbt coverage "testOnly com.microsoft.ml.spark.$(PACKAGE).**"'
- task: AzureCLI@1
condition: and(failed(), eq(variables.flaky, 'True'))
displayName: 'Flaky Unit Test Retry'
inputs:
azureSubscription: 'Findable Incubation(ca9d21ff-2a46-4e8b-bf06-8d65242342e5)'
scriptLocation: inlineScript
inlineScript: 'sbt "testOnly com.microsoft.ml.spark.$(PACKAGE).**" '
inlineScript: 'sbt coverage "testOnly com.microsoft.ml.spark.$(PACKAGE).**"'
- task: AzureCLI@1
displayName: 'Generate Codecov report'
inputs:
azureSubscription: 'Findable Incubation(ca9d21ff-2a46-4e8b-bf06-8d65242342e5)'
scriptLocation: inlineScript
inlineScript: 'sbt uploadRawCodeCov'
condition: succeededOrFailed()
- task: PublishTestResults@2
displayName: 'Publish Test Results **/test-reports/*.xml'
inputs:
testResultsFiles: '**/test-reports/*.xml'
failTaskOnFailedTests: true
condition: succeededOrFailed()
condition: succeededOrFailed()
@@ -4,3 +4,4 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "3.1.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")

0 comments on commit 7940967

Please sign in to comment.
You can’t perform that action at this time.