name: Scala (sbt) tests on: [push, pull_request] jobs: scala-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 # Find an sbt project (first build.sbt found). If none, we skip gracefully. - name: Detect sbt project id: detect shell: bash run: | set -e FILE=$(git ls-files '**/build.sbt' | head -n1 || true) if [ -z "$FILE" ]; then echo "found=false" >> "$GITHUB_OUTPUT" exit 0 fi DIR=$(dirname "$FILE") echo "found=true" >> "$GITHUB_OUTPUT" echo "dir=$DIR" >> "$GITHUB_OUTPUT" - name: Set up Java (for sbt) if: steps.detect.outputs.found == 'true' uses: actions/setup-java@v4 with: distribution: temurin java-version: '11' # or 17/21 to match your project cache: sbt # Limit cache scan to the detected project to avoid the "no file matched" error cache-dependency-path: | ${{ steps.detect.outputs.dir }}/build.sbt ${{ steps.detect.outputs.dir }}/project/build.properties ${{ steps.detect.outputs.dir }}/project/**/*.scala ${{ steps.detect.outputs.dir }}/project/**/*.sbt - name: Set up sbt if: steps.detect.outputs.found == 'true' uses: sbt/setup-sbt@v1 - name: Run tests if: steps.detect.outputs.found == 'true' working-directory: ${{ steps.detect.outputs.dir }} run: sbt -batch -v test - name: Skip (no sbt project found) if: steps.detect.outputs.found != 'true' run: echo "No sbt project found; skipping Scala tests."