Fix Android build tests #1062
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android Ubuntu | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 55 | |
strategy: | |
matrix: | |
directory: [example] | |
concurrency: | |
group: android-ubuntu-${{ matrix.directory }}-${{ github.ref }} | |
cancel-in-progress: true | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- uses: actions/setup-node@v3 | |
with: | |
cache: 'yarn' | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: '11' | |
- name: Install NDK | |
uses: nttld/setup-ndk@v1 | |
id: setup-ndk | |
with: | |
ndk-version: r23 | |
- name: Set ANDROID_NDK | |
run: echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV | |
- name: Disk Cleanup | |
run: | | |
sudo apt-get clean | |
sudo rm -rf /var/lib/apt/lists/* | |
sudo rm -rf ~/.cache | |
- name: Prune Docker system | |
run: docker system prune -f --volumes | |
- name: Install root node dependencies | |
run: yarn | |
- name: Download Skia Binary Artifacts | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow: "build-skia.yml" | |
repo: shopify/react-native-skia | |
path: artifacts | |
branch: main | |
- name: Copy Artifacts to libs folder | |
run: yarn workflow-copy-libs | |
- name: Copy Skia Headers | |
run: yarn copy-skia-headers | |
- name: SDKs - accept licenses | |
run: yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses | |
- name: Install Package | |
working-directory: package | |
run: yarn install | |
# Install node dependencies in specified directories using matrix | |
- name: Install app node dependencies | |
working-directory: ${{ matrix.directory }} | |
run: yarn | |
# Cache hermes build for both directories | |
- name: Cache hermes build | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-rn-hermes-engine | |
with: | |
path: ${{ matrix.directory }}/node_modules/react-native | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.directory }}-${{ hashFiles('**/react-native/package.json') }} | |
# Cache android libraries for both directories | |
- name: Cache android libraries | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-rn | |
with: | |
path: ${{ matrix.directory }}/android/app/build | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.directory }}-${{ hashFiles('**/react-native/package.json') }} | |
# Build Android app in specified directories using matrix | |
- name: Build Android app | |
working-directory: ${{ matrix.directory }}/android | |
run: ./gradlew assembleDebug --daemon --build-cache --parallel --max-workers=2 | |
# Cache apk for both directories | |
- name: Cache apk | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-apk | |
with: | |
path: ${{ matrix.directory }}/android/app/build/outputs/apk/debug/app-debug.apk | |
key: apk-${{ github.sha }} | |
# Clean up after the build to free up space | |
- name: Clean up build directories | |
run: rm -rf ${{ matrix.directory }}/android/app/build |