Test and deploy a Scala application to Heroku
.gitlab-ci.yml file to project
.gitlab-ci.yml should be added in the root of your
repository to trigger CI:
image: java:8 stages: - test - deploy before_script: - apt-get update -y - apt-get install apt-transport-https -y ## 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 sbtVersion test: stage: test script: - sbt clean coverage test coverageReport deploy: stage: deploy script: - apt-get update -yq - apt-get install rubygems ruby-dev -y - gem install dpl - dpl --provider=heroku --app=gitlab-play-sample-app --api-key=$HEROKU_API_KEY
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 an SBT
plugin to measure test coverage.
deploy stage automatically deploys the project to Heroku using dpl.
You can use other versions of Scala and SBT by defining them in
Display test coverage in job
Coverage was \[\d+.\d+\%\] regular expression in the
Settings ➔ Pipelines ➔ Coverage report project setting to
retrieve the test coverage
rate from the build trace and have it displayed with your jobs.
Pipelines must be enabled for this option to appear.
A Heroku application is required. You can create one through the
.gitlab-ci.yml file with your application's name.