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 NDK_ABI_FILTERS: x86_64 33 steps: 34 - name: Check out repository 35 uses: actions/checkout@v2 36 with: 37 submodules: true 38 - name: Get yarn cache directory path 39 id: yarn-cache-dir-path 40 run: echo "::set-output name=dir::$(yarn cache dir)" 41 - uses: actions/cache@v2 42 name: Restore yarn cache 43 with: 44 path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 45 key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} 46 restore-keys: | 47 ${{ runner.os }}-yarn- 48 - run: yarn install --frozen-lockfile 49 - uses: actions/cache@v2 50 name: Restore Gradle cache 51 with: 52 path: ~/.gradle/caches 53 key: ${{ runner.os }}-gradle-${{ hashFiles('android/*.gradle*') }} 54 restore-keys: | 55 ${{ runner.os }}-gradle- 56 - uses: actions/cache@v2 57 name: Restore NDK cache 58 id: cache-android-ndk 59 with: 60 path: /usr/local/lib/android/sdk/ndk/21.4.7075529/ 61 key: ${{ runner.os }}-ndk-21.4.7075529 62 restore-keys: | 63 ${{ runner.os }}-ndk- 64 - name: Install NDK 65 if: steps.cache-android-ndk.outputs.cache-hit != 'true' 66 run: | 67 sudo $ANDROID_SDK_ROOT/tools/bin/sdkmanager --install "ndk;21.4.7075529" 68 - run: echo "$(pwd)/bin" >> $GITHUB_PATH 69 - name: Patch react-native to support single abi 70 run: sed -i 's/^APP_ABI := .*$/APP_ABI := $(if $(NDK_ABI_FILTERS),$(NDK_ABI_FILTERS),$(armeabi-v7a x86 arm64-v8a x86_64))/g' ReactAndroid/src/main/jni/Application.mk 71 working-directory: react-native-lab/react-native 72 - name: Run Spotless lint check 73 env: 74 ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/21.4.7075529/ 75 working-directory: android 76 run: ./gradlew spotlessCheck || { echo '::error Spotless lint failed. Run `./gradlew spotlessApply` to automatically fix formatting.' && exit 1; } 77 - name: Run native Android unit tests 78 timeout-minutes: 30 79 env: 80 ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/21.4.7075529/ 81 run: expotools native-unit-tests --platform android 82 - name: Save test results 83 if: always() 84 uses: actions/upload-artifact@v2 85 with: 86 name: test-results 87 path: packages/**/build/test-results/**/*xml 88