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-18.04 30 timeout-minutes: 60 31 env: 32 ORG_GRADLE_PROJECT_reactNativeArchitectures: x86_64 33 GRADLE_OPTS: -Dorg.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=1024m 34 steps: 35 - name: Check out repository 36 uses: actions/checkout@v2 37 with: 38 submodules: true 39 - name: Use JDK 11 40 uses: actions/setup-java@v2 41 with: 42 distribution: 'temurin' 43 java-version: '11' 44 - name: Get yarn cache directory path 45 id: yarn-cache-dir-path 46 run: echo "::set-output name=dir::$(yarn cache dir)" 47 - uses: actions/cache@v2 48 name: Restore yarn cache 49 with: 50 path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 51 key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} 52 restore-keys: | 53 ${{ runner.os }}-yarn- 54 - run: yarn install --frozen-lockfile 55 - uses: actions/cache@v2 56 name: Restore Gradle cache 57 with: 58 path: ~/.gradle/caches 59 key: ${{ runner.os }}-gradle-${{ hashFiles('android/*.gradle*') }} 60 restore-keys: | 61 ${{ runner.os }}-gradle- 62 - uses: actions/cache@v2 63 name: Restore NDK cache 64 id: cache-android-ndk 65 with: 66 path: /usr/local/lib/android/sdk/ndk/21.4.7075529/ 67 key: ${{ runner.os }}-ndk-21.4.7075529 68 restore-keys: | 69 ${{ runner.os }}-ndk- 70 - name: Install NDK 71 if: steps.cache-android-ndk.outputs.cache-hit != 'true' 72 run: | 73 sudo $ANDROID_SDK_ROOT/tools/bin/sdkmanager --install "ndk;21.4.7075529" 74 - run: echo "$(pwd)/bin" >> $GITHUB_PATH 75 - name: Run Spotless lint check 76 env: 77 ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/21.4.7075529/ 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 env: 83 ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/21.4.7075529/ 84 run: expotools native-unit-tests --platform android 85 - name: Save test results 86 if: always() 87 uses: actions/upload-artifact@v2 88 with: 89 name: test-results 90 path: packages/**/build/test-results/**/*xml 91