Files
trezor-suite/.github/workflows/template-suite-native-e2e-android.yml
2025-10-31 12:14:06 -06:00

234 lines
8.4 KiB
YAML

name: "Android E2E Test Job Template"
on:
workflow_call:
inputs:
emulator_model:
description: "Emulator model identifier (e.g. T3W1)"
required: true
type: string
jest_test_name_pattern:
description: "(Optional) Jest test name pattern to filter tests"
required: false
default: ""
type: string
publish_results_to_github:
description: "Publish test report to GitHub Project"
required: false
default: false
type: boolean
currents_ci_build_id:
description: "Custom CI build ID for Currents reporting, default is pr-run-RUN_ID-RUN_ATTEMPT"
required: false
default: pr-run-${{ github.run_id }}-${{ github.run_attempt }}
type: string
currents_tags:
description: "(Optional) Additional tags for Currents reporting"
required: false
default: ""
type: string
secrets:
TREZOR_BOT_APP_ID:
required: true
TREZOR_BOT_PRIVATE_KEY:
required: true
CURRENTS_RECORD_KEY:
required: true
SLACK_MOBILE_E2E_WEBHOOK:
required: true
E2E_TEST_PASSPHRASE:
required: true
jobs:
run_android_e2e_tests:
runs-on: ubuntu-latest
outputs:
is_failure: ${{ steps.aggregate-result.outputs.is_failure }}
strategy:
fail-fast: false
matrix:
TEST_GROUP: [0, 1, 2, 3]
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
submodules: "true"
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
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/restore@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: Generate GitHub App token
id: trezor-bot-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.TREZOR_BOT_APP_ID }}
private-key: ${{ secrets.TREZOR_BOT_PRIVATE_KEY }}
- name: Extract Release Build
id: extract_branch
shell: bash
run: |
echo "release_build=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}-${GITHUB_SHA:0:7}" >> $GITHUB_ENV
- 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
GITHUB_TOKEN: ${{ steps.trezor-bot-token.outputs.token }}
RELEASE_BUILD: ${{ env.release_build }}
EMULATOR_MODEL: ${{ inputs.emulator_model }}
PUBLISH_RESULTS_TO_GITHUB: ${{ inputs.publish_results_to_github == true }}
JEST_TEST_NAME_PATTERN: ${{ inputs.jest_test_name_pattern }}
TRADING_ACADEMIC_SEED_WALLET_PASSPHRASE: ${{ secrets.E2E_TEST_PASSPHRASE }}
GITHUB_ACTION: true
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: |
npx jest --listTests e2e | sort | awk "NR % 4 == ${{ matrix.TEST_GROUP }}" > shard.txt
xargs yarn test:e2e android.emu.release --headless < shard.txt
- name: Upload results to Currents.dev
if: ${{ ! cancelled() }}
env:
CURRENTS_PROJECT_ID: iUe1Y4
CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
CURRENTS_CI_BUILD_ID: ${{ inputs.currents_ci_build_id }}
CURRENTS_TAG: ${{ inputs.currents_tags }}
COMMIT_INFO_BRANCH: ${{ github.head_ref }}
working-directory: ./suite-native/app
run: |
npx currents convert \
--input-format=junit \
--input-file=./reports/junit-report.xml \
--output-dir=./currents \
--framework=postman \
--framework-version=v11.2.0
npx currents upload \
--project-id=${CURRENTS_PROJECT_ID} \
--key=${CURRENTS_RECORD_KEY} \
--ci-build-id=${CURRENTS_CI_BUILD_ID} \
--report-dir ./currents
- name: Post Currents link
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
uses: ./.github/actions/post-currents-link
with:
github_token: ${{ steps.trezor-bot-token.outputs.token }}
project: "native android"
currents-project-id: "iUe1Y4"
- name: Extract Trezor-user-env and Regtest logs
if: ${{ !cancelled() }}
shell: bash
run: |
set -euo pipefail
LOG_DIR="suite-native/app/artifacts"
docker cp trezor-user-env.unix:/trezor-user-env/logs/debugging.log "$LOG_DIR/trezor-user-env-debugging.log" || true
docker cp trezor-user-env.unix:/trezor-user-env/logs/emulator_bridge.log "$LOG_DIR/tenv-emulator-bridge-debugging.log" || true
docker cp trezor-user-env.unix:/trezor-user-env/docker/version.txt "$LOG_DIR/trezor-user-env-version.txt" || true
docker logs trezor-user-env-regtest > "$LOG_DIR/electrum-regtest.txt" || true
- name: "Store test artifacts"
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: android-tests-${{ inputs.emulator_model }}-${{ matrix.TEST_GROUP }}
path: suite-native/app/artifacts
retention-days: 14
- name: Upload run test shard
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: shard-${{ inputs.emulator_model }}-${{ matrix.TEST_GROUP }}
path: suite-native/app/shard.txt
notify_scheduled_failure_to_slack:
runs-on: ubuntu-latest
if: ${{ failure() && github.event_name == 'schedule' }}
needs: run_android_e2e_tests
steps:
- name: Notify scheduled job failure to Slack
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":"Nightly Android E2E tests failed :pepe_flame: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} "}' "${{ secrets.SLACK_MOBILE_E2E_WEBHOOK }}"
aggregate_android_test_index:
runs-on: ubuntu-latest
needs: run_android_e2e_tests
if: ${{ !cancelled() }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 1
- name: Generate GitHub App token
id: trezor-bot-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.TREZOR_BOT_APP_ID }}
private-key: ${{ secrets.TREZOR_BOT_PRIVATE_KEY }}
- name: Display testFiles-artifacts links
uses: ./.github/actions/display-testfile-artifact-links
with:
github-token: ${{ steps.trezor-bot-token.outputs.token }}
model: ${{ inputs.emulator_model }}