Skip to content

[Test] suite-native Android E2E #30

[Test] suite-native Android E2E

[Test] suite-native Android E2E #30

name: "[Test] suite-native Android E2E"
on:
schedule:
- cron: "0 0 * * *"
pull_request:
paths:
- "suite-native/**"
- "suite-common/**"
- "packages/connect/**"
- ".github/workflows/test-suite-native-e2e-android.yml"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
NODE_ENV: "test"
jobs:
build_android_test_app:
if: github.repository == 'trezor/trezor-suite'
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
submodules: "true"
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
# The free GH runner has limited disk space, so we need to uninstall some preinstalled tools.
dotnet: true
haskell: true
tool-cache: false
android: false
swap-storage: false
large-packages: false
- name: Install node and yarn
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: yarn
- name: Setup node_modules cache
uses: actions/cache@v4
with:
path: node_modules
key: node_modules/${{ github.ref }}/${{github.run_id}}
- name: Install Yarn dependencies
run: |
echo -e "\nenableScripts: false" >> .yarnrc.yml
echo -e "\nenableHardenedMode: false" >> .yarnrc.yml
yarn install
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Sign message system config
working-directory: ./suite-common/message-system
run: yarn sign-config
- name: Prebuild native expo project
working-directory: ./suite-native/app
run: yarn prebuild --platform android --clean
- name: Build Detox test .apk
run: ../../node_modules/.bin/detox build -PreactNativeArchitectures=x86_64 --configuration android.emu.release
working-directory: ./suite-native/app
- name: Save build to cache
uses: actions/cache/save@v4
with:
path: |
suite-native/app/android/app/build/
key: android_test_build/${{ github.ref }}/${{github.run_id}}
run_android_e2e_tests:
if: github.repository == 'trezor/trezor-suite'
runs-on: ubuntu-latest
needs: build_android_test_app
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
submodules: "true"
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
# Combination of android emulator and trezor-user-env is using a too much disk space
# of a free tier GH action runner, some preinstalled packages have to be removed.
dotnet: true
haskell: true
tool-cache: false
android: false
swap-storage: false
large-packages: false
- name: Install node and yarn
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: yarn
- name: Load node modules cache
uses: actions/cache@v4
with:
path: node_modules
key: node_modules/${{ github.ref }}/${{github.run_id}}
- name: Install Yarn dependencies
run: |
echo -e "\nenableScripts: false" >> .yarnrc.yml
echo -e "\nenableHardenedMode: false" >> .yarnrc.yml
yarn install
- name: Get device name from detox config file
id: device
run: node -e "console.log('AVD_NAME=' + require('./suite-native/app/.detoxrc').devices.emulator.device.avdName)" >> $GITHUB_OUTPUT
- name: Run trezor-user-env
env:
COMPOSE_FILE: ./docker/docker-compose.suite-native-ci.yml
run: |
docker compose pull trezor-user-env-unix trezor-user-env-regtest
docker compose up --detach trezor-user-env-unix trezor-user-env-regtest
- name: Read test .apk from cache
uses: actions/cache/restore@v4
with:
path: |
suite-native/app/android/app/build/
key: android_test_build/${{ github.ref }}/${{github.run_id}}
- name: Enable Android emulator KVM optimalization
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: Run Detox E2E Android tests
uses: reactivecircus/android-emulator-runner@v2
env:
RUNNER_TEMP: /tmp
with:
api-level: 31
profile: pixel_3a
arch: x86_64
working-directory: suite-native/app
ram-size: 4096M
force-avd-creation: true
avd-name: ${{ steps.device.outputs.AVD_NAME }}
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -grpc 8554
script: yarn test:e2e android.emu.release --headless --take-screenshots failing --record-videos failing
- name: "Store failed test screenshot artifacts"
if: ${{failure()}}
uses: actions/upload-artifact@v4
with:
name: failed-android-tests
path: suite-native/app/artifacts