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=-Xmx3072m -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: �� Cleanup GitHub Linux runner disk space
46        uses: ./.github/actions/cleanup-linux-disk-space
47      - name: �� Use JDK 11
48        uses: actions/setup-java@v3
49        with:
50          distribution: 'temurin'
51          java-version: '11'
52      - name: ♻️ Restore caches
53        uses: ./.github/actions/expo-caches
54        id: expo-caches
55        with:
56          yarn-workspace: 'true'
57          yarn-tools: 'true'
58          hermes-engine-aar: 'true'
59          react-native-gradle-downloads: 'true'
60      - name: ➕ Add `bin` to GITHUB_PATH
61        run: echo "$(pwd)/bin" >> $GITHUB_PATH
62      - name: �� Install node modules in root dir
63        if: steps.expo-caches.outputs.yarn-workspace-hit != 'true'
64        run: yarn install --frozen-lockfile
65      - name: �� Run Spotless lint check
66        working-directory: android
67        run: ./gradlew spotlessCheck || { echo '::error Spotless lint failed. Run `./gradlew spotlessApply` to automatically fix formatting.' && exit 1; }
68      - name: �� Run native Android unit tests
69        timeout-minutes: 30
70        run: expotools native-unit-tests --platform android
71      - name: �� Save test results
72        if: always()
73        uses: actions/upload-artifact@v3
74        with:
75          name: test-results
76          path: packages/**/build/test-results/**/*xml
77