name: Android Unit Tests on: workflow_dispatch: {} push: branches: [main] paths: - .github/workflows/android-unit-tests.yml - android/** - fastlane/** - packages/**/android/** - tools/** - yarn.lock pull_request: paths: - .github/workflows/android-unit-tests.yml - android/** - fastlane/** - packages/**/android/** - tools/** - yarn.lock concurrency: group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} cancel-in-progress: true jobs: test: runs-on: ubuntu-latest timeout-minutes: 60 env: ORG_GRADLE_PROJECT_reactNativeArchitectures: x86 GRADLE_OPTS: -Dorg.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=1024m steps: - name: ⬢ Setup Node uses: actions/setup-node@v3 with: node-version: '14.17' - name: 👀 Check out repository uses: actions/checkout@v3 with: submodules: true - name: 🔨 Use JDK 11 uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '11' - name: ♻️ Restore workspace node modules uses: actions/cache@v2 id: node-modules-cache with: path: | # See "workspaces" → "packages" in the root package.json for the source of truth of # which node_modules are affected by the root yarn.lock node_modules apps/*/node_modules home/node_modules packages/*/node_modules packages/@expo/*/node_modules packages/@unimodules/*/node_modules react-native-lab/react-native/node_modules key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} - name: 🧶 Install node modules in root dir run: yarn install --frozen-lockfile - name: ♻️ Restore node modules in tools uses: actions/cache@v2 with: path: tools/node_modules key: ${{ runner.os }}-tools-modules-${{ hashFiles('tools/yarn.lock') }} - name: ♻️ Restore Gradle caches uses: actions/cache@v2 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('android/*.gradle*') }} restore-keys: | ${{ runner.os }}-gradle- - run: echo "$(pwd)/bin" >> $GITHUB_PATH - name: Run Spotless lint check working-directory: android run: ./gradlew spotlessCheck || { echo '::error Spotless lint failed. Run `./gradlew spotlessApply` to automatically fix formatting.' && exit 1; } - name: 🎸 Run native Android unit tests timeout-minutes: 30 run: expotools native-unit-tests --platform android - name: 🎸 Run instrumented unit tests timeout-minutes: 40 uses: reactivecircus/android-emulator-runner@v2 with: api-level: 29 emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -no-snapshot-save script: | # wait for emulator to be fully boot up sleep 180 bin/expotools android-native-unit-tests --type instrumented - name: 💿 Save test results if: always() uses: actions/upload-artifact@v3 with: name: test-results path: packages/**/build/test-results/**/*xml