name: Shared Tests

on:
  pull_request:
  workflow_dispatch:

jobs:
  shared-test:
    name: shared-test
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Set up JDK 21
        uses: actions/setup-java@v5
        with:
          java-version: '21'
          distribution: 'temurin'

      - name: Setup Gradle
        uses: gradle/actions/setup-gradle@v5
        with:
          cache-read-only: true

      - name: Run shared tests
        run: ./gradlew --no-daemon -Dorg.gradle.jvmargs="-Xmx2g" :shared:test

      - name: Upload test report
        if: always()
        uses: actions/upload-artifact@v6
        with:
          name: shared-test-report-attempt${{ github.run_attempt }}
          path: shared/build/reports/tests/test
          retention-days: 7

