From 8222f4b55baebfa96f91e5c2cfee006e968155bf Mon Sep 17 00:00:00 2001 From: Denis Mikhaylov Date: Thu, 10 Aug 2023 17:53:33 +0300 Subject: [PATCH] Add support for CircleCI (#272) * Add support for CircleCI * Update README.md --- README.md | 20 +++++++++++++++++++ .../org/scoverage/coveralls/CIService.scala | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/README.md b/README.md index b03cdb2..e4049c8 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,26 @@ Travis build and you should see coverage reports appear on [coveralls][]. 2) Job done! Commit these changes to kick off your GitHub Actions build and you should see coverage reports appear on [coveralls][]. +## CircleCI Integration + +Enable CircleCI support in your `build.sbt`: + +```scala +import org.scoverage.coveralls.Imports.CoverallsKeys._ +import org.scoverage.coveralls.CircleCI + +coverallsService := Some(CircleCI) +``` + +Add the following step to your `config.yml` right after your test step: + +```yaml +- run: + name: Generate and upload coverage report + when: always + command: sbt ";coverageReport ;coverageAggregate ;coveralls" +``` + ## Manual Usage 1) Get the repo token for your repo from [coveralls][]. diff --git a/src/main/scala/org/scoverage/coveralls/CIService.scala b/src/main/scala/org/scoverage/coveralls/CIService.scala index 63d94e6..b011192 100644 --- a/src/main/scala/org/scoverage/coveralls/CIService.scala +++ b/src/main/scala/org/scoverage/coveralls/CIService.scala @@ -94,3 +94,10 @@ case object GitHubActions extends CIService { } } } + +object CircleCI extends CIService { + def name: String = "circleci" + def jobId: Option[String] = sys.env.get("CIRCLE_BUILD_NUM") + def pullRequest: Option[String] = sys.env.get("CIRCLE_PULL_REQUEST").map(_.split("/").last) + def currentBranch: Option[String] = sys.env.get("CIRCLE_BRANCH") +}