Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run sbt tests in gitlab ci

Tags:

sbt

gitlab-ci

I have a play 2.4.x project. I would like to use gitlab to do CI.

How can I run tests in ci.gitlab.com?

My gitbal-ci.yml file looks like the following but its obviously wrong.

tests:
  script: "apt-get install -y sbt && sbt test"

I get the error

Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package sbt
like image 594
smk Avatar asked Sep 01 '25 03:09

smk


2 Answers

You can use directly an SBT image.

This gitbal-ci.yml worked in my case (handles also caching):

image: "sbtscala/scala-sbt:17.0.2_1.6.2_3.1.3"

variables:
  SBT_VERSION: "1.2.8"
  SBT_OPTS: "-Dsbt.global.base=sbt-cache/.sbtboot -Dsbt.boot.directory=sbt-cache/.boot -Dsbt.ivy.home=sbt-cache/.ivy"

cache:
  key: "$CI_BUILD_REF_NAME" # contains either the branch or the tag, so it's caching per branch
  untracked: true
  paths:
    - "sbt-cache/.ivy.cache"
    - "sbt-cache/.boot"
    - "sbt-cache/.sbtboot"
    - "sbt-cache/target"

stages:
  - test

test:
  script:
    - sbt test

This is from: Stackoverflow Answer

like image 146
pme Avatar answered Sep 03 '25 10:09

pme


To install sbt on a Debian based distribution, you have to run the following steps

echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823
sudo apt-get update
sudo apt-get install sbt

See the official sbt documentation for more details.

like image 41
stefan.schwetschke Avatar answered Sep 03 '25 10:09

stefan.schwetschke