mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-02-20 00:33:07 +01:00
178 lines
6.5 KiB
YAML
178 lines
6.5 KiB
YAML
name: "Android E2E Test Job Template"
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
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
|
|
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-${{ hashFiles('yarn.lock') }}
|
|
restore-keys: node_modules-
|
|
|
|
- name: Install Yarn dependencies
|
|
run: |
|
|
echo -e "\nenableScripts: false" >> .yarnrc.yml
|
|
echo -e "\nenableHardenedMode: false" >> .yarnrc.yml
|
|
yarn install
|
|
|
|
# Detox runtime may indirectly import the built config, and that would crash if message-system is not built
|
|
- name: Sign message system config
|
|
working-directory: ./suite-common/message-system
|
|
run: yarn sign-config
|
|
|
|
- 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: Download Android build artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: android-test-build-${{ github.run_id }}
|
|
path: suite-native/app/android/app/build/
|
|
|
|
- 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 }}
|
|
PUBLISH_RESULTS_TO_GITHUB: ${{ inputs.publish_results_to_github == true }}
|
|
TRADING_ACADEMIC_SEED_WALLET_PASSPHRASE: ${{ secrets.E2E_TEST_PASSPHRASE }}
|
|
GITHUB_ACTION: true
|
|
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 }}
|
|
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 --config=e2e/trezorDetoxRunner/config/runner-android-release.config.js --shard=${{ matrix.TEST_GROUP }} --totalShards=4 --headless
|
|
|
|
- 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-${{ matrix.TEST_GROUP }}
|
|
path: suite-native/app/artifacts
|
|
retention-days: 14
|
|
|
|
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 }}"
|