feat: Initial Native Ad Support #872
Workflow file for this run
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: Testing E2E Android | |
on: | |
pull_request: | |
branches: | |
- '**' | |
paths-ignore: | |
- 'docs/**' | |
- 'website/**' | |
- '.spellcheck.dict.txt' | |
- '**/*.md' | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- 'docs/**' | |
- 'website/**' | |
- '.spellcheck.dict.txt' | |
- '**/*.md' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
android: | |
name: Android | |
runs-on: ubuntu-latest | |
timeout-minutes: 70 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
EMULATOR_COMMAND: "-avd TestingAVD -noaudio -gpu swiftshader_indirect -camera-back none -no-snapshot -no-window -no-boot-anim -nojni -memory 2048 -timezone 'Europe/London' -cores 2" | |
EMULATOR_EXECUTABLE: qemu-system-x86_64-headless | |
strategy: | |
fail-fast: false | |
matrix: | |
# Refactor to make these dynamic with a low/high bracket only on schedule, not push | |
# For now this is just the fastest combo (api/arch/target/snapshot-warm-time) based on testing | |
api-level: [29] | |
arch: [x86_64] | |
target: [google_apis] | |
first-boot-delay: [600] | |
# This is useful for benchmarking, do 0, 1, 2, etc (up to 256 max job-per-matrix limit) for averages | |
iteration: [0] | |
steps: | |
- name: Liberate disk space | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: false | |
android: false | |
dotnet: true | |
haskell: true | |
large-packages: false | |
docker-images: true | |
swap-storage: false | |
- name: Enable KVM group perms | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 50 | |
# Set up tool versions | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Configure JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
# Set path variables needed for caches | |
- name: Set workflow variables | |
id: workflow-variables | |
run: | | |
echo "metro-cache=$HOME/.metro" >> $GITHUB_OUTPUT | |
echo "yarn-cache-dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | |
echo "tempdir=$TMPDIR" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v4 | |
name: Yarn Cache | |
id: yarn-cache | |
with: | |
path: ${{ steps.workflow-variables.outputs.yarn-cache-dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('package.json', 'RNGoogleMobileAdsExample/package.json') }} | |
restore-keys: ${{ runner.os }}-yarn-v1 | |
- name: Yarn Install | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 10 | |
retry_wait_seconds: 60 | |
max_attempts: 3 | |
command: yarn --no-audit --prefer-offline && cd RNGoogleMobileAdsExample && DETOX_DISABLE_POSTINSTALL=1 yarn --no-audit --prefer-offline | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
with: | |
# Only write to the cache for builds on the 'main' branches, stops branches evicting main cache | |
# Builds on other branches will only read from main branch cache writes | |
# Comment this and the with: above out for performance testing on a branch | |
cache-read-only: ${{ github.ref != 'refs/heads/main' }} | |
- name: Warm Gradle Cache | |
# This makes sure we fetch gradle network resources with a retry | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 15 | |
retry_wait_seconds: 60 | |
max_attempts: 3 | |
command: yarn tests:android:build | |
# This appears to be 'Cache Size: ~1230 MB (1290026823 B)' based on watching action logs | |
# Repo limit is 10GB; branch caches are independent; branches may read default branch cache. | |
# We don't want branches to evict main branch snapshot, so save on main, read-only all else | |
- name: AVD cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ matrix.api-level }}-${{ matrix.arch }}-${{matrix.target}}-v1-${{ hashFiles('~/.android/avd/**/snapshots/**') }} | |
restore-keys: | | |
avd-${{ matrix.api-level }}-${{ matrix.arch }}-${{matrix.target}}-v1 | |
- name: AVD Boot and Snapshot Creation | |
# Only generate a snapshot for saving if we are on main branch with a cache miss | |
# Comment the if out to generate snapshots on branch for performance testing | |
if: steps.avd-cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
avd-name: TestingAVD | |
force-avd-creation: false | |
target: ${{ matrix.target }} | |
arch: ${{ matrix.arch }} | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
sdcard-path-or-size: 100M | |
disable-animations: true | |
# Give the emulator a little time to run and do first boot stuff before taking snapshot | |
script: echo "Generated AVD snapshot for caching." | |
# This step is separate so pure install time may be calculated as a step | |
- name: Emulator Snapshot After Firstboot Warmup | |
# Only generate a snapshot for saving if we are on main branch with a cache miss | |
# Switch the if statements via comment if generating snapshots for performance testing | |
# if: matrix.first-boot-delay != '0' | |
if: steps.avd-cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main' | |
env: | |
FIRST_BOOT_DELAY: ${{ matrix.first-boot-delay }} | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
avd-name: TestingAVD | |
force-avd-creation: false | |
target: ${{ matrix.target }} | |
arch: ${{ matrix.arch }} | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
sdcard-path-or-size: 100M | |
disable-animations: true | |
# Give the emulator a little time to run and do first boot stuff before taking snapshot | |
script: | | |
sleep $FIRST_BOOT_DELAY | |
echo "First boot warmup completed." | |
- name: Metro Bundler Cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.workflow-variables.outputs.metro-cache }} | |
key: ${{ runner.os }}-metro-v1-${{ github.run_id }} | |
restore-keys: ${{ runner.os }}-metro-v1 | |
- name: Pre-fetch Javascript bundle | |
# Prebuild the bundle so that's fast when the app starts. | |
run: | | |
nohup yarn tests:packager & | |
printf 'Waiting for packager to come online' | |
until curl --output /dev/null --silent --head --fail http://localhost:8081/status; do | |
printf '.' | |
sleep 2 | |
done | |
echo "Packager is online! Preparing javascript bundle..." | |
curl --output /dev/null --silent --head --fail "http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&inlineSourceMap=true" | |
echo "...javascript bundle ready." | |
- name: Run Emulator Tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
timeout-minutes: 30 | |
continue-on-error: true | |
with: | |
api-level: ${{ matrix.api-level }} | |
avd-name: TestingAVD | |
force-avd-creation: false | |
target: ${{ matrix.target }} | |
arch: ${{ matrix.arch }} | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
sdcard-path-or-size: 100M | |
disable-animations: true | |
script: | | |
$ANDROID_HOME/platform-tools/adb logcat '*:D' > adb-log.txt & | |
yarn tests:android:run | |
- uses: codecov/codecov-action@v4 | |
with: | |
verbose: true | |
- name: Upload Emulator Log | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: adb_logs | |
path: adb-log.txt |