1
votes

I am trying to make my first gitlab ci pipeline with sbt. i am trying to make build and test stages.

the problem is that although i compile the project at build, it compiles again at test stage before running the tests.

can someone help me to understand why this is happening and how to solve it?

sbt version: 1.2.7

this is my gitlab-ci.yml file:

image: docker-registry:5000/sbt-docker:latest

variables:

SBT_OPTS: "-Dsbt.global.base=sbt-cache/sbtboot -Dsbt.boot.directory=sbt-cache/boot -Dsbt.ivy.home=sbt-cache/ivy Dsbt.coursier.home=sbt-cache/coursier -Dsbt.io.jdktimestamps=true"

COURSIER_CACHE: sbt-cache/coursier

stages:
 - build
 - test

cache:
  paths:
    - "sbt-cache/ivy/cache"
    - "sbt-cache/boot"
    - "sbt-cache/sbtboot"
    - "sbt-cache/coursier"

build:
 stage: build
 script:
   - sbt -J-Xmx2G clean core/compile core/package
 artifacts:
   untracked: true
   paths:
     - "target/"


test:
  stage: test
  dependencies:
    - build
  script:
    - sbt core/test
  allow_failure: true
1
Have you tried to execute anything? When it compiles again as you say does it then quit? Perhaps you can shed more some light on what specifically you are trying to fix.Nelles
Your untracked and paths keys seem incorrectly indented. Is that just a copy-n-paste issue?cbley
@Nelles i tried to execute, everything is working but the problem is that it takes a lot of time because it is compiling again at test stageAvshalom Orenstein
@cbley yep it was copy-n-paste issueAvshalom Orenstein
When you run sbt core/test in your second stage, it probably doesn't see the target/ directory from your first stage, so it compiles sources again from scratch. You'd need to find a way to pass this directory to the next stage, using artifacts and dependencies.Etienne Neveu

1 Answers

0
votes

You need to cache the target/ folders of your project. I'm not familiar with CircleCI, it seems that there is a cache:paths key available, which sounds nice as long as the cache is per branch.