Compare commits

...

17 Commits

Author SHA1 Message Date
Ammar Ahmed
515a1231aa ci: test run on ubuntu-22.04 2026-04-04 12:35:16 +05:00
Ammar Ahmed
ca17236337 mobile: test cache 2026-04-04 12:28:38 +05:00
Ammar Ahmed
2e8088eacc mobile: skip tasks 2026-04-04 12:25:43 +05:00
Ammar Ahmed
c43c5e847a mobile: test 2026-04-04 11:45:25 +05:00
Ammar Ahmed
9688e140c6 mobile: update 2026-04-04 11:41:35 +05:00
Ammar Ahmed
e61f34010c mobile: check 2026-04-04 11:40:12 +05:00
Ammar Ahmed
fffdddbb9c mobile: test 2026-04-04 11:36:01 +05:00
Ammar Ahmed
240d087d62 mobile: optimize build 2026-04-04 11:02:23 +05:00
Ammar Ahmed
393aeaaaad mobile: up 2026-04-04 09:20:28 +05:00
Ammar Ahmed
5747123b86 mobile: enable paralell build 2026-04-04 00:35:21 +05:00
Ammar Ahmed
4c9e081501 mobile: optimize freeing space 2026-04-04 00:15:27 +05:00
Ammar Ahmed
efaa4db6b6 mobile: push test cache restore 2026-04-03 23:33:46 +05:00
Ammar Ahmed
7f4ccc8462 mobile: update preview 2026-04-03 23:07:25 +05:00
Ammar Ahmed
76797a450a mobile: update 2026-04-03 22:37:40 +05:00
Ammar Ahmed
f6e3e30194 mobile: test 2026-04-03 22:09:37 +05:00
Ammar Ahmed
522c78f0b1 mobile: push 2026-04-03 21:15:01 +05:00
Ammar Ahmed
b8293a4305 ci: add test cache workflow 2026-04-03 21:11:52 +05:00
5 changed files with 288 additions and 1 deletions

View 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

View File

@@ -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

View File

@@ -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: () => {

View File

@@ -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

View 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)
}
}
}