Skip to content

Commit 0e721a4

Browse files
ammarahm-edthecodrr
authored andcommittedNov 13, 2024·
mobile: add e2e test workflow
1 parent e0a704d commit 0e721a4

File tree

5 files changed

+101
-6
lines changed

5 files changed

+101
-6
lines changed
 

‎.github/workflows/android.e2e.yml

+91-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,100 @@
1-
21
name: e2e-android
32
on: workflow_dispatch
43

54
jobs:
65
e2e-android:
76
runs-on: ubuntu-latest
7+
env:
8+
API_LEVEL: 34
9+
ARCH: x86_64
810

911
steps:
1012
- name: Checkout repository
11-
uses: actions/checkout@v4
13+
uses: actions/checkout@v4
14+
15+
- name: Enable KVM
16+
run: |
17+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
18+
sudo udevadm control --reload-rules
19+
sudo udevadm trigger --name-match=kvm
20+
21+
- name: Free Disk Space
22+
uses: jlumbroso/free-disk-space@main
23+
with:
24+
tool-cache: false
25+
android: false
26+
27+
- name: Setup Node
28+
uses: ./.github/actions/setup-node-with-cache
29+
30+
- name: Install node modules
31+
run: |
32+
npm ci --ignore-scripts --prefer-offline --no-audit
33+
npm run bootstrap -- --scope=mobile
34+
35+
- name: Setup Gradle
36+
uses: gradle/actions/setup-gradle@v3
37+
with:
38+
gradle-version: wrapper
39+
cache-read-only: false
40+
41+
- name: Use specific Java version for the builds
42+
uses: joschi/setup-jdk@v2
43+
with:
44+
java-version: "17"
45+
architecture: "x64"
46+
47+
- name: Install Detox CLI
48+
run: npm install detox-cli --global
49+
50+
- name: Detox build
51+
run: |
52+
yarn build:android
53+
ls apps/mobile/native/android/app/build/outputs/apk
54+
ls apps/mobile/native/android/app/build/outputs/apk/release
55+
56+
- name: Get device name
57+
id: device
58+
run: |
59+
AVD_NAME=$(node -p "require('./apps/mobile/native/.detoxrc.js').devices.emulator.device.avdName")
60+
echo "AVD_NAME=$AVD_NAME" >> $GITHUB_OUTPUT
61+
62+
- name: AVD cache
63+
uses: actions/cache@v4
64+
id: avd-cache
65+
with:
66+
path: |
67+
~/.android/avd/*
68+
~/.android/adb*
69+
key: ${{ steps.device.outputs.AVD_NAME }}
70+
71+
- name: create AVD and generate snapshot for caching
72+
if: steps.avd-cache.outputs.cache-hit != 'true'
73+
uses: reactivecircus/android-emulator-runner@v2
74+
with:
75+
api-level: ${{ env.API_LEVEL }}
76+
arch: ${{ env.ARCH }}
77+
avd-name: ${{ steps.device.outputs.AVD_NAME }}
78+
force-avd-creation: false
79+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
80+
disable-animations: true
81+
script: echo "Generated AVD snapshot for caching."
82+
83+
- name: Detox test
84+
uses: reactivecircus/android-emulator-runner@v2
85+
with:
86+
api-level: ${{ env.API_LEVEL }}
87+
arch: ${{ env.ARCH }}
88+
avd-name: ${{ steps.device.outputs.AVD_NAME }}
89+
disable-animations: true
90+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
91+
force-avd-creation: false
92+
script: yarn test:android --headless --record-logs failing --record-videos failing --take-screenshots failing
93+
94+
- name: Upload artifacts
95+
if: failure()
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: detox-artifacts
99+
path: artifacts
100+
retention-days: 14

‎apps/mobile/native/android/gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF
1616
# This option should only be used with decoupled projects. More details, visit
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1818
# org.gradle.parallel=true
19+
org.gradle.configuration-cache=true
1920

2021
# AndroidX package structure to make it clearer which packages are bundled with the
2122
# Android operating system, and which are packaged with your app's APK

‎apps/mobile/native/globals.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import { i18n } from "@lingui/core";
1818
import { ScriptManager, Script } from '@callstack/repack/client';
1919
import {
2020
messages as $en
21-
} from "@notesnook/intl/locales/$en.json";
21+
} from "@notesnook/intl/dist/locales/$en.json";
2222
import {
2323
messages as $pseudo
24-
} from "@notesnook/intl/locales/$pseudo-LOCALE.json";
24+
} from "@notesnook/intl/dist/locales/$pseudo-LOCALE.json";
2525

2626
i18n.load({
2727
en: __DEV__ ? $pseudo : $en

‎packages/editor-mobile/src/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ import "./index.css";
3131
if (globalThis.__DEV__) {
3232
const logFn = global.console.log;
3333
global.console.log = function () {
34+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
3435
//@ts-ignore
36+
// eslint-disable-next-line prefer-rest-params
3537
logFn.apply(console, arguments);
38+
// eslint-disable-next-line prefer-rest-params
3639
globalThis.logger("info", ...arguments);
3740
};
3841
}
@@ -52,7 +55,7 @@ function loadApp() {
5255
})
5356
);
5457

55-
locale.then((locale) => {
58+
locale.then((locale: { [name: string]: any }) => {
5659
i18n.load(locale);
5760
i18n.activate(globalThis.LINGUI_LOCALE || "en");
5861
setI18nGlobal(i18n);

‎packages/editor-mobile/tsconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"lib": ["dom", "dom.iterable", "esnext"],
66
"jsx": "react-jsx",
77
"noEmit": true,
8-
"allowJs": true
8+
"allowJs": true,
9+
"moduleResolution": "nodenext",
10+
"module": "nodenext"
911
},
1012
"include": ["src/"]
1113
}

0 commit comments

Comments
 (0)
Please sign in to comment.