1name: Android Unit Tests 2 3on: 4 workflow_dispatch: {} 5 push: 6 branches: [master] 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 steps: 31 - name: Check out repository 32 uses: actions/checkout@v2 33 with: 34 submodules: true 35 - name: Get yarn cache directory path 36 id: yarn-cache-dir-path 37 run: echo "::set-output name=dir::$(yarn cache dir)" 38 - uses: actions/cache@v2 39 name: Restore yarn cache 40 with: 41 path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 42 key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} 43 restore-keys: | 44 ${{ runner.os }}-yarn- 45 - run: yarn install --frozen-lockfile 46 - uses: actions/cache@v2 47 name: Restore Gradle cache 48 with: 49 path: ~/.gradle/caches 50 key: ${{ runner.os }}-gradle-${{ hashFiles('android/*.gradle*') }} 51 restore-keys: | 52 ${{ runner.os }}-gradle- 53 - uses: actions/cache@v2 54 name: Restore NDK cache 55 id: cache-android-ndk 56 with: 57 path: /usr/local/lib/android/sdk/ndk/19.2.5345600/ 58 key: ${{ runner.os }}-ndk-19.2.5345600 59 restore-keys: | 60 ${{ runner.os }}-ndk- 61 - name: Install NDK 62 if: steps.cache-android-ndk.outputs.cache-hit != 'true' 63 run: | 64 sudo $ANDROID_SDK_ROOT/tools/bin/sdkmanager --install "ndk;19.2.5345600" 65 - run: echo "$(pwd)/bin" >> $GITHUB_PATH 66 - name: Run Spotless lint check 67 env: 68 ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/19.2.5345600/ 69 working-directory: android 70 run: ./gradlew spotlessCheck || { echo '::error Spotless lint failed. Run `./gradlew spotlessApply` to automatically fix formatting.' && exit 1; } 71 - name: Run native Android unit tests 72 env: 73 ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/19.2.5345600/ 74 run: expotools native-unit-tests --platform android 75 - name: Save test results 76 if: always() 77 uses: actions/upload-artifact@v2 78 with: 79 name: test-results 80 path: packages/**/build/test-results/**/*xml 81