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 pull_request: 15 paths: 16 - .github/workflows/android-unit-tests.yml 17 - android/** 18 - fastlane/** 19 - packages/**/android/** 20 - tools/** 21 - yarn.lock 22 23concurrency: 24 group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} 25 cancel-in-progress: true 26 27jobs: 28 test: 29 runs-on: ubuntu-20.04 30 timeout-minutes: 60 31 env: 32 ORG_GRADLE_PROJECT_reactNativeArchitectures: x86 33 GRADLE_OPTS: -Dorg.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=1024m 34 steps: 35 - name: ⬢ Setup Node 36 uses: actions/setup-node@v3 37 with: 38 node-version: '14.17' 39 - name: Check out repository 40 uses: actions/checkout@v3 41 with: 42 submodules: true 43 - name: Use JDK 11 44 uses: actions/setup-java@v3 45 with: 46 distribution: 'temurin' 47 java-version: '11' 48 - name: ♻️ Restore workspace node modules 49 uses: actions/cache@v2 50 id: node-modules-cache 51 with: 52 path: | 53 # See "workspaces" → "packages" in the root package.json for the source of truth of 54 # which node_modules are affected by the root yarn.lock 55 node_modules 56 apps/*/node_modules 57 home/node_modules 58 packages/*/node_modules 59 packages/@expo/*/node_modules 60 react-native-lab/react-native/node_modules 61 key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} 62 - name: Install node modules in root dir 63 run: yarn install --frozen-lockfile 64 - name: ♻️ Restore node modules in tools 65 uses: actions/cache@v2 66 with: 67 path: tools/node_modules 68 key: ${{ runner.os }}-tools-modules-${{ hashFiles('tools/yarn.lock') }} 69 - name: ♻️ Restore Gradle caches 70 uses: actions/cache@v2 71 with: 72 path: ~/.gradle/caches 73 key: ${{ runner.os }}-gradle-${{ hashFiles('android/*.gradle*') }} 74 restore-keys: | 75 ${{ runner.os }}-gradle- 76 - run: echo "$(pwd)/bin" >> $GITHUB_PATH 77 - name: Run Spotless lint check 78 working-directory: android 79 run: ./gradlew spotlessCheck || { echo '::error Spotless lint failed. Run `./gradlew spotlessApply` to automatically fix formatting.' && exit 1; } 80 - name: Run native Android unit tests 81 timeout-minutes: 30 82 run: expotools native-unit-tests --platform android 83 - name: Run instrumented unit tests 84 timeout-minutes: 40 85 uses: reactivecircus/android-emulator-runner@v2 86 with: 87 api-level: 29 88 emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -no-snapshot-save 89 script: | 90 # wait for emulator to be fully boot up 91 sleep 180 92 bin/expotools android-native-unit-tests --type instrumented 93 - name: Save test results 94 if: always() 95 uses: actions/upload-artifact@v3 96 with: 97 name: test-results 98 path: packages/**/build/test-results/**/*xml 99