mdm
mdm

Reputation: 3988

Reusing the result of SBT compilation between Travis or Github Actions jobs

Does anyone know if it is possible to have a multi-stage Travis build that uses SBT (latest 1.4.3 version) and for each stage to reuse the compiled code from the previous one?

I tried with caching, but it does not seem to work (I hope I am just missing something). What I have is a first “Compile” stage, and then a second “Tests” stage where two jobs are run in parallel (unit tests and integration tests).

What I want is that the Compile compiles everything (including test code) and then both the next stage just picks up where the compilation left.

I managed to organise the build to do that but:

The caching config I am using comes from the sbt docs:

cache:
  directories:
    - $HOME/.cache/coursier
    - $HOME/.ivy2/cache
    - $HOME/.sbt

Any idea?

(alternatively, if you know this is a problem of Travis and it can be made to work properly in Github Actions, that would be ok too)

Upvotes: 0

Views: 297

Answers (1)

cbley
cbley

Reputation: 4608

There is a new Travis feature (in beta) that allows you to share files from one job with subsequent jobs in a build: workspaces

jobs:
  include:
    - stage: warm_cache
      script:
        - echo "foo" > foo.txt
      workspaces:
        create:
          name: ws1
          paths:
            - foo.txt
    - stage: use_cache
      workspaces:
        use: ws1
      script:
        - cat foo.txt || true

Also, SBT 1.4 allows you to push build artefacts to a Maven server and fetch then again later: https://www.scala-sbt.org/1.x/docs/Remote-Caching.html

Upvotes: 1

Related Questions