mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-08-29 18:19:38 +02:00
Compare commits
17 Commits
master
...
mobile-tes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
515a1231aa | ||
|
|
ca17236337 | ||
|
|
2e8088eacc | ||
|
|
c43c5e847a | ||
|
|
9688e140c6 | ||
|
|
e61f34010c | ||
|
|
fffdddbb9c | ||
|
|
240d087d62 | ||
|
|
393aeaaaad | ||
|
|
5747123b86 | ||
|
|
4c9e081501 | ||
|
|
efaa4db6b6 | ||
|
|
7f4ccc8462 | ||
|
|
76797a450a | ||
|
|
f6e3e30194 | ||
|
|
522c78f0b1 | ||
|
|
b8293a4305 |
183
.github/workflows/android.preview.firebase.test.yml
vendored
Normal file
183
.github/workflows/android.preview.firebase.test.yml
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
name: Notesnook Android Preview Test Cache
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
branches: [master, beta]
|
||||
paths:
|
||||
- "apps/mobile/**"
|
||||
- "packages/**"
|
||||
# re-run workflow if workflow file changes
|
||||
- ".github/workflows/android.preview.firebase.test.yml"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
STAGING_BUILD: true
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node
|
||||
uses: ./.github/actions/setup-node-with-cache
|
||||
|
||||
- name: Use specific Java version for the builds
|
||||
uses: joschi/setup-jdk@v2
|
||||
with:
|
||||
java-version: "17"
|
||||
architecture: "x64"
|
||||
|
||||
- name: Free Disk Space (Ubuntu)
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
# this might remove tools that are actually needed,
|
||||
# if set to "true" but frees about 6 GB
|
||||
tool-cache: false
|
||||
|
||||
# all of these default to true, but feel free to set to
|
||||
# "false" if necessary for your workflow
|
||||
android: false
|
||||
dotnet: true
|
||||
haskell: true
|
||||
large-packages: false
|
||||
docker-images: false
|
||||
swap-storage: false
|
||||
|
||||
- name: Install node modules
|
||||
run: |
|
||||
npm ci --ignore-scripts --prefer-offline --no-audit
|
||||
npm run bootstrap -- --scope=mobile
|
||||
|
||||
- name: Generate dependency hash
|
||||
id: dep-hash
|
||||
run: |
|
||||
DEPS_HASH=$(node -e "
|
||||
const pkg = require('./apps/mobile/package.json');
|
||||
const crypto = require('crypto');
|
||||
const depsStr = JSON.stringify(pkg.dependencies);
|
||||
const hash = crypto.createHash('md5').update(depsStr).digest('hex');
|
||||
console.log(hash);
|
||||
")
|
||||
echo "hash=$DEPS_HASH" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache Android build files
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
apps/mobile/android/.gradle
|
||||
apps/mobile/android/build
|
||||
apps/mobile/android/app/build
|
||||
apps/mobile/android/app/.cxx
|
||||
apps/mobile/node_modules/**/android/build
|
||||
apps/mobile/node_modules/**/android/.cxx
|
||||
apps/mobile/node_modules/**/android/generated
|
||||
apps/mobile/node_modules/**/.gradle
|
||||
apps/mobile/node_modules/**/.cxx
|
||||
key: android-build-${{ runner.os }}-deps-${{ steps.dep-hash.outputs.hash }}
|
||||
restore-keys: |
|
||||
android-build-${{ runner.os }}-
|
||||
|
||||
- name: Make Gradlew Executable
|
||||
run: cd apps/mobile/android && chmod +x ./gradlew
|
||||
|
||||
- name: Get build number
|
||||
id: build-number
|
||||
run: echo "timestamp=$(($(date +%s) - 1774851180 ))" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Check for typescript errors
|
||||
run: |
|
||||
npm run tx mobile:build
|
||||
cd apps/mobile
|
||||
npx tsc --noEmit
|
||||
|
||||
- name: Apply optimize-build.gradle to native modules
|
||||
run: |
|
||||
modules=(
|
||||
"react-native-gesture-handler"
|
||||
"react-native-mmkv-storage"
|
||||
"react-native-nitro-cloud-uploader"
|
||||
"react-native-nitro-modules"
|
||||
"react-native-reanimated"
|
||||
"react-native-screens"
|
||||
"react-native-worklets"
|
||||
"react-native-quick-sqlite"
|
||||
)
|
||||
for module in "${modules[@]}"; do
|
||||
gradle_file="apps/mobile/node_modules/${module}/android/build.gradle"
|
||||
if [ -f "$gradle_file" ]; then
|
||||
if ! grep -qF "apply from: '../../../scripts/optimize-build.gradle'" "$gradle_file"; then
|
||||
echo "" >> "$gradle_file"
|
||||
echo "apply from: '../../../scripts/optimize-build.gradle'" >> "$gradle_file"
|
||||
echo "Patched $gradle_file"
|
||||
else
|
||||
echo "Already patched: $gradle_file"
|
||||
fi
|
||||
else
|
||||
echo "WARNING: $gradle_file not found, skipping."
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Build arm64-v8a apk
|
||||
run: |
|
||||
cd apps/mobile/android
|
||||
./gradlew assembleRelease -PreactNativeArchitectures=arm64-v8a -PstagingReleaseBuild=true -PprBuildNumber=${{ steps.build-number.outputs.timestamp }}
|
||||
|
||||
##
|
||||
# - name: Get app version
|
||||
# id: package-version
|
||||
# uses: saionaro/extract-package-version@master
|
||||
# with:
|
||||
# path: apps/mobile
|
||||
|
||||
# - name: Publish to firebase CLI
|
||||
# id: firebase-output
|
||||
# uses: wzieba/Firebase-Distribution-Github-Action@v1
|
||||
# with:
|
||||
# appId: ${{secrets.FIREBASE_APP_ID}}
|
||||
# serviceCredentialsFileContent: ${{ secrets.QA_SERVICE_ACCOUNT }}
|
||||
# groups: testers
|
||||
# file: apps/mobile/android/app/build/outputs/apk/release/app-arm64-v8a-release.apk
|
||||
# releaseNotes: Preview for https://github.com/streetwriters/notesnook/pull/${{github.event.number}}
|
||||
|
||||
# - name: Post or update PR comment
|
||||
# uses: actions/github-script@v6
|
||||
# env:
|
||||
# preview_url: ${{ steps.firebase-output.outputs.TESTING_URI }}
|
||||
# with:
|
||||
# script: |
|
||||
# const marker = '<!-- android-preview-comment -->';
|
||||
# const prNumber = context.issue.number;
|
||||
# const previewUrl = process.env.preview_url || '';
|
||||
# const body = `${marker}\n**Android App Preview**\n\n${previewUrl || 'Preview URL unavailable — check workflow logs.'}\n\nCommit: ${process.env.GITHUB_SHA}\n`;
|
||||
# const { data: comments } = await github.rest.issues.listComments({
|
||||
# owner: context.repo.owner,
|
||||
# repo: context.repo.repo,
|
||||
# issue_number: prNumber,
|
||||
# });
|
||||
# const existing = comments.find(c => c.body && c.body.includes(marker));
|
||||
# if (existing) {
|
||||
# await github.rest.issues.updateComment({
|
||||
# owner: context.repo.owner,
|
||||
# repo: context.repo.repo,
|
||||
# comment_id: existing.id,
|
||||
# body,
|
||||
# });
|
||||
# } else {
|
||||
# await github.rest.issues.createComment({
|
||||
# owner: context.repo.owner,
|
||||
# repo: context.repo.repo,
|
||||
# issue_number: prNumber,
|
||||
# body,
|
||||
# });
|
||||
# }
|
||||
|
||||
# - name: Upload sourcemaps
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: sourcemaps
|
||||
# path: |
|
||||
# apps/mobile/android/app/build/generated/sourcemaps/**/*.map
|
||||
@@ -15,7 +15,7 @@ org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# 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.parallel=true
|
||||
# org.gradle.configuration-cache=true
|
||||
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
|
||||
@@ -10,6 +10,7 @@ import { setI18nGlobal } from "@notesnook/intl";
|
||||
import { i18n } from "@lingui/core";
|
||||
import Config from "react-native-config";
|
||||
|
||||
const testchange = 1;
|
||||
let domParser;
|
||||
Object.defineProperty(global, "DOMParser", {
|
||||
get: () => {
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
diff --git a/node_modules/react-native-nitro-cloud-uploader/android/build.gradle b/node_modules/react-native-nitro-cloud-uploader/android/build.gradle
|
||||
index 89d0be6..8703e89 100644
|
||||
--- a/node_modules/react-native-nitro-cloud-uploader/android/build.gradle
|
||||
+++ b/node_modules/react-native-nitro-cloud-uploader/android/build.gradle
|
||||
@@ -43,7 +43,7 @@ android {
|
||||
namespace "com.margelo.nitro.nitroclouduploader"
|
||||
|
||||
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
||||
-
|
||||
+ ndkVersion getExtOrDefault("ndkVersion")
|
||||
defaultConfig {
|
||||
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
||||
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
||||
diff --git a/node_modules/react-native-nitro-cloud-uploader/android/src/main/AndroidManifest.xml b/node_modules/react-native-nitro-cloud-uploader/android/src/main/AndroidManifest.xml
|
||||
index 9ea903a..e023649 100644
|
||||
--- a/node_modules/react-native-nitro-cloud-uploader/android/src/main/AndroidManifest.xml
|
||||
|
||||
90
apps/mobile/scripts/optimize-build.gradle
Normal file
90
apps/mobile/scripts/optimize-build.gradle
Normal file
@@ -0,0 +1,90 @@
|
||||
import java.security.MessageDigest
|
||||
|
||||
def hasReleaseNativeSoInIntermediates = {
|
||||
!fileTree(dir: "$buildDir/intermediates", include: ["**/release/**/*.so", "**/*Release*/**/*.so"]).isEmpty()
|
||||
}
|
||||
|
||||
def releasePackageJsonFile = file("$buildDir/../../package.json")
|
||||
def releaseNativeFingerprintFile = file("$buildDir/intermediates/release-native-build/package-json.sha256")
|
||||
|
||||
def sha256ForFile = { targetFile ->
|
||||
def digest = MessageDigest.getInstance("SHA-256")
|
||||
targetFile.withInputStream { stream ->
|
||||
byte[] buffer = new byte[8192]
|
||||
int bytesRead
|
||||
while ((bytesRead = stream.read(buffer)) != -1) {
|
||||
digest.update(buffer, 0, bytesRead)
|
||||
}
|
||||
}
|
||||
digest.digest().encodeHex().toString()
|
||||
}
|
||||
|
||||
def hasValidReleaseNativeSoInIntermediates = {
|
||||
if (!hasReleaseNativeSoInIntermediates()) {
|
||||
logger.lifecycle("No release .so artifacts found in $buildDir/intermediates; release native build will run.")
|
||||
return false
|
||||
}
|
||||
|
||||
if (!releasePackageJsonFile.exists()) {
|
||||
logger.lifecycle("package.json not found at ${releasePackageJsonFile.absolutePath}; release native build will run.")
|
||||
return false
|
||||
}
|
||||
|
||||
if (!releaseNativeFingerprintFile.exists()) {
|
||||
logger.lifecycle("No existing package.json fingerprint found at ${releaseNativeFingerprintFile.absolutePath}; release native build will run and create it.")
|
||||
return false
|
||||
}
|
||||
|
||||
def storedFingerprint = releaseNativeFingerprintFile.text.trim()
|
||||
def currentFingerprint = sha256ForFile(releasePackageJsonFile)
|
||||
|
||||
if (storedFingerprint != currentFingerprint) {
|
||||
logger.lifecycle("package.json fingerprint changed; release native build will run and refresh cached artifacts.")
|
||||
return false
|
||||
}
|
||||
|
||||
logger.lifecycle("package.json fingerprint matches existing release .so artifacts.")
|
||||
return true
|
||||
}
|
||||
|
||||
def isReleaseBuildRequested = gradle.startParameter.taskNames.any { it.toLowerCase().contains("release") }
|
||||
|
||||
def verifyReleaseNativeSoOutputsTask = tasks.register("verifyReleaseNativeSoOutputs") {
|
||||
group = "verification"
|
||||
description = "Checks whether release native .so artifacts exist in build/intermediates after native build tasks."
|
||||
doLast {
|
||||
if (hasReleaseNativeSoInIntermediates()) {
|
||||
logger.lifecycle("[optimize-build] Release native .so artifacts exist in $buildDir/intermediates")
|
||||
} else {
|
||||
logger.lifecycle("[optimize-build] Release native .so artifacts do NOT exist in $buildDir/intermediates")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isReleaseBuildRequested) {
|
||||
tasks.configureEach { task ->
|
||||
// Skip release CMake/native tasks when release libs are already present in intermediates.
|
||||
if ((task.name.toLowerCase().contains("cmake") || task.name.startsWith("externalNativeBuild"))) {
|
||||
onlyIf {
|
||||
def shouldRun = !hasValidReleaseNativeSoInIntermediates()
|
||||
if (!shouldRun) {
|
||||
logger.lifecycle("Skipping ${task.path}: found matching release .so artifacts and package.json fingerprint in $buildDir/intermediates")
|
||||
}
|
||||
return shouldRun
|
||||
}
|
||||
|
||||
doLast {
|
||||
if (releasePackageJsonFile.exists()) {
|
||||
def fingerprintAlreadyExists = releaseNativeFingerprintFile.exists()
|
||||
releaseNativeFingerprintFile.parentFile.mkdirs()
|
||||
releaseNativeFingerprintFile.text = sha256ForFile(releasePackageJsonFile)
|
||||
logger.lifecycle("${fingerprintAlreadyExists ? "Updated" : "Created"} package.json fingerprint at ${releaseNativeFingerprintFile.absolutePath}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (task.name.contains("mergeReleaseJniLibFolders")) {
|
||||
finalizedBy(verifyReleaseNativeSoOutputsTask)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user