Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Re)Adding service_name to CoverallsPayload #315

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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