1name: Android Unit Tests
2
3on:
4  workflow_dispatch: {}
5  push:
6    branches: [main]
7    paths:
8      - .github/workflows/android-unit-tests.yml
9      - android/**
10      - fastlane/**
11      - packages/**/android/**
12      - tools/**
13      - yarn.lock
14      - '!packages/@expo/cli/**'
15  pull_request:
16    paths:
17      - .github/workflows/android-unit-tests.yml
18      - android/**
19      - fastlane/**
20      - packages/**/android/**
21      - tools/**
22      - yarn.lock
23      - '!packages/@expo/cli/**'
24
25concurrency:
26  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
27  cancel-in-progress: true
28
29jobs:
30  test:
31    runs-on: ubuntu-22.04
32    timeout-minutes: 100
33    env:
34      ORG_GRADLE_PROJECT_reactNativeArchitectures: x86_64
35      GRADLE_OPTS: -Dorg.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=1024m
36    steps:
37      - name: ⬢ Setup Node
38        uses: actions/setup-node@v3
39        with:
40          node-version: 16
41      - name: �� Check out repository
42        uses: actions/checkout@v3
43        with:
44          submodules: true
45      - name: �� Use JDK 11
46        uses: actions/setup-java@v3
47        with:
48          distribution: 'temurin'
49          java-version: '11'
50      - name: ♻️ Restore caches
51        uses: ./.github/actions/expo-caches
52        id: expo-caches
53        with:
54          yarn-workspace: 'true'
55          yarn-tools: 'true'
56          hermes-engine-aar: 'true'
57          react-native-gradle-downloads: 'true'
58      - name: ➕ Add `bin` to GITHUB_PATH
59        run: echo "$(pwd)/bin" >> $GITHUB_PATH
60      - name: �� Install node modules in root dir
61        if: steps.expo-caches.outputs.yarn-workspace-hit != 'true'
62        run: yarn install --frozen-lockfile
63      - name: �� Run Spotless lint check
64        working-directory: android
65        run: ./gradlew spotlessCheck || { echo '::error Spotless lint failed. Run `./gradlew spotlessApply` to automatically fix formatting.' && exit 1; }
66      - name: �� Run native Android unit tests
67        timeout-minutes: 30
68        run: expotools native-unit-tests --platform android
69      - name: �� Save test results
70        if: always()
71        uses: actions/upload-artifact@v3
72        with:
73          name: test-results
74          path: packages/**/build/test-results/**/*xml
75