diff --git a/.gitea/workflows/scala-test.yml b/.gitea/workflows/scala-test.yml index 6f087a2..0ec18b7 100644 --- a/.gitea/workflows/scala-test.yml +++ b/.gitea/workflows/scala-test.yml @@ -1,5 +1,5 @@ -name: Scala Test -on: [push] +name: Scala (sbt) tests +on: [push, pull_request] jobs: scala-test: @@ -7,15 +7,44 @@ jobs: 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' # auto-cache Coursier/Ivy for sbt + 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 - uses: sbt/setup-sbt@v1 # installs sbt + if: steps.detect.outputs.found == 'true' + uses: sbt/setup-sbt@v1 - name: Run tests - run: sbt -batch -v test \ No newline at end of file + 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."