Skip to content
GitHub Action to install Java via Jabba and sbt for Scala projects
TypeScript Shell JavaScript Scala
Use this GitHub Action with your project

Add this Action to an existing workflow or create a new one.

View on Marketplace
Branch: master
Clone or download

Latest commit

bkabrda and olafurpg Set action as failed when Java can't be installed. Fixes #12 (#13)
* Set action as failed when Java can't be installed. Fixes #12

* Update src/install.ts

Co-Authored-By: Ólafur Páll Geirsson <olafurpg@gmail.com>

Co-authored-by: Ólafur Páll Geirsson <olafurpg@gmail.com>
Latest commit 8a9a839 Mar 26, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Add support for Windows. Sep 29, 2019
__tests__ Add custom action to install Java via Jabba Sep 22, 2019
bin
src
test-build Print CI environment variable in test Nov 27, 2019
.gitignore
LICENSE Initial commit Sep 22, 2019
README.md Add a section about how to speed up checkout of big repos Dec 15, 2019
action.yml Update action name to match with the repo name Feb 17, 2020
jest.config.js Initial commit Sep 22, 2019
package.json Add custom action to install Java via Jabba Sep 22, 2019
tsconfig.json
yarn.lock Bump handlebars from 4.2.1 to 4.5.3 Dec 30, 2019

README.md

Setup Scala GitHub Action

A GitHub Action to install Java via Jabba and sbt.

  • Configurable Java version: supports OpenJDK, GraalVM, Zulu and any other Java version that's installable via Jabba.
  • The sbt command is installed using the paulp/sbt-extras launcher.
  • For faster startup, the csbt command is installed using the Coursier-based coursier/sbt-extras launcher. This launcher does not work with all builds, only use csbt if you know what you are doing.
  • Cross-platform: works on Linux, macOS, Windows.

Usage:

In your GitHub Actions workflow, add a uses: declaration before calling the sbt command.

+++ .github/workflows/ci.yml
  name: CI
  on:
    push:
  jobs:
    build:
      runs-on: ubuntu-latest
      steps:
      - uses: actions/checkout@v1
+     - uses: olafurpg/setup-scala@v5
      - name: Compile
        run: sbt compile

The default Java version is the latest OpenJDK 8 HotSpot version via AdoptOpenJDK. To customize the Java version add a with: declaration. For example, to use the latest AdoptOpenJDK 11 version

+++ .github/workflows/ci.yml
  name: CI
  on:
    push:
  jobs:
    build:
      runs-on: ubuntu-latest
      steps:
      - uses: actions/checkout@v1
      - uses: olafurpg/setup-scala@v5
+       with:
+         java-version: adopt@1.11
      - name: Compile
        run: sbt compile

More Java version examples:

  • graalvm@: the latest GraalVM
  • openjdk@1.14: the latest OpenJDK 14 version
  • zulu@1.11: the latest Zulu OpenJDK 11

Tips and tricks

Some suggestions that may be helpful when using GitHub Actions.

Disable fail-fast strategy

By default, GitHub Actions stops running jobs on the first failure. Add the following configuration to ensure that all jobs run on every PR even if one job fails.

+++ .github/workflows/ci.yml
  name: CI
  on: [push]
  jobs:
    build:
      runs-on: ubuntu-latest
+     strategy:
+       fail-fast: false
      steps:
      - uses: actions/checkout@v1
      - uses: olafurpg/setup-scala@v2
      - name: Compile
        run: sbt compile

Browsing raw logs

Searching through large logs in the GitHub Actions web UI can be slow sometimes. It can be faster to look at the raw logs instead.

Configuring Windows jobs

When running jobs on Windows, you may want to default to the bash shell and configure git to disable Windows line feeds.

+++ .github/workflows/ci.yml
  name: CI
  on: [push]
  jobs:
    build:
-     runs-on: ubuntu-latest
+     runs-on: windows-latest
      steps:
+     - name: Configure git
+       run: "git config --global core.autocrlf false"
+       shell: bash
      - uses: actions/checkout@v1
      - uses: olafurpg/setup-scala@v2
      - name: Compile
+       shell: bash
        run: sbt compile

Faster checkout of big repos

Your repository can have a lot of commits, or branches with bulk resources. The v2 version of actions/checkout doesn't fetch a whole repo by default that can speed up builds greatly. But an additional configuration can be required to fetch tags up to some level of depth for some builds which check binary compatibility with previous tagged release from the branch.

+++ .github/workflows/ci.yml
  name: CI
  on: [push]
  jobs:
    build:
      runs-on: ubuntu-latest
      steps:
-     - uses: actions/checkout@v1
+     - uses: actions/checkout@v2
+       with:
+         fetch-depth: 100
+     - name: Fetch tags
+       run: git fetch --depth=100 origin +refs/tags/*:refs/tags/*
      - uses: olafurpg/setup-scala@v2
      - name: Compile
        run: sbt compile
You can’t perform that action at this time.