.github/workflows/android_repeatable.yml
name: R
on:
workflow_dispatch:
push:
paths-ignore:
- '*'
- '**/**'
- '!.github/workflows/android_repeatable.yml'
defaults:
run:
shell: sh
working-directory: .
concurrency:
group: ${{ github.workflow }} ${{ github.ref }}
cancel-in-progress: true
# Default environment variables.
env:
GITHUB_STEP_TIMEOUT_SMALL: 4
GITHUB_STEP_TIMEOUT_MEDIUM: 10
GITHUB_STEP_TIMEOUT_LONG: 20
jobs:
Build:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
strategy:
fail-fast: false
matrix:
include:
- test: RayTracingTest#testRenderSceneFromSDCardOBJ
type: debug
host_os: ubuntu-latest
android_api: 30
name: ${{ matrix.test }} [${{ matrix.type }} (${{ matrix.host_os }})]
runs-on: ${{ matrix.host_os }}
timeout-minutes: 360
steps:
- name: Checkout
timeout-minutes: ${{ fromJSON(env.GITHUB_STEP_TIMEOUT_MEDIUM) }}
if: success()
uses: actions/checkout@v4
- name: Set up JDK
timeout-minutes: ${{ fromJSON(env.GITHUB_STEP_TIMEOUT_MEDIUM) }}
if: success()
uses: actions/setup-java@v4
with:
# Check available parameters in: https://github.com/actions/setup-java/blob/main/action.yml
java-version: 21
distribution: zulu
java-package: jdk
architecture: x64
check-latest: false
server-id: github
server-username: GITHUB_ACTOR
server-password: GITHUB_TOKEN
settings-path: ~/.gradle
overwrite-settings: true
gpg-private-key: ''
gpg-passphrase: GPG_PASSPHRASE
cache: gradle
cache-dependency-path: '**/build.gradle'
- name: Set Android CPU Architecture
id: set-cpu-arch
timeout-minutes: ${{ fromJSON(env.GITHUB_STEP_TIMEOUT_SMALL) }}
if: success()
run: |
set +eu;
MAJOR_MAC_VERSION=$(sw_vers | grep ProductVersion | cut -d ':' -f2 | cut -d '.' -f1 | tr -d '[:space:]');
if [ "${MAJOR_MAC_VERSION}" != '' ]; then
echo "MacOS '${MAJOR_MAC_VERSION}' detected";
fi
set -e;
if [ "${MAJOR_MAC_VERSION}" -gt 13 ]; then
echo 'android_arch=\"arm64-v8a\"' >> "${GITHUB_ENV}";
echo 'android_emulator_arch=arm64-v8a' >> "${GITHUB_ENV}";
else
if [ "${{ matrix.android_api }}" -gt 20 ]; then
echo 'android_arch=\"x86_64\"' >> "${GITHUB_ENV}";
echo 'android_emulator_arch=x86_64' >> "${GITHUB_ENV}";
else
echo 'android_arch=\"x86\"' >> "${GITHUB_ENV}";
echo 'android_emulator_arch=x86' >> "${GITHUB_ENV}";
fi
fi
set -u;
. scripts/helper_functions.sh && parallelizeBuild && echo "NCPU_CORES=${NCPU_CORES}" >> "${GITHUB_ENV}";
- name: Download Android CMake
timeout-minutes: ${{ fromJSON(env.GITHUB_STEP_TIMEOUT_SMALL) }}
if: success() && !startsWith(matrix.host_os, 'windows')
run: |
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install 'cmake;3.31.1';
- name: Download Android CMake Windows
timeout-minutes: ${{ fromJSON(env.GITHUB_STEP_TIMEOUT_SMALL) }}
if: success() && startsWith(matrix.host_os, 'windows')
run: |
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager.bat --install 'cmake;3.31.1';
- name: Download Android dependencies
timeout-minutes: 5
if: success()
run: |
sh gradlew build --dry-run -Dorg.gradle.configuration-cache=true --parallel \
-DtestType="${{ matrix.type }}" -DandroidApiVersion="${{ matrix.android_api }}" -DabiFilters="[${{ env.android_arch }}]" \
--info --warning-mode all --stacktrace;
- name: Build ${{ matrix.type }}
timeout-minutes: 20
if: success()
working-directory: .
run: |
sh scripts/compile_android.sh -t ${{ matrix.type }} -a ${{ matrix.android_api }} -r yes -f ${{ env.android_arch }};
- name: Enable KVM group permissions
timeout-minutes: ${{ fromJSON(env.GITHUB_STEP_TIMEOUT_SMALL) }}
if: success() && startsWith(matrix.host_os, 'ubuntu')
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;
- name: Download Android dependencies
timeout-minutes: ${{ fromJSON(env.GITHUB_STEP_TIMEOUT_SMALL) }}
if: success()
run: |
sh gradlew connectedAndroidTest --dry-run -Dorg.gradle.configuration-cache=true --parallel \
-DtestType="${{ matrix.type }}" -DandroidApiVersion="${{ matrix.android_api }}" -DabiFilters="[${{ env.android_arch }}]" \
--info --warning-mode all --stacktrace;
- name: Run Android tests
timeout-minutes: 20
if: success() && !startsWith(matrix.host_os, 'windows')
uses: ReactiveCircus/android-emulator-runner@v2
env:
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 1
with:
# Check available parameters in: https://github.com/ReactiveCircus/android-emulator-runner/blob/main/action.yml
api-level: ${{ matrix.android_api }}
target: default
arch: ${{ env.android_emulator_arch }}
disable-animations: true
disable-spellchecker: true
channel: stable
emulator-options: -no-metrics -no-window -cores ${{ env.NCPU_CORES }} -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none
cores: ${{ env.NCPU_CORES }}
sdcard-path-or-size: 100M
ram-size: 1024M
emulator-boot-timeout: 400 # It can take more than 5 min to boot, and the tests can take more than 17 min to finish.
script: |
sh scripts/run_tests_android.sh -t ${{ matrix.type }} -r rep_puscas.mobilertapp.${{ matrix.test }} -a ${{ matrix.android_api }} -k false -f ${{ env.android_arch }};
- name: Upload reports as artifact
timeout-minutes: ${{ fromJSON(env.GITHUB_STEP_TIMEOUT_SMALL) }}
if: success()
uses: actions/upload-artifact@v4
with:
# Check available parameters in: https://github.com/actions/upload-artifact/blob/main/action.yml
name: reports_${{ matrix.type }}_${{ matrix.host_os }}-artifacts
path: app/build/reports
if-no-files-found: error
retention-days: 90