Commit ac4d7538 authored by Jasper Denkers's avatar Jasper Denkers

Added CI example for Scala and SBT

Added CI test coverage parse regex for scoverage
parent 8edb133f
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
- [Test and deploy a Ruby application to Heroku](test-and-deploy-ruby-application-to-heroku.md) - [Test and deploy a Ruby application to Heroku](test-and-deploy-ruby-application-to-heroku.md)
- [Test and deploy a Python application to Heroku](test-and-deploy-python-application-to-heroku.md) - [Test and deploy a Python application to Heroku](test-and-deploy-python-application-to-heroku.md)
- [Test a Clojure application](test-clojure-application.md) - [Test a Clojure application](test-clojure-application.md)
- [Test a Scala application](test-scala-application.md)
- [Using `dpl` as deployment tool](deployment/README.md) - [Using `dpl` as deployment tool](deployment/README.md)
- Help your favorite programming language and GitLab by sending a merge request - Help your favorite programming language and GitLab by sending a merge request
with a guide for that language. with a guide for that language.
......
## Test a Scala application
This example demonstrates the integration of Gitlab CI with Scala applications using SBT. Checkout the example [project](https://gitlab.com/jasperdenkers/scala-sbt-sample-app) and [build status](https://gitlab.com/jasperdenkers/scala-sbt-sample-app/builds).
### Add `.gitlab-ci.yml` file to project
The following `.gitlab-ci.yml` should be added in the root of your repository to trigger CI:
```yaml
before_script:
# Install SBT
- echo "deb http://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list
- apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823
- apt-get update -y
- apt-get install sbt -y
- sbt sbt-version
test:
script:
- sbt clean coverage test coverageReport
```
The `before_script` installs [SBT](http://www.scala-sbt.org/) and displays the version that is being used. The `test` stage executes SBT to compile and test the project. [scoverage](https://github.com/scoverage/sbt-scoverage) is used as a SBT plugin to measure test coverage.
You can use other versions of Scala and SBT by defining them in `build.sbt`.
### Display test coverage in build
Add the `Coverage was \[\d+.\d+\%\]` regular expression in the `Continuous Integration > Test coverage parsing` project setting to retrieve the test coverage rate from the build trace and have it displayed with your builds.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment