gitlab-org--gitlab-foss/doc/ci/examples/test-scala-application.md
2016-03-18 09:52:56 +01:00

1.3 KiB

Test a Scala application

This example demonstrates the integration of Gitlab CI with Scala applications using SBT. Checkout the example project and build status.

Add .gitlab-ci.yml file to project

The following .gitlab-ci.yml should be added in the root of your repository to trigger CI:

image: java:8

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 and displays the version that is being used. The test stage executes SBT to compile and test the project. 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.