Skip to content

Scala

Scala is JVM based programming language and combines object-oriented and functional programming in one concise, high-level language.

This guide provides a walkthrough of .razorops.yaml for a typical Scala-based application based.

Example project

See the Example Project on GitHub for a demonstration and use the full configuration file as a template for your own projects.

The pipeline performs the following tasks:

  • Downloads the dependencies using sbt and cache them
  • Builds the artifact (jar)
  • Executes the unit tests

Choosing Scala version

You can choose the Java compiler version based on the build environment. Common build tools like maven, sbt, ant and gradle are pre-installed in the environment.

For Docker environment, Razorops provides convenience container images for various programming languages. You can use an appropriate image tag to control Java compiler version.

global:
  runner: razorci/openjdk:8-buster
...
tasks:
  build-deps:
    runner: razorci/openjdk:11-buster
...

You can additionally provide environment variables and provide service dependencies to run your test suite.

For Linux-VM environment, we support following Scala version(s) along with other build tools -

  • 2.12.10

Downloading dependencies

Downloading third-party packages/dependencies from the internet can be time-consuming, you can greatly speed up this process by caching it using an unique key. In future workflow runs, the cache will be restored so that dependencies don't need to be downloaded from remote (Sbt, Gradle etc) repositories. For more information, see Caching dependencies.

    - cache/pull: sbt-{{ checksum "project/build.properties" }}
    ...

    - cache/push:
        key: sbt-{{ checksum "project/build.properties" }}
        paths:
        - ~/.sbt
        - ~/.ivy2/cache

Executing tests

You can use the same commands that you use locally to test your code and generate JUnit reports to tell how much of your application is tested.

    steps:
    ...
    - name: Run unit test
      run: sbt test 

Managing artifacts

You can compile and build the jars just like you do locally and optionally upload to our artifact storage to use them after the workflow completes. For more information, see "Persisting workflow data using artifacts.".

    steps:
    ...
    - commands:
      - sbt clean package

    ...
    - artifacts/push:
        name: demo-x.x.x.jar
        paths: [target/scala-2.xx/demo-x.x.x.jar] # replace x with right version