Skip to content

Commit bb76037

Browse files
cunhabrunoabdurrahman-ledger
authored andcommitted
test(e2e): enhance detox video options patch
1 parent c365923 commit bb76037

File tree

8 files changed

+60
-31
lines changed

8 files changed

+60
-31
lines changed

apps/ledger-live-mobile/detox.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
jest: {
1313
setupTimeout: 500000,
1414
},
15-
retries: process.env.CI ? 2 : 0,
15+
retries: 0,
1616
},
1717
logger: {
1818
level: process.env.DEBUG_DETOX ? "trace" : "info",

apps/ledger-live-mobile/scripts/e2e-ci.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const test_ios = async () => {
7474
--take-screenshots failing \
7575
--forceExit \
7676
--headless \
77+
--retries 2 \
7778
--cleanup \
7879
${filteredArgs}`.nothrow();
7980
process.exitCode = result.exitCode;
@@ -91,6 +92,7 @@ const test_android = async () => {
9192
--take-screenshots failing \\
9293
--forceExit \\
9394
--headless \\
95+
--retries 2 \\
9496
--cleanup \\
9597
${filteredArgs}`.nothrow();
9698
process.exitCode = result.exitCode;

e2e/mobile/detox.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = {
3030
teardownTimeout: 120000,
3131
},
3232
noRetryArgs: ["json", "outputFile"],
33-
retries: process.env.CI ? 2 : 0,
33+
retries: 0,
3434
forwardEnv: true, // Used to forward DETOX_CONFIGURATION to Jest workers
3535
},
3636
logger: {

e2e/mobile/jest.globalSetup.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ register({
88

99
import { globalSetup } from "detox/runners/jest";
1010
import { log } from "detox";
11-
import { session as detoxSession } from "detox/internals";
11+
import { session as detoxSession, config as detoxConfig } from "detox/internals";
1212
import * as fs from "fs/promises";
1313
import * as path from "path";
1414
import { exec } from "child_process";
@@ -35,8 +35,6 @@ export default async function setup(): Promise<void> {
3535
await globalSetup();
3636

3737
const testSessionIndex = detoxSession.testSessionIndex ?? 0;
38-
// eslint-disable-next-line @typescript-eslint/no-require-imports
39-
const detoxConfig = require("./detox.config.js");
4038
const maxRetries = detoxConfig.testRunner?.retries ?? 0;
4139
const isLastRetry = maxRetries > 0 && testSessionIndex >= maxRetries;
4240

patches/detox-allure2-adapter@1.0.0-alpha.42.patch

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- a/dist/listener.js
22
+++ b/dist/listener.js
3-
@@ -75,8 +75,20 @@
3+
@@ -75,8 +75,21 @@
44
onError,
55
});
66
}
@@ -15,11 +15,21 @@
1515
+ // If enabled via env var, check for JSON options or use defaults
1616
+ if (enableVideoFromEnv) {
1717
+ try {
18-
+ baseOptions = process.env.DETOX_VIDEO_OPTIONS ? JSON.parse(process.env.DETOX_VIDEO_OPTIONS) : { android: { recording: { bitRate: 1000000, maxSize: 720, codec: 'h264' }, audio: false, window: false }, ios: { codec: 'hevc' } };
18+
+ baseOptions = process.env.DETOX_VIDEO_OPTIONS ? JSON.parse(process.env.DETOX_VIDEO_OPTIONS) : {};
1919
+ } catch (e) {
20+
+ console.warn('Failed to parse DETOX_VIDEO_OPTIONS:', e instanceof Error ? e.message : String(e));
2021
+ baseOptions = {};
2122
+ }
2223
+ }
2324
videoManager = new video_1.VideoManager({ device, options: baseOptions, onError });
2425
}
2526
if (deviceViewHierarchy && viewHierarchyFactory) {
27+
@@ -152,7 +165,7 @@
28+
})
29+
.on('test_fn_failure', async () => {
30+
failing = true;
31+
- await Promise.all([logs?.attachAfterFailure(api_1.allure), screenshots?.attachFailure(api_1.allure)]);
32+
+ await Promise.all([logs?.attachAfterFailure(api_1.allure), screenshots?.attachFailure(api_1.allure), videoManager?.stopAndAttach($test, failing)]);
33+
})
34+
.on('test_fn_success', async () => {
35+
await Promise.all([logs?.attachAfterSuccess(api_1.allure), screenshots?.attachSuccess(api_1.allure)]);

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/actions/composites/upload-allure-report/action.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,7 @@ runs:
4242
echo "path=${PATH_VALUE}" >> "$GITHUB_OUTPUT"
4343
- name: Compress PNG files
4444
shell: bash
45-
run: |
46-
if command -v pngquant &> /dev/null; then
47-
echo "pngquant already installed"
48-
else
49-
echo "Installing pngquant..."
50-
if [[ "$OSTYPE" == "darwin"* ]]; then
51-
brew install pngquant
52-
else
53-
sudo apt-get update && sudo apt-get install -y pngquant
54-
fi
55-
fi
56-
57-
PNG_COUNT=$(find "${{ inputs.path }}" -type f -name "*.png" 2>/dev/null | wc -l)
58-
echo "Found $PNG_COUNT PNG files to compress"
59-
60-
if [ "$PNG_COUNT" -gt 0 ]; then
61-
find "${{ inputs.path }}" -type f -name "*.png" -exec pngquant --quality=65-80 --skip-if-larger --ext .png --force {} \;
62-
echo "PNG compression completed"
63-
fi
45+
run: ${{ github.action_path }}/compress-pngs.sh "${{ inputs.path }}"
6446
- name: Publish report on Allure Server
6547
id: publish-report
6648
uses: LedgerHQ/send-to-allure-server-action@2.1.2
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Compress PNG files in a directory using pngquant
5+
# Usage: compress-pngs.sh <directory>
6+
7+
TARGET_DIR="${1:-}"
8+
9+
if [ -z "$TARGET_DIR" ]; then
10+
echo "::error::No directory specified"
11+
exit 1
12+
fi
13+
14+
if [ ! -d "$TARGET_DIR" ]; then
15+
echo "::warning::Directory '$TARGET_DIR' not found. Skipping PNG compression."
16+
exit 0
17+
fi
18+
19+
# Install pngquant if not available
20+
if command -v pngquant &> /dev/null; then
21+
echo "pngquant already installed"
22+
else
23+
echo "Installing pngquant..."
24+
if [[ "$OSTYPE" == "darwin"* ]]; then
25+
brew install pngquant
26+
else
27+
sudo apt-get update && sudo apt-get install -y pngquant
28+
fi
29+
fi
30+
31+
PNG_COUNT=$(find "$TARGET_DIR" -type f -name "*.png" 2>/dev/null | wc -l | tr -d ' ')
32+
echo "Found $PNG_COUNT PNG files to compress"
33+
34+
if [ "$PNG_COUNT" -gt 0 ]; then
35+
find "$TARGET_DIR" -type f -name "*.png" -exec pngquant --quality=65-80 --skip-if-larger --ext .png --force {} \;
36+
echo "PNG compression completed"
37+
fi

0 commit comments

Comments
 (0)