SBT plugin that uploads scala code coverage to https://coveralls.io and integrates with Travis CI. This plugin uses scct to generate the code coverage metrics.
For an example project that uses this plugin click here
For example output click here
- OpenJDK support
- You must now add
seq(com.github.theon.coveralls.CoverallsPlugin.coverallsSettings: _*)
to your rootbuild.sbt
. This is to support multi project builds. - Command to run the plugin is now
coveralls
rather thancoverall test
. This is as a result from changing to useTaskKey
rather thanCommand
. See explanation - Multi project build support!
- Bug Fix: unicode characters in source files now decoded/encoded correctly
- New ways to specify your repo token
- Support for different source file encodings
- Adding the following to your
project/build.sbt
file
resolvers ++= Seq(
Classpaths.typesafeResolver,
"scct-github-repository" at "http://mtkopone.github.com/scct/maven-repo"
)
addSbtPlugin("reaktor" % "sbt-scct" % "0.2-SNAPSHOT")
addSbtPlugin("com.github.theon" %% "xsbt-coveralls-plugin" % "0.0.4")
- Add the following to the top of your
build.sbt
seq(ScctPlugin.instrumentSettings : _*)
seq(com.github.theon.coveralls.CoverallsPlugin.coverallsSettings: _*)
Coveralls configuration options (such as Specifying Your Repo Token) must come after this line.
-
Register on
https://coveralls.io/
-
Follow the instructions for either Travis CI or Manual Usage
xsbt-coverall-plugin
can be run by Travis CI by following these instructions:
-
Add the following to you
travis.yml
script: "sbt coveralls"
-
Job done! Commit these changes to
travis.yml
to kick off your Travis build and you should see coverage reports appear on http://coveralls.io
-
Get the repo token for your repo from http://coveralls.io
-
Let
xsbt-coverall-plugin
know what your coveralls repo token is. See Specifying Your Repo Token -
In the SBT console run the command
coveralls
. This should run your test suite, generate code coverage reports and upload the reports tocoveralls.io
. After running the command, you should see output similar to the following:Uploading to coveralls.io succeeded: Job #17.1 https://coveralls.io/jobs/12207
For example output click here
There are several ways to tell xsbt-coverall-plugin
your repo token to support different use cases:
Add the following to your build.sbt
. The path can be absolute and point to somewhere outside the project or relative and point somewhere inside the project (such as src/main/resources/token.txt
).
Just remember: Do not store repo tokens inside your project if it is in a public git repository!
import com.github.theon.coveralls.CoverallsPlugin.CoverallsKeys._
coverallsTokenFile := "/path/to/my/repo/token.txt"
Do not store repo tokens inside your project if it is in a public git repository!
import com.github.theon.coveralls.CoverallsPlugin.CoverallsKeys._
coverallsToken := "my-token"
Add an environment variable COVERALLS_REPO_TOKEN
, for example:
export COVERALLS_REPO_TOKEN=my-token
By default xsbt-coveralls-plugin
assumes your source files are UTF-8
encoded. To use a different encoding, add the following to your build.sbt
import com.github.theon.coveralls.CoverallsPlugin.CoverallsKeys._
encoding := "ISO-8859-1"
Once the plugin has slurped your source code into memory using the specified encoding, it will be converted into UTF-8 to be sent to the coveralls API. This is because the coveralls API uses a JSON request body and RFC 4627 mandates that JSON must be UTF encoded.
Add the following to your project/build.sbt
file
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
addSbtPlugin("com.github.theon" %% "xsbt-coveralls-plugin" % "0.0.5-SNAPSHOT")
In a single project build now add this to your build.sbt:
seq(CoverallsPlugin.singleProject: _*)
- 0.13.0 support added
- Moved plugin to root unnamed package
- Added scct as a dependency rather than requiring the user to also bring it in
- Added
singleProject
andmultiProject
Settings which include the scct settings, so the user doesn't need to manually include them in theirbuild.sbt
- Multi Project support still needs to be tested. Need to make a demo project for this.
For a list of features that going to be implemented see the issue tracker
xsbt-coveralls-plugin
is open source software released under the Apache 2 License.