name: Run unit tests

on:
  pull_request:
    branches:
      - 'master'
  push:
    branches:
      - 'master'

jobs:
  test:
    name: Run Unit Tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          java-version: 17
          distribution: 'temurin'
      - name: Unit tests
        run: ./gradlew testDevDebug -PdisablePreDex --no-daemon
      - name: Shared module unit tests (Android target + commonTest)
        run: ./gradlew :shared:testDebugUnitTest --no-daemon
      - name: Archive test results
        uses: actions/upload-artifact@v4
        with:
          name: test-results
          path: |
            app/build/test-results/testDevDebugUnitTest/
            app/build/reports/tests
            shared/build/test-results/testDebugUnitTest/
            shared/build/reports/tests
