Skip to content

Commit

Permalink
Merge pull request #7831 from LedgerHQ/support/qaa_195_speculos_llm_ci
Browse files Browse the repository at this point in the history
[QAA-195][Detox][Speculos] Add Android Speculos tests to CI
  • Loading branch information
abdurrahman-ledger authored Sep 26, 2024
2 parents 4847469 + f037f76 commit c8c006c
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 6 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/test-mobile-e2e-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ on:
description: "[iOS] Test Execution ticket ID. Ex: 'B2CQA-2461'"
required: false
type: string
speculos_tests:
description: Run Speculos tests
required: false
type: boolean
default: false

# Uncomment to have log-level: trace on detox run and build
# (cf: apps/ledger-live-mobile/detox.config.js)
Expand Down Expand Up @@ -173,6 +178,8 @@ jobs:
AVD_CORES: 4
AVD_RAM_SIZE: 4096M
AVD_OPTIONS: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
SPECULOS_IMAGE_TAG: ghcr.io/ledgerhq/speculos:0.9.5
COINAPPS: ${{ github.workspace }}/coin-apps
outputs:
status: ${{ steps.detox.outcome }}
steps:
Expand Down Expand Up @@ -255,12 +262,22 @@ jobs:
disable-linux-hw-accel: false
emulator-options: ${{ env.AVD_OPTIONS }}
script: ./tools/scripts/wait_emulator_idle.sh
- name: Setup Speculos image and Coin Apps
if: ${{ inputs.speculos_tests }}
uses: LedgerHQ/ledger-live/tools/actions/composites/setup-speculos_image@develop
with:
coinapps_path: ${{ env.COINAPPS }}
speculos_tag: ${{ env.SPECULOS_IMAGE_TAG }}
bot_id: ${{ secrets.GH_BOT_APP_ID }}
bot_key: ${{ secrets.GH_BOT_PRIVATE_KEY }}
- name: Run Android Tests
id: detox
run: pnpm mobile e2e:ci -p android -t
run: pnpm mobile e2e:ci -p android -t $([[ "$INPUT_SPECULOS" == "true" ]] && printf %s '--speculos')
timeout-minutes: 45
env:
DETOX_INSTALL_TIMEOUT: 120000
SEED: ${{ secrets.SEED_QAA_B2C }}
INPUT_SPECULOS: ${{ inputs.speculos_tests }}
- name: Generate single file Allure report
if: ${{ !cancelled() || steps.detox.outcome == 'cancelled' }}
run: pnpm dlx allure-commandline generate apps/ledger-live-mobile/artifacts --single-file
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test-mobile-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ on:
description: "[iOS] Test Execution ticket ID. Ex: 'B2CQA-2461'"
required: false
type: string
speculos_tests:
description: Run Speculos tests
required: false
type: boolean
default: false

# Uncomment to have log-level: trace on detox run and build
# (cf: apps/ledger-live-mobile/detox.config.js)
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/bridge/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface ProxyOptions {
speculosApiPort: string;
}

export async function startProxy(speculosApiPort?: string, proxyPort?: string): Promise<string> {
export async function startProxy(proxyPort?: string, speculosApiPort?: string): Promise<string> {
if (!proxyPort) proxyPort = (await findFreePort()).toString();
if (!speculosApiPort) speculosApiPort = getEnv("SPECULOS_API_PORT").toString();
invariant(speculosApiPort, "E2E Proxy : speculosApiPort is not defined");
Expand Down
5 changes: 4 additions & 1 deletion apps/ledger-live-mobile/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ export async function launchSpeculos(appName: string) {
invariant(speculosApiPort, "[E2E Setup] speculosApiPort not defined");
setEnv("SPECULOS_API_PORT", speculosApiPort);

const proxyAddress = await startProxy();
const proxyPort = await findFreePort();
await device.reverseTcpPort(proxyPort);
await startProxy(proxyPort.toString());
const proxyAddress = `localhost:${proxyPort}`;
speculosDevices.push([proxyAddress, speculosDevice]);
console.warn(`Speculos started on ${proxyAddress}`);
return proxyAddress;
Expand Down
1 change: 1 addition & 0 deletions apps/ledger-live-mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"e2e:build": "pnpm detox build",
"e2e:ci": "zx ./scripts/e2e-ci.mjs",
"e2e:test": "pnpm detox test",
"e2e:test:speculos": "pnpm detox test --testMatch $(pwd)/e2e/specs/speculos/**/*.spec.ts",
"prebeta": "bundle install",
"debug:detox": "pnpm detox test -c ios.manual currencies.spec.ts",
"ios:staging": "ENVFILE=.env.ios.staging react-native run-ios --mode Staging",
Expand Down
10 changes: 7 additions & 3 deletions apps/ledger-live-mobile/scripts/e2e-ci.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import { basename } from "path";

let platform, test, build, bundle;
let speculos = "";
let cache = true;

const usage = (exitCode = 1) => {
console.log(
`Usage: ${basename(
__filename,
)} -p --platform <ios|android> [-h --help] [-t --test] [-b --build] [--bundle] [--cache | --no-cache]`,
)} -p --platform <ios|android> [-h --help] [-t --test] [-b --build] [--bundle] [--cache | --no-cache] [--speculos]`,
);
process.exit(exitCode);
};
Expand All @@ -34,7 +35,7 @@ const bundle_ios_with_cache = async () => {
};

const test_ios = async () => {
await $`pnpm mobile e2e:test \
await $`pnpm mobile e2e:test${speculos} \
-c ios.sim.release \
--loglevel error \
--record-logs all \
Expand All @@ -50,7 +51,7 @@ const build_android = async () => {
};

const test_android = async () => {
await $`pnpm mobile e2e:test \\
await $`pnpm mobile e2e:test${speculos} \\
-c android.emu.release \\
--loglevel error \\
--record-logs all \\
Expand Down Expand Up @@ -104,6 +105,9 @@ for (const argName in argv) {
break;
case "_":
break;
case "speculos":
speculos = ":speculos";
break;
default:
usage(42);
break;
Expand Down
34 changes: 34 additions & 0 deletions tools/actions/composites/setup-speculos_image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Setup Speculos Image and Coin Apps"
description: "Uploading allure report to Allure Server"
inputs:
coinapps_path:
required: true
description: "Path to the coin apps folder"
speculos_tag:
required: false
description: "Speculos docker image tag"
bot_id:
description: "GitHub Bot ID"
bot_key:
description: "GitHub Bot private key"

runs:
using: composite

steps:
- name: Generate token
id: generate-token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ inputs.bot_id }}
private_key: ${{ inputs.bot_key }}
- name: Retrieving coin apps
uses: actions/checkout@v4
with:
ref: master
repository: LedgerHQ/coin-apps
token: ${{ steps.generate-token.outputs.token }}
path: ${{ inputs.coinapps_path }}
- name: Pull docker image
run: docker pull ${{ inputs.speculos_tag }}
shell: bash

0 comments on commit c8c006c

Please sign in to comment.