Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: add e2e test workflow

Ammar Ahmed0e721a4948b9
diff --git a/.github/workflows/android.e2e.yml b/.github/workflows/android.e2e.yml
index 484610aa8..1c71e6041 100644
--- a/.github/workflows/android.e2e.yml
+++ b/.github/workflows/android.e2e.yml
@@ -1,11 +1,100 @@
-
name: e2e-android
on: workflow_dispatch
jobs:
e2e-android:
runs-on: ubuntu-latest
+ env:
+ API_LEVEL: 34
+ ARCH: x86_64
steps:
- name: Checkout repository
- uses: actions/checkout@v4
\ No newline at end of file
+ uses: actions/checkout@v4
+
+ - name: Enable KVM
+ 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: Free Disk Space
+ uses: jlumbroso/free-disk-space@main
+ with:
+ tool-cache: false
+ android: false
+
+ - name: Setup Node
+ uses: ./.github/actions/setup-node-with-cache
+
+ - name: Install node modules
+ run: |
+ npm ci --ignore-scripts --prefer-offline --no-audit
+ npm run bootstrap -- --scope=mobile
+
+ - name: Setup Gradle
+ uses: gradle/actions/setup-gradle@v3
+ with:
+ gradle-version: wrapper
+ cache-read-only: false
+
+ - name: Use specific Java version for the builds
+ uses: joschi/setup-jdk@v2
+ with:
+ java-version: "17"
+ architecture: "x64"
+
+ - name: Install Detox CLI
+ run: npm install detox-cli --global
+
+ - name: Detox build
+ run: |
+ yarn build:android
+ ls apps/mobile/native/android/app/build/outputs/apk
+ ls apps/mobile/native/android/app/build/outputs/apk/release
+
+ - name: Get device name
+ id: device
+ run: |
+ AVD_NAME=$(node -p "require('./apps/mobile/native/.detoxrc.js').devices.emulator.device.avdName")
+ echo "AVD_NAME=$AVD_NAME" >> $GITHUB_OUTPUT
+
+ - name: AVD cache
+ uses: actions/cache@v4
+ id: avd-cache
+ with:
+ path: |
+ ~/.android/avd/*
+ ~/.android/adb*
+ key: ${{ steps.device.outputs.AVD_NAME }}
+
+ - name: create AVD and generate snapshot for caching
+ if: steps.avd-cache.outputs.cache-hit != 'true'
+ uses: reactivecircus/android-emulator-runner@v2
+ with:
+ api-level: ${{ env.API_LEVEL }}
+ arch: ${{ env.ARCH }}
+ avd-name: ${{ steps.device.outputs.AVD_NAME }}
+ force-avd-creation: false
+ emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
+ disable-animations: true
+ script: echo "Generated AVD snapshot for caching."
+
+ - name: Detox test
+ uses: reactivecircus/android-emulator-runner@v2
+ with:
+ api-level: ${{ env.API_LEVEL }}
+ arch: ${{ env.ARCH }}
+ avd-name: ${{ steps.device.outputs.AVD_NAME }}
+ disable-animations: true
+ emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
+ force-avd-creation: false
+ script: yarn test:android --headless --record-logs failing --record-videos failing --take-screenshots failing
+
+ - name: Upload artifacts
+ if: failure()
+ uses: actions/upload-artifact@v4
+ with:
+ name: detox-artifacts
+ path: artifacts
+ retention-days: 14
diff --git a/apps/mobile/native/android/gradle.properties b/apps/mobile/native/android/gradle.properties
index 862815fea..882bfa98f 100644
--- a/apps/mobile/native/android/gradle.properties
+++ b/apps/mobile/native/android/gradle.properties
@@ -16,6 +16,7 @@ org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
+org.gradle.configuration-cache=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
diff --git a/apps/mobile/native/globals.js b/apps/mobile/native/globals.js
index 3b51343d7..072001385 100644
--- a/apps/mobile/native/globals.js
+++ b/apps/mobile/native/globals.js
@@ -18,10 +18,10 @@ import { i18n } from "@lingui/core";
import { ScriptManager, Script } from '@callstack/repack/client';
import {
messages as $en
-} from "@notesnook/intl/locales/$en.json";
+} from "@notesnook/intl/dist/locales/$en.json";
import {
messages as $pseudo
-} from "@notesnook/intl/locales/$pseudo-LOCALE.json";
+} from "@notesnook/intl/dist/locales/$pseudo-LOCALE.json";
i18n.load({
en: __DEV__ ? $pseudo : $en
diff --git a/packages/editor-mobile/src/index.tsx b/packages/editor-mobile/src/index.tsx
index 3c4b60a6f..a784d2f7a 100644
--- a/packages/editor-mobile/src/index.tsx
+++ b/packages/editor-mobile/src/index.tsx
@@ -31,8 +31,11 @@ import "./index.css";
if (globalThis.__DEV__) {
const logFn = global.console.log;
global.console.log = function () {
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
+ // eslint-disable-next-line prefer-rest-params
logFn.apply(console, arguments);
+ // eslint-disable-next-line prefer-rest-params
globalThis.logger("info", ...arguments);
};
}
@@ -52,7 +55,7 @@ function loadApp() {
})
);
- locale.then((locale) => {
+ locale.then((locale: { [name: string]: any }) => {
i18n.load(locale);
i18n.activate(globalThis.LINGUI_LOCALE || "en");
setI18nGlobal(i18n);
diff --git a/packages/editor-mobile/tsconfig.json b/packages/editor-mobile/tsconfig.json
index 3847e6cd4..28f4f70de 100644
--- a/packages/editor-mobile/tsconfig.json
+++ b/packages/editor-mobile/tsconfig.json
@@ -5,7 +5,9 @@
"lib": ["dom", "dom.iterable", "esnext"],
"jsx": "react-jsx",
"noEmit": true,
- "allowJs": true
+ "allowJs": true,
+ "moduleResolution": "nodenext",
+ "module": "nodenext"
},
"include": ["src/"]
}