π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Warm complete build caches for PR workflows
Manav Rathi6a53361d482c
diff --git a/.github/actions/deploy-web-app/action.yml b/.github/actions/deploy-web-app/action.ymlindex 3ea8a343ed..dfc076a726 100644--- a/.github/actions/deploy-web-app/action.yml+++ b/.github/actions/deploy-web-app/action.yml@@ -1,22 +1,22 @@-name: "Deploy web app"-description: "Build a web app and publish it to Cloudflare Pages"+name: Deploy web app+description: Build a web app and publish it to Cloudflare Pagesinputs:app:- description: "Web app slug"+ description: Web app slugrequired: trueoutput:- description: "Build output directory within web/apps/<app>"- default: "out"+ description: Build output directory within web/apps/<app>+ default: outaccount-id:- description: "Cloudflare account ID"+ description: Cloudflare account IDrequired: trueapi-token:- description: "Cloudflare API token"+ description: Cloudflare API tokenrequired: trueruns:- using: "composite"+ using: compositesteps:- name: Build ${{ inputs.app }}shell: bashdiff --git a/.github/actions/restore-rust-target/action.yml b/.github/actions/restore-rust-target/action.ymlnew file mode 100644index 0000000000..b48f0f54bf--- /dev/null+++ b/.github/actions/restore-rust-target/action.yml@@ -0,0 +1,39 @@+name: Restore Rust target+description: Restore Rust artifacts and source timestamps++inputs:+ shared-key:+ description: Cache group+ required: true+ lookup-only:+ description: Check without restoring+ default: false++outputs:+ cache-key:+ description: Cache key+ value: ${{ steps.cache.outputs.cache-primary-key }}+ cache-hit:+ description: Exact cache hit+ value: ${{ steps.cache.outputs.cache-hit }}++runs:+ using: composite+ steps:+ # Runner image changes can break cached binaries.+ - id: image+ shell: bash+ run: echo "version=$ImageOS-$ImageVersion" >> "$GITHUB_OUTPUT"++ - id: cache+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: target-${{ inputs.shared-key }}-${{ steps.image.outputs.version }}-${{ github.sha }}+ restore-keys: target-${{ inputs.shared-key }}-${{ steps.image.outputs.version }}-+ path: rust/target+ lookup-only: ${{ inputs.lookup-only }}++ - if: inputs.lookup-only != 'true' && steps.cache.outputs.cache-matched-key != ''+ shell: bash+ working-directory: ${{ github.workspace }}+ run: node .github/actions/restore-rust-target/mtimes.mjs restorediff --git a/.github/actions/restore-rust-target/mtimes.mjs b/.github/actions/restore-rust-target/mtimes.mjsnew file mode 100644index 0000000000..278668d576--- /dev/null+++ b/.github/actions/restore-rust-target/mtimes.mjs@@ -0,0 +1,29 @@+import { execFileSync } from "node:child_process";+import { createHash } from "node:crypto";+import { readFileSync, statSync, utimesSync, writeFileSync } from "node:fs";++const restore = process.argv[2] === "restore";+const manifest = "rust/target/source-mtimes.json";+const mtimes = restore ? JSON.parse(readFileSync(manifest, "utf8")) : {};+const paths = execFileSync("git", ["ls-files", "-z", "--", "rust"], {+ encoding: "utf8",+})+ .split("\0")+ .filter(Boolean);++for (const path of paths) {+ const stat = statSync(path);+ const hash = createHash("sha256")+ .update(readFileSync(path))+ .update(String(stat.mode))+ .digest("hex");+ if (restore) {+ // Preserve real timestamps so older feature builds remain stale.+ const mtime = hash === mtimes[path]?.[0] ? mtimes[path][1] : Date.now();+ utimesSync(path, stat.atime, mtime / 1000);+ } else {+ mtimes[path] = [hash, stat.mtimeMs];+ }+}++if (!restore) writeFileSync(manifest, JSON.stringify(mtimes));diff --git a/.github/actions/setup-flutter/action.yml b/.github/actions/setup-flutter/action.ymlindex 308edc7741..119bfa3d70 100644--- a/.github/actions/setup-flutter/action.yml+++ b/.github/actions/setup-flutter/action.yml@@ -1,16 +1,23 @@-name: "Setup Flutter"-description: "Install the Flutter SDK version used by Ente CI"+name: Setup Flutter+description: Install the Flutter SDK version used by Ente CIruns:- using: "composite"+ using: compositesteps:+ - id: cache+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: flutter-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/actions/setup-flutter/action.yml') }}+ path: ${{ runner.tool_cache }}/flutter+- shell: bashenv:# Update every archive SHA below when changing this version:# https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json# https://storage.googleapis.com/flutter_infra_release/releases/releases_macos.json# https://storage.googleapis.com/flutter_infra_release/releases/releases_windows.json- FLUTTER_VERSION: "3.47.2"+ FLUTTER_VERSION: 3.47.2+ CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}run: |set -euo pipefail@@ -48,21 +55,29 @@ runs:archive_name="${archive##*/}"archive_path="$temp_dir/$archive_name"- curl --retry 3 --retry-all-errors -fsSL "$base_url/$archive" -o "$archive_path"- if [ "$RUNNER_OS" = macOS ]; then- printf '%s %s\n' "$archive_sha256" "$archive_path" | shasum -a 256 -c -- else- printf '%s %s\n' "$archive_sha256" "$archive_path" | sha256sum -c -+ if [ "$CACHE_HIT" != true ]; then+ curl --retry 3 --retry-all-errors -fsSL "$base_url/$archive" -o "$archive_path"+ if [ "$RUNNER_OS" = macOS ]; then+ printf '%s %s\n' "$archive_sha256" "$archive_path" | shasum -a 256 -c -+ else+ printf '%s %s\n' "$archive_sha256" "$archive_path" | sha256sum -c -+ fi+ mkdir -p "$install_root"+ case "$archive_name" in+ *.zip) unzip -q -o "$archive_path" -d "$install_root" ;;+ *) tar xf "$archive_path" -C "$install_root" ;;+ esac+ rm -f "$archive_path"fi- mkdir -p "$install_root"- case "$archive_name" in- *.zip) unzip -q -o "$archive_path" -d "$install_root" ;;- *) tar xf "$archive_path" -C "$install_root" ;;- esac- rm -f "$archive_path"if [ "$RUNNER_OS" = Windows ]; thencygpath -w "$flutter_root/bin" >>"$GITHUB_PATH"elseprintf '%s\n' "$flutter_root/bin" >>"$GITHUB_PATH"fi++ - if: github.ref == 'refs/heads/main' && steps.cache.outputs.cache-hit != 'true'+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: ${{ steps.cache.outputs.cache-primary-key }}+ path: ${{ runner.tool_cache }}/flutterdiff --git a/.github/scripts/ci/paths.json b/.github/scripts/ci/paths.jsonindex c961663241..b9a3fd9bdb 100644--- a/.github/scripts/ci/paths.json+++ b/.github/scripts/ci/paths.json@@ -16,6 +16,7 @@".github/workflows/dependency-review.yml"],"desktop-lint": [+ ".github/actions/restore-rust-target/**",".github/workflows/desktop-lint.yml","desktop/**","rust/Cargo.lock",@@ -28,6 +29,7 @@],"docs-verify-build": [".github/workflows/docs-verify-build.yml", "docs/**"],"ensu-android-build": [+ ".github/actions/restore-rust-target/**",".github/workflows/ensu-android-build.yml","android/build.gradle.kts","android/settings.gradle.kts",@@ -46,6 +48,7 @@"rust/tools/codegen/**"],"ensu-ios-build": [+ ".github/actions/restore-rust-target/**",".github/workflows/ensu-ios-build.yml","apple/apps/ensu/**","apple/packages/EnteOnnxRuntime/**",@@ -62,6 +65,7 @@"infra/staff/**"],"mobile-lint": [+ ".github/actions/restore-rust-target/**",".github/actions/setup-flutter/**",".github/workflows/mobile-lint.yml","mobile/**",@@ -90,13 +94,24 @@],"repo-lint": null,"rust-cli-test": [+ ".github/actions/restore-rust-target/**",".github/workflows/rust-cli-test.yml","rust/apps/cli-next/**"],- "rust-lint": [".github/workflows/rust-lint.yml", "rust/**"],- "rust-test": [".github/workflows/rust-test.yml", "rust/**", "server/**"],+ "rust-lint": [+ ".github/actions/restore-rust-target/**",+ ".github/workflows/rust-lint.yml",+ "rust/**"+ ],+ "rust-test": [+ ".github/actions/restore-rust-target/**",+ ".github/workflows/rust-test.yml",+ "rust/**",+ "server/**"+ ],"server-lint": [".github/workflows/server-lint.yml", "server/**"],"web-lint": [+ ".github/actions/restore-rust-target/**",".github/workflows/web-lint.yml","rust/Cargo.lock","rust/Cargo.toml",diff --git a/.github/workflows/desktop-lint.yml b/.github/workflows/desktop-lint.ymlindex 15a20ecaaf..bc0a9788a7 100644--- a/.github/workflows/desktop-lint.yml+++ b/.github/workflows/desktop-lint.yml@@ -33,8 +33,14 @@ jobs:with:workspaces: rustshared-key: photos-desktop-ensu-android+ cache-targets: falsesave-if: false+ - name: Restore Rust target+ uses: ./.github/actions/restore-rust-target+ with:+ shared-key: photos-desktop-ensu-android+- run: npm run codegen:napi- run: npm run lintdiff --git a/.github/workflows/ensu-android-build.yml b/.github/workflows/ensu-android-build.ymlindex 1a5b4104ef..6ece65c4fc 100644--- a/.github/workflows/ensu-android-build.yml+++ b/.github/workflows/ensu-android-build.yml@@ -20,8 +20,14 @@ jobs:with:workspaces: rustshared-key: photos-desktop-ensu-android+ cache-targets: falsesave-if: false+ - name: Restore Rust target+ uses: ./.github/actions/restore-rust-target+ with:+ shared-key: photos-desktop-ensu-android+# cargo codegen native enables llama.cpp's Vulkan backend on Linux.- name: Install Vulkan build dependenciesrun: |@@ -31,6 +37,15 @@ jobs:- run: cargo codegen nativeworking-directory: rust+ - name: Restore Gradle cache+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: gradle-${{ github.sha }}+ restore-keys: gradle-+ path: |+ ~/.gradle/caches+ ~/.gradle/wrapper+- name: Build Ensuworking-directory: android- run: ./gradlew :ensu:app:assembleDebug+ run: ./gradlew --build-cache :ensu:app:assembleDebugdiff --git a/.github/workflows/ensu-ios-build.yml b/.github/workflows/ensu-ios-build.ymlindex ea93bafeb6..bc07b2cbd9 100644--- a/.github/workflows/ensu-ios-build.yml+++ b/.github/workflows/ensu-ios-build.yml@@ -20,8 +20,14 @@ jobs:with:workspaces: rustshared-key: ensu-ios+ cache-targets: falsesave-if: false+ - name: Restore Rust target+ uses: ./.github/actions/restore-rust-target+ with:+ shared-key: ensu-ios+- run: cargo codegen nativeworking-directory: rustdiff --git a/.github/workflows/mobile-lint.yml b/.github/workflows/mobile-lint.ymlindex e5eba80479..53c1909efb 100644--- a/.github/workflows/mobile-lint.yml+++ b/.github/workflows/mobile-lint.yml@@ -63,8 +63,14 @@ jobs:with:workspaces: rustshared-key: rust-flutter+ cache-targets: falsesave-if: false+ - name: Restore Rust target+ uses: ./.github/actions/restore-rust-target+ with:+ shared-key: rust-flutter+- run: cargo codegen frbworking-directory: rustdiff --git a/.github/workflows/rust-cli-test.yml b/.github/workflows/rust-cli-test.ymlindex 1d09ec214e..b2e5df5d32 100644--- a/.github/workflows/rust-cli-test.yml+++ b/.github/workflows/rust-cli-test.yml@@ -26,8 +26,14 @@ jobs:with:workspaces: rustshared-key: rust-cli+ cache-targets: falsesave-if: false+ - name: Restore Rust target+ uses: ./.github/actions/restore-rust-target+ with:+ shared-key: rust-cli+- name: Run with disposable signing and storagerun: |umask 077@@ -76,7 +82,13 @@ jobs:with:workspaces: rustshared-key: rust-cli+ cache-targets: falsesave-if: false+ - name: Restore Rust target+ uses: ./.github/actions/restore-rust-target+ with:+ shared-key: rust-cli+- name: Run with Windows Credential Managerrun: python apps/cli-next/scripts/native-keyring.py testdiff --git a/.github/workflows/rust-lint.yml b/.github/workflows/rust-lint.ymlindex 0ba8fc16c7..f22ac7da5c 100644--- a/.github/workflows/rust-lint.yml+++ b/.github/workflows/rust-lint.yml@@ -33,9 +33,15 @@ jobs:with:workspaces: rustshared-key: rust-workspace+ cache-targets: falsesave-if: falsecache-directories: rust/.cache+ - name: Restore Rust target+ uses: ./.github/actions/restore-rust-target+ with:+ shared-key: rust-workspace+- run: cargo install cargo-audit --version 0.22.2 --locked- run: ./scripts/lint.shdiff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.ymlindex 1b0abaa77d..d8d3143983 100644--- a/.github/workflows/rust-test.yml+++ b/.github/workflows/rust-test.yml@@ -41,9 +41,25 @@ jobs:with:workspaces: rustshared-key: rust-workspace+ cache-targets: falsesave-if: falsecache-directories: rust/.cache+ - name: Restore Rust target+ uses: ./.github/actions/restore-rust-target+ with:+ shared-key: rust-workspace++ - name: Restore Museum cache+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: museum-${{ github.sha }}+ restore-keys: museum-+ path: |+ ~/go/pkg/mod+ ~/.cache/go-build+ ~/.cache/.theseus/postgresql+- run: cargo test --locked --features museum,ente-ml/ml-assets# postgresql_embedded downloads its binaries from GitHub.# GITHUB_TOKEN raises the API rate limit for those downloads.diff --git a/.github/workflows/warm-caches.yml b/.github/workflows/warm-caches.ymlindex 731be0ba23..8c6e998f17 100644--- a/.github/workflows/warm-caches.yml+++ b/.github/workflows/warm-caches.yml@@ -44,8 +44,16 @@ jobs:with:workspaces: rustshared-key: rust-workspace+ cache-targets: falsecache-directories: rust/.cache+ - name: Check Rust target cache+ id: rust-target+ uses: ./.github/actions/restore-rust-target+ with:+ lookup-only: true+ shared-key: rust-workspace+- name: Reset ML test cacherun: rm -rf .cache@@ -53,10 +61,32 @@ jobs:- run: ./scripts/lint.sh+ - name: Cache Museum+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: museum-${{ github.sha }}+ restore-keys: museum-+ path: |+ ~/go/pkg/mod+ ~/.cache/go-build+ ~/.cache/.theseus/postgresql+- run: cargo test --locked --features museum,ente-ml/ml-assetsenv:GITHUB_TOKEN: ${{ github.token }}+ - run: cargo test --locked -p ente-cli-next --test cli --features museum --no-run++ - run: node .github/actions/restore-rust-target/mtimes.mjs save+ working-directory: ${{ github.workspace }}++ - name: Save Rust target+ if: steps.rust-target.outputs.cache-hit != 'true'+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: ${{ steps.rust-target.outputs.cache-key }}+ path: rust/target+rust-cli:# For rust-cli-test.yml.strategy:@@ -77,9 +107,27 @@ jobs:with:workspaces: rustshared-key: rust-cli+ cache-targets: false++ - name: Check Rust target cache+ id: rust-target+ uses: ./.github/actions/restore-rust-target+ with:+ lookup-only: true+ shared-key: rust-cli- run: cargo test --locked -p ente-cli-next --test cli --no-run+ - run: node .github/actions/restore-rust-target/mtimes.mjs save+ working-directory: ${{ github.workspace }}++ - name: Save Rust target+ if: steps.rust-target.outputs.cache-hit != 'true'+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: ${{ steps.rust-target.outputs.cache-key }}+ path: rust/target+rust-flutter:# For the cargo steps of mobile-lint.yml.runs-on: ubuntu-latest@@ -102,6 +150,14 @@ jobs:with:workspaces: rustshared-key: rust-flutter+ cache-targets: false++ - name: Check Rust target cache+ id: rust-target+ uses: ./.github/actions/restore-rust-target+ with:+ lookup-only: true+ shared-key: rust-flutter- run: cargo codegen frb@@ -109,8 +165,18 @@ jobs:- run: cargo clippy -p ente-locker-frb --features flutter --all-targets --locked- rust-wasm:- # For web-lint.yml's WASM builds.+ - run: node .github/actions/restore-rust-target/mtimes.mjs save+ working-directory: ${{ github.workspace }}++ - name: Save Rust target+ if: steps.rust-target.outputs.cache-hit != 'true'+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: ${{ steps.rust-target.outputs.cache-key }}+ path: rust/target++ web:+ # For web-lint.yml.runs-on: ubuntu-latestdefaults:run:@@ -131,11 +197,44 @@ jobs:with:workspaces: rustshared-key: rust-wasm+ cache-targets: false++ - name: Check Rust target cache+ id: rust-target+ uses: ./.github/actions/restore-rust-target+ with:+ lookup-only: true+ shared-key: rust-wasm++ - name: Cache web+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: web-${{ github.sha }}+ restore-keys: web-+ path: |+ web/apps/photos/.next/cache+ web/apps/*/*.tsbuildinfo+ web/packages/*/*.tsbuildinfo+ web/packages/wasm/*/*.tsbuildinfo- run: npm ci+ - run: _ENTE_IS_DESKTOP=1 npm run build:photos+- run: npm run build:wasm+ - run: npm exec --workspaces -- tsc --incremental++ - run: node .github/actions/restore-rust-target/mtimes.mjs save+ working-directory: ${{ github.workspace }}++ - name: Save Rust target+ if: steps.rust-target.outputs.cache-hit != 'true'+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: ${{ steps.rust-target.outputs.cache-key }}+ path: rust/target+photos-desktop-ensu-android:# For desktop-lint.yml and ensu-android-build.yml.runs-on: ubuntu-latest@@ -156,6 +255,14 @@ jobs:with:workspaces: rustshared-key: photos-desktop-ensu-android+ cache-targets: false++ - name: Check Rust target cache+ id: rust-target+ uses: ./.github/actions/restore-rust-target+ with:+ lookup-only: true+ shared-key: photos-desktop-ensu-android- name: Install Vulkan build dependenciesrun: |@@ -168,9 +275,30 @@ jobs:- run: cargo codegen napiworking-directory: rust+ - name: Cache Gradle+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: gradle-${{ github.sha }}+ restore-keys: gradle-+ path: |+ ~/.gradle/caches+ ~/.gradle/wrapper+- name: Build Ensuworking-directory: android- run: ./gradlew :ensu:app:assembleDebug+ run: |+ ./gradlew --build-cache :ensu:app:assembleDebug+ ./gradlew --stop++ - run: node .github/actions/restore-rust-target/mtimes.mjs save+ working-directory: ${{ github.workspace }}++ - name: Save Rust target+ if: steps.rust-target.outputs.cache-hit != 'true'+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: ${{ steps.rust-target.outputs.cache-key }}+ path: rust/targetensu-ios:# For ensu-ios-build.yml.@@ -184,6 +312,14 @@ jobs:with:workspaces: rustshared-key: ensu-ios+ cache-targets: false++ - name: Check Rust target cache+ id: rust-target+ uses: ./.github/actions/restore-rust-target+ with:+ lookup-only: true+ shared-key: ensu-ios- run: cargo codegen nativeworking-directory: rust@@ -192,6 +328,16 @@ jobs:working-directory: apple/apps/ensurun: xcodebuild build-for-testing -scheme Ensu -destination 'platform=iOS Simulator,name=iPhone 17'+ - run: node .github/actions/restore-rust-target/mtimes.mjs save+ working-directory: ${{ github.workspace }}++ - name: Save Rust target+ if: steps.rust-target.outputs.cache-hit != 'true'+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: ${{ steps.rust-target.outputs.cache-key }}+ path: rust/target+go-server:# For server-lint.yml.runs-on: ubuntu-latestdiff --git a/.github/workflows/web-lint.yml b/.github/workflows/web-lint.ymlindex b5f21466c2..eb074461ed 100644--- a/.github/workflows/web-lint.yml+++ b/.github/workflows/web-lint.yml@@ -29,8 +29,25 @@ jobs:with:workspaces: rustshared-key: rust-wasm+ cache-targets: falsesave-if: false+ - name: Restore Rust target+ uses: ./.github/actions/restore-rust-target+ with:+ shared-key: rust-wasm++ - name: Restore web cache+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ key: web-${{ github.sha }}+ restore-keys: web-+ path: |+ web/apps/photos/.next/cache+ web/apps/*/*.tsbuildinfo+ web/packages/*/*.tsbuildinfo+ web/packages/wasm/*/*.tsbuildinfo+- run: npm ci- run: npm audit --audit-level criticaldiff --git a/web/scripts/lint.mjs b/web/scripts/lint.mjsindex 38d5852c0f..c13b9b6f2e 100644--- a/web/scripts/lint.mjs+++ b/web/scripts/lint.mjs@@ -13,7 +13,7 @@ const commands = [name: "eslint",command: `npm exec --workspaces -- eslint ${fix ? "--fix " : ""}--max-warnings 0`,},- { name: "tsc", command: "npm exec --workspaces -- tsc" },+ { name: "tsc", command: "npm exec --workspaces -- tsc --incremental" },...globSync("checks/*/check.mjs", { cwd }).sort().map((path) => ({