Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ jobs:
- os: ubuntu-22.04
java: 17
distribution: temurin
- os: macos-14
java: 17
distribution: zulu
- os: windows-2022
java: 17
distribution: temurin
runs-on: ${{ matrix.os }}
env:
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
Expand All @@ -32,6 +38,13 @@ jobs:
java-version: ${{ matrix.java }}
cache: sbt
- uses: ./
- name: Build and test
- name: Build and test root
shell: bash
run: sbt -v +test
- name: Build and test sbt 2
shell: bash
run: |
pushd example
sbt -v test
sbt -v test
popd
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ steps:

### Setting the runner version

The `sbt` runner (Bash script that launches sbt) is typically compatible with all modern sbt releases,
you might want to pin the runner to a specific version.
The `sbt` runner is typically compatible with all modern sbt releases.
However, the launcher distributed by sbt 2.x will require JDK 17.

You can pin the `sbt` runner back to sbt 1.x to run JDK 8:

```yaml
env:
Expand All @@ -42,12 +44,25 @@ steps:
- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
distribution: zulu
java-version: 8
cache: sbt
- uses: step-security/setup-sbt@v1
with:
sbt-runner-version: 1.9.9
sbt-runner-version: 1.12.11
- name: Build and test
shell: bash
run: sbt -v +test
```

### Opting out of disk cache

By default setup-sbt enables the disk cache on sbt 2.x. This can be opted out as follows:

```yaml
- uses: step-security/setup-sbt@v1
with:
disk-cache: false
- name: Build and test
shell: bash
run: sbt -v +test
Expand Down
22 changes: 20 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ inputs:
description: "The runner version (The actual version is controlled via project/build.properties)"
required: true
default: 1.12.11
disk-cache:
description: "Enable sbt 2.x disk cache"
required: false
default: true
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -62,11 +66,18 @@ runs:
if [[ "$RUNNER_OS" == "Windows" ]]; then
echo "sbt_toolpath=$RUNNER_TOOL_CACHE\\sbt\\$SBT_RUNNER_VERSION" >> "$GITHUB_OUTPUT"
echo "sbt_downloadpath=$RUNNER_TEMP\\_sbt" >> "$GITHUB_OUTPUT"
echo "sbt_diskcache=$HOME\\AppData\\Local\\sbt" >> "$GITHUB_OUTPUT"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
echo "sbt_toolpath=$RUNNER_TOOL_CACHE/sbt/$SBT_RUNNER_VERSION" >> "$GITHUB_OUTPUT"
echo "sbt_downloadpath=$RUNNER_TEMP/_sbt" >> "$GITHUB_OUTPUT"
echo "sbt_diskcache=$HOME/Library/Caches/sbt" >> "$GITHUB_OUTPUT"
else
echo "sbt_toolpath=$RUNNER_TOOL_CACHE/sbt/$SBT_RUNNER_VERSION" >> "$GITHUB_OUTPUT"
echo "sbt_downloadpath=$RUNNER_TEMP/_sbt" >> "$GITHUB_OUTPUT"
echo "sbt_diskcache=$HOME/.cache/sbt" >> "$GITHUB_OUTPUT"
fi
echo "sbt_cachekey=$RUNNER_OS-sbt-$SBT_RUNNER_VERSION-$SBT_CACHE_KEY_VERSION" >> "$GITHUB_OUTPUT"
echo "sbt_diskcachekey=$RUNNER_OS-sbt-diskcache-$SBT_CACHE_KEY_VERSION" >> "$GITHUB_OUTPUT"
- name: Check Tool Cache
id: cache-tool-dir
shell: bash
Expand All @@ -86,6 +97,13 @@ runs:
with:
path: ${{ steps.cache-paths.outputs.sbt_toolpath }}
key: ${{ steps.cache-paths.outputs.sbt_cachekey }}
- name: sbt 2.x disk cache
id: disk-cache
if: inputs.disk-cache == 'true'
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ steps.cache-paths.outputs.sbt_diskcache }}
key: ${{ steps.cache-paths.outputs.sbt_diskcachekey }}
- name: "Download and Install sbt"
shell: bash
env:
Expand All @@ -102,15 +120,15 @@ runs:

cd "$SBT_DOWNLOADPATH"
unzip -o "sbt-$SBT_RUNNER_VERSION.zip" -d "$SBT_TOOLPATH"

- name: "Verify the sbt distribution signature"
id: "ampel-verify"
# Skip on Windows/macOS until go-billy path fix lands: https://github.com/go-git/go-billy/issues/194
if: runner.os == 'Linux' && steps.cache-tool-dir.outputs.cache-hit != 'true' && steps.cache-dir.outputs.cache-hit != 'true'
env:
SBT_RUNNER_VERSION: ${{ inputs.sbt-runner-version }}
SBT_DOWNLOADPATH: "${{ steps.cache-paths.outputs.sbt_downloadpath }}"
uses: step-security/carabiner-dev-actions/ampel/verify@a4c7cda4c13b389e6747e7dfcaac9f599c7541db # v1.1.7
uses: step-security/carabiner-dev-actions/ampel/verify@0fd42d7efbb2b2c90458cc03add003600e3cd999 # v1.2.1
with:
policy: "git+https://github.com/carabiner-dev/policies#signature/signature.json"
subject: "${{ steps.cache-paths.outputs.sbt_downloadpath }}/sbt-${{ inputs.sbt-runner-version }}.zip"
Expand Down
3 changes: 3 additions & 0 deletions example/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scalaVersion := "3.8.3"
val munit = "org.scalameta" %% "munit" % "1.0.4"
libraryDependencies += munit % Test
1 change: 1 addition & 0 deletions example/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=2.0.0-RC13
9 changes: 9 additions & 0 deletions example/src/test/scala/example/ATest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package example

import munit.*

// a
class ATest extends FunSuite:
test("sum"):
assert(1 + 1 == 2)
end ATest
Loading