Skip to content

Commit

Permalink
(Re)Adding service_name to CoverallsPayload (#315)
Browse files Browse the repository at this point in the history
* (Re)Adding service_name to CoverallsPayload.

* (Re)Adding service_name to CoverallsPayload.

* Make test(s) pass (again).
  • Loading branch information
rolandtritsch authored Jul 22, 2024
1 parent 6901069 commit 43120e9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CoverallPayloadWriter(
factory.createGenerator(file, JsonEncoding.UTF8)
}

def start() {
def start() = {
gen.writeStartObject()

def writeOpt(fieldName: String, holder: Option[String]) =
Expand All @@ -36,11 +36,10 @@ class CoverallPayloadWriter(
gen.writeStringField("repo_token", token)
case CIServiceToken(token) =>
gen.writeStringField("repo_token", token)
writeOpt("service_name", service.map(_.name))
case NoTokenNeeded =>
writeOpt("service_name", service.map(_.name))
}

writeOpt("service_name", service.map(_.name))
writeOpt("service_job_id", service.flatMap(_.jobId))
writeOpt("service_pull_request", service.flatMap(_.pullRequest))
writeOpt("flag_name", sys.env.get("COVERALLS_FLAG_NAME"))
Expand All @@ -53,7 +52,7 @@ class CoverallPayloadWriter(
gen.writeStartArray()
}

private def addGitInfo() {
private def addGitInfo() = {
gen.writeFieldName("git")
gen.writeStartObject()

Expand Down Expand Up @@ -86,7 +85,7 @@ class CoverallPayloadWriter(
gen.writeEndObject()
}

private def addGitRemotes(remotes: Seq[String]) {
private def addGitRemotes(remotes: Seq[String]) = {
remotes.foreach(remote => {
gen.writeStartObject()
gen.writeStringField("name", remote)
Expand All @@ -95,7 +94,7 @@ class CoverallPayloadWriter(
})
}

def addSourceFile(report: SourceFileReport) {
def addSourceFile(report: SourceFileReport) = {
val repoRootDirStr =
repoRootDir.getCanonicalPath.replace(File.separator, "/") + "/"

Expand Down
12 changes: 7 additions & 5 deletions src/main/scala/org/scoverage/coveralls/CoverallsAuth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ import io.circe.generic.auto._
*/
sealed trait CoverallsAuth

/** Auth strategy where a Coveralls-specific token is used. Works with every CI
* service.
/** Auth strategy where a Coveralls-specific token is used. Works
* with every CI service.
*/
case class CoverallsRepoToken(token: String) extends CoverallsAuth

/** Auth strategy where a token specific to the CI service is used, such as a
* GitHub token. Works on selected CI services supported by Coveralls.
/** Auth strategy where a token specific to the CI service is used,
* such as a GitHub token. Works on selected CI services supported
* by Coveralls.
*/
case class CIServiceToken(token: String) extends CoverallsAuth

/** Auth strategy where no token is passed. This seems to work for Travis.
/** Auth strategy where no token is passed. This seems to work
* for Travis.
*/
case object NoTokenNeeded extends CoverallsAuth
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ class CoverallPayloadWriterTest
payloadWriter.start
payloadWriter.flush()

println(writer.toString())

writer.toString should equal(
"""{"repo_token":"testRepoToken","service_job_id":"testServiceJob","parallel":false,""" +
"""{"repo_token":"testRepoToken","service_name":"my-service","service_job_id":"testServiceJob","parallel":false,""" +
expectedGit +
""","source_files":["""
)
Expand Down

0 comments on commit 43120e9

Please sign in to comment.