Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Consolidate Rust CI

Manav Rathi1f1182653a6c
diff --git a/.github/workflows/ensu-android-build.yml b/.github/workflows/ensu-android-build.yml
index 5cda3778ee..421842351b 100644
--- a/.github/workflows/ensu-android-build.yml
+++ b/.github/workflows/ensu-android-build.yml
@@ -29,6 +29,15 @@ jobs:
- name: Checkout code
uses: actions/checkout@v6
+ - name: Restore Rust cache
+ uses: actions/cache/restore@v4
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: rust-ubuntu-latest-${{ runner.arch }}-
+
- run: cargo codegen native
working-directory: rust
diff --git a/.github/workflows/ensu-build.yml b/.github/workflows/ensu-build.yml
index defac090ff..48793a7bfc 100644
--- a/.github/workflows/ensu-build.yml
+++ b/.github/workflows/ensu-build.yml
@@ -131,27 +131,25 @@ jobs:
corepack enable
corepack prepare [email protected] --activate
- # Pin to 1.93.0: Rust 1.94.0 has a trait glob-import regression
- # that breaks wry 0.24.x (SettingsExt not found via traits::*).
- - name: Install Rust 1.93.0
- uses: dtolnay/[email protected]
- with:
- targets: ${{ matrix.platform.rust-target }}
-
- name: Install dependencies (Ubuntu only)
if: matrix.platform.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.0-dev libsoup2.4-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
- - name: Rust cache
- uses: actions/cache@v4
+ - name: Install macOS Intel Rust target
+ if: matrix.platform.rust-target == 'x86_64-apple-darwin'
+ run: rustup target add x86_64-apple-darwin
+
+ - name: Restore Rust cache
+ if: matrix.platform.os == 'ubuntu-22.04'
+ uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
- key: ${{ runner.os }}-${{ matrix.platform.rust-target }}-cargo-ensu-release-${{ hashFiles('rust/Cargo.lock') }}
+ key: rust-ubuntu-22.04-${{ runner.arch }}-
- name: Install web dependencies
working-directory: web
@@ -165,10 +163,6 @@ jobs:
working-directory: rust/apps/ensu
run: yarn install --frozen-lockfile
- - name: Fetch Rust dependencies
- working-directory: rust
- run: cargo fetch
-
- name: Prepare Windows signing
if: matrix.platform.os == 'windows-latest'
shell: bash
@@ -228,7 +222,7 @@ jobs:
build-android:
needs: build-metadata
if: needs.build-metadata.outputs.should_build == 'true'
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-latest
environment:
name: production
env:
@@ -261,8 +255,14 @@ jobs:
echo "y" | sdkmanager --install "ndk;${{ env.NDK_VERSION }}"
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ env.NDK_VERSION }}" >> $GITHUB_ENV
- - name: Setup Rust
- uses: dtolnay/rust-toolchain@stable
+ - name: Restore Rust cache
+ uses: actions/cache/restore@v4
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: rust-ubuntu-latest-${{ runner.arch }}-
- run: cargo codegen native
working-directory: rust
@@ -329,9 +329,6 @@ jobs:
with:
ref: ${{ needs.build-metadata.outputs.commit_sha }}
- - name: Setup Rust
- uses: dtolnay/rust-toolchain@stable
-
- run: cargo codegen native
working-directory: rust
diff --git a/.github/workflows/ensu-desktop-lint.yml b/.github/workflows/ensu-desktop-lint.yml
deleted file mode 100644
index abb0afe35c..0000000000
--- a/.github/workflows/ensu-desktop-lint.yml
+++ /dev/null
@@ -1,62 +0,0 @@
-name: "Lint (ensu desktop)"
-
-on:
- # Run on every pull request (open or push to it) that changes ensu desktop
- pull_request:
- paths:
- - "rust/apps/ensu/**"
- - "rust/crates/core/**"
- - "rust/crates/ensu/**"
- - ".github/workflows/ensu-desktop-lint.yml"
-
-permissions:
- contents: read
-
-# Cancel in-progress lint runs when a new commit is pushed.
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
-env:
- RUSTFLAGS: -D warnings
-
-jobs:
- lint:
- runs-on: ubuntu-22.04
- defaults:
- run:
- working-directory: rust
- steps:
- - name: Checkout code
- uses: actions/checkout@v6
-
- - name: Cache
- uses: actions/cache@v4
- with:
- path: |
- ~/.cargo/registry
- ~/.cargo/git
- rust/target
- key: ${{ runner.os }}-cargo-ensu-desktop-${{ hashFiles('rust/Cargo.lock') }}
-
- - name: Install Rust 1.93.0
- uses: dtolnay/[email protected]
- with:
- components: rustfmt,clippy
-
- - name: Install system dependencies
- run: |
- sudo apt-get update
- sudo apt-get install -y libwebkit2gtk-4.0-dev libsoup2.4-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
-
- - name: Fetch Rust dependencies
- run: cargo fetch
-
- - name: Ensure Tauri distDir exists for macro checks
- run: mkdir -p ../web/apps/ensu/out
-
- - run: cargo fmt --check
-
- - run: cargo clippy -p ensu-tauri --all-targets --all-features
-
- - run: cargo build -p ensu-tauri
diff --git a/.github/workflows/ensu-ios-build.yml b/.github/workflows/ensu-ios-build.yml
index 1c77c1463c..f7ae98bea5 100644
--- a/.github/workflows/ensu-ios-build.yml
+++ b/.github/workflows/ensu-ios-build.yml
@@ -29,6 +29,15 @@ jobs:
- name: Checkout code
uses: actions/checkout@v6
+ - name: Restore Rust cache
+ uses: actions/cache/restore@v4
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: rust-macos-latest-${{ runner.arch }}-ios-
+
- run: cargo codegen native
working-directory: rust
diff --git a/.github/workflows/locker-lint.yml b/.github/workflows/locker-lint.yml
index c8bbfab693..ff9f5342fa 100644
--- a/.github/workflows/locker-lint.yml
+++ b/.github/workflows/locker-lint.yml
@@ -18,7 +18,6 @@ on:
env:
FLUTTER_VERSION: "3.38.10"
- RUST_VERSION: "1.90.0"
permissions:
contents: read
@@ -48,20 +47,14 @@ jobs:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- - name: Install Rust ${{ env.RUST_VERSION }}
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8
- with:
- toolchain: ${{ env.RUST_VERSION }}
- components: rustfmt
-
- - name: Cache Rust dependencies
- uses: actions/cache@v4
+ - name: Restore Rust cache
+ uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
- key: ${{ runner.os }}-cargo-locker-${{ hashFiles('rust/Cargo.lock') }}
+ key: rust-ubuntu-latest-${{ runner.arch }}-
- run: cargo codegen frb
working-directory: rust
diff --git a/.github/workflows/mobile-lint.yml b/.github/workflows/mobile-lint.yml
index 370cce0293..5696bbc7c2 100644
--- a/.github/workflows/mobile-lint.yml
+++ b/.github/workflows/mobile-lint.yml
@@ -19,8 +19,6 @@ on:
env:
FLUTTER_VERSION: "3.38.10"
- RUST_VERSION: "1.90.0"
- RUSTFLAGS: -D warnings
permissions:
contents: read
@@ -34,38 +32,6 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v6
- with:
- fetch-depth: 2
-
- - name: Detect Rust changes
- id: rust_changes
- shell: bash
- run: |
- ente_rust=false
- ente_photos_rust=false
-
- while IFS= read -r file; do
- case "$file" in
- .github/workflows/mobile-lint.yml|mobile/packages/rust/*|rust/bindings/frb/ente-rust/*|rust/crates/core/*|rust/crates/contacts/*|rust/apps/codegen/*|rust/Cargo.lock|rust/Cargo.toml)
- ente_rust=true
- ;;
- esac
-
- case "$file" in
- .github/workflows/mobile-lint.yml|mobile/apps/photos/rust_builder/*|rust/bindings/frb/photos/*|rust/crates/photos/*|rust/crates/image/*|rust/apps/codegen/*|rust/Cargo.lock|rust/Cargo.toml)
- ente_photos_rust=true
- ;;
- esac
- done < <(git diff --name-only "${{ github.event.pull_request.base.sha }}...HEAD")
-
- echo "ente_rust=$ente_rust" >> "$GITHUB_OUTPUT"
- echo "ente_photos_rust=$ente_photos_rust" >> "$GITHUB_OUTPUT"
-
- if [[ "$ente_rust" == "true" || "$ente_photos_rust" == "true" ]]; then
- echo "any=true" >> "$GITHUB_OUTPUT"
- else
- echo "any=false" >> "$GITHUB_OUTPUT"
- fi
- name: Verify frozen mobile pubspecs
run: ruby mobile/scripts/check_frozen_pubspecs.rb mobile/apps/photos
@@ -82,20 +48,14 @@ jobs:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- - name: Install Rust ${{ env.RUST_VERSION }}
- uses: dtolnay/rust-toolchain@stable
- with:
- toolchain: ${{ env.RUST_VERSION }}
- components: rustfmt,clippy
-
- - name: Cache
- uses: actions/cache@v4
+ - name: Restore Rust cache
+ uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
- key: ${{ runner.os }}-cargo-mobile-${{ hashFiles('rust/Cargo.lock') }}
+ key: rust-ubuntu-latest-${{ runner.arch }}-
- run: flutter pub get --enforce-lockfile
@@ -106,43 +66,3 @@ jobs:
- name: Run Flutter tests
run: flutter test
-
- - name: Check formatting (ente_rust)
- if: steps.rust_changes.outputs.ente_rust == 'true'
- working-directory: rust
- run: cargo fmt --check -p ente_rust
-
- - name: Run clippy (ente_rust)
- if: steps.rust_changes.outputs.ente_rust == 'true'
- working-directory: rust
- run: cargo clippy -p ente_rust --all-targets --all-features
-
- - name: Build (ente_rust)
- if: steps.rust_changes.outputs.ente_rust == 'true'
- working-directory: rust
- run: cargo build -p ente_rust
-
- - name: Test (ente_rust)
- if: steps.rust_changes.outputs.ente_rust == 'true'
- working-directory: rust
- run: cargo test -p ente_rust
-
- - name: Check formatting (ente_photos_rust)
- if: steps.rust_changes.outputs.ente_photos_rust == 'true'
- working-directory: rust
- run: cargo fmt --check -p ente_photos_rust
-
- - name: Run clippy (ente_photos_rust)
- if: steps.rust_changes.outputs.ente_photos_rust == 'true'
- working-directory: rust
- run: cargo clippy -p ente_photos_rust --all-targets --all-features
-
- - name: Build (ente_photos_rust)
- if: steps.rust_changes.outputs.ente_photos_rust == 'true'
- working-directory: rust
- run: cargo build -p ente_photos_rust
-
- - name: Test (ente_photos_rust)
- if: steps.rust_changes.outputs.ente_photos_rust == 'true'
- working-directory: rust
- run: cargo test -p ente_photos_rust
diff --git a/.github/workflows/mobile-packages-lint.yml b/.github/workflows/mobile-packages-lint.yml
index 2277f3c4b7..9dc90b87e6 100644
--- a/.github/workflows/mobile-packages-lint.yml
+++ b/.github/workflows/mobile-packages-lint.yml
@@ -1,17 +1,11 @@
name: "Lint (mobile packages)"
on:
- # Run when mobile/packages or shared photos Rust changes
pull_request:
paths:
- "mobile/packages/**"
- "mobile/**/pubspec*.yaml"
- "mobile/**/pubspec.lock"
- - "rust/crates/photos/**"
- - "rust/bindings/frb/**"
- - "rust/apps/codegen/**"
- - "rust/Cargo.lock"
- - "rust/Cargo.toml"
- ".github/workflows/mobile-packages-lint.yml"
- "mobile/scripts/check_frozen_pubspecs.rb"
- "mobile/scripts/check_source_arb_plurals.rb"
@@ -22,12 +16,9 @@ on:
env:
FLUTTER_VERSION: "3.38.10"
- RUST_VERSION: "1.90.0"
- RUSTFLAGS: -D warnings
permissions:
contents: read
- pull-requests: read # Required for paths-filter
jobs:
detect-changes:
@@ -38,32 +29,10 @@ jobs:
lint_auth: ${{ steps.filter.outputs.lint_auth }}
lint_locker: ${{ steps.filter.outputs.lint_locker }}
lint_all: ${{ steps.filter.outputs.lint_all }}
- rust_changed: ${{ steps.filter.outputs.rust_changed }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- - name: Detect changed files
- uses: dorny/paths-filter@v3
- id: changes
- with:
- filters: |
- rust:
- - 'rust/bindings/frb/**/*.rs'
- - 'rust/bindings/frb/**/Cargo.toml'
- - 'rust/apps/codegen/**'
- - 'rust/Cargo.lock'
- - 'rust/Cargo.toml'
- - 'rust/crates/photos/**'
- - 'rust/crates/core/**/*.rs'
- - 'rust/crates/contacts/**/*.rs'
- workflow:
- - '.github/workflows/mobile-packages-lint.yml'
- analysis:
- - 'mobile/analysis_options.yaml'
- packages:
- - 'mobile/packages/**'
-
- name: Determine affected packages
id: filter
run: |
@@ -89,14 +58,12 @@ jobs:
echo "lint_auth=$LINT_AUTH" >> $GITHUB_OUTPUT
echo "lint_locker=$LINT_LOCKER" >> $GITHUB_OUTPUT
echo "lint_all=$LINT_ALL" >> $GITHUB_OUTPUT
- echo "rust_changed=${{ steps.changes.outputs.rust }}" >> $GITHUB_OUTPUT
echo "Affected packages: $PACKAGES"
echo "Lint photos: $LINT_PHOTOS"
echo "Lint auth: $LINT_AUTH"
echo "Lint locker: $LINT_LOCKER"
echo "Lint all: $LINT_ALL"
- echo "Rust changed: ${{ steps.changes.outputs.rust }}"
pubspec-constraints:
runs-on: ubuntu-latest
@@ -127,20 +94,14 @@ jobs:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- - name: Install Rust ${{ env.RUST_VERSION }}
- uses: dtolnay/rust-toolchain@stable
- with:
- toolchain: ${{ env.RUST_VERSION }}
- components: rustfmt,clippy
-
- - name: Cache Rust dependencies
- uses: actions/cache@v4
+ - name: Restore Rust cache
+ uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
- key: ${{ runner.os }}-cargo-packages-${{ hashFiles('rust/Cargo.lock') }}
+ key: rust-ubuntu-latest-${{ runner.arch }}-
- run: cargo codegen frb
working-directory: rust
@@ -250,71 +211,6 @@ jobs:
run: flutter pub get --enforce-lockfile && flutter analyze --no-fatal-infos
working-directory: mobile/packages/utils
- rust-lint:
- needs: detect-changes
- runs-on: ubuntu-latest
- if: needs.detect-changes.outputs.rust_changed == 'true'
- steps:
- - name: Checkout code
- uses: actions/checkout@v6
-
- - name: Install Flutter ${{ env.FLUTTER_VERSION }}
- uses: subosito/flutter-action@v2
- with:
- channel: "stable"
- flutter-version: ${{ env.FLUTTER_VERSION }}
- cache: true
-
- - name: Install Rust ${{ env.RUST_VERSION }}
- uses: dtolnay/rust-toolchain@stable
- with:
- toolchain: ${{ env.RUST_VERSION }}
- components: rustfmt,clippy
-
- - name: Cache Rust dependencies
- uses: actions/cache@v4
- with:
- path: |
- ~/.cargo/registry
- ~/.cargo/git
- rust/target
- key: ${{ runner.os }}-cargo-packages-${{ hashFiles('rust/Cargo.lock') }}
-
- - run: cargo codegen frb
- working-directory: rust
-
- - name: Check formatting (ente_rust)
- working-directory: rust
- run: cargo fmt --check -p ente_rust
-
- - name: Run clippy (ente_rust)
- working-directory: rust
- run: cargo clippy -p ente_rust --all-targets --all-features
-
- - name: Build (ente_rust)
- working-directory: rust
- run: cargo build -p ente_rust
-
- - name: Test (ente_rust)
- working-directory: rust
- run: cargo test -p ente_rust
-
- - name: Check formatting (ente_photos_rust)
- working-directory: rust
- run: cargo fmt --check -p ente_photos_rust
-
- - name: Run clippy (ente_photos_rust)
- working-directory: rust
- run: cargo clippy -p ente_photos_rust --all-targets --all-features
-
- - name: Build (ente_photos_rust)
- working-directory: rust
- run: cargo build -p ente_photos_rust
-
- - name: Test (ente_photos_rust)
- working-directory: rust
- run: cargo test -p ente_photos_rust
-
apps-lint:
needs: detect-changes
runs-on: ubuntu-latest
@@ -337,21 +233,15 @@ jobs:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- - name: Install Rust ${{ env.RUST_VERSION }}
+ - name: Restore Rust cache
if: needs.detect-changes.outputs.lint_photos == 'true' || needs.detect-changes.outputs.lint_locker == 'true'
- uses: dtolnay/rust-toolchain@stable
- with:
- toolchain: ${{ env.RUST_VERSION }}
- components: rustfmt,clippy
-
- - name: Cache Rust dependencies
- uses: actions/cache@v4
+ uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
- key: ${{ runner.os }}-cargo-packages-${{ hashFiles('rust/Cargo.lock') }}
+ key: rust-ubuntu-latest-${{ runner.arch }}-
- if: needs.detect-changes.outputs.lint_photos == 'true' || needs.detect-changes.outputs.lint_locker == 'true'
run: cargo codegen frb
diff --git a/.github/workflows/rust-cache.yml b/.github/workflows/rust-cache.yml
new file mode 100644
index 0000000000..959d149f2a
--- /dev/null
+++ b/.github/workflows/rust-cache.yml
@@ -0,0 +1,151 @@
+name: "Cache (rust)"
+
+on:
+ schedule:
+ # 03:00 AM IST.
+ - cron: "30 21 * * *"
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: false
+
+env:
+ CARGO_INCREMENTAL: "0"
+
+jobs:
+ linux:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v6
+
+ - name: Restore Rust cache
+ id: rust_cache
+ uses: actions/cache/restore@v4
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: rust-ubuntu-latest-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/**/Cargo.toml') }}
+ restore-keys: |
+ rust-ubuntu-latest-${{ runner.arch }}-
+
+ - name: Install WASM Rust target
+ run: rustup target add wasm32-unknown-unknown
+
+ - name: Build Rust workspace
+ run: cargo build --workspace --exclude ensu-tauri --all-targets --all-features --locked
+ working-directory: rust
+
+ - name: Build WASM Rust target
+ run: cargo build -p ente-wasm --release --target wasm32-unknown-unknown --locked
+ working-directory: rust
+
+ - name: Generate native bindings
+ run: cargo codegen native
+ working-directory: rust
+
+ - name: Generate Flutter bindings
+ run: cargo codegen frb
+ working-directory: rust
+
+ - name: Build Ensu Android Rust libraries
+ run: ./gradlew :rust:buildRustJniDebug
+ working-directory: mobile/native/android/apps/ensu
+
+ - name: Save Rust cache
+ if: github.ref == 'refs/heads/main' && steps.rust_cache.outputs.cache-hit != 'true'
+ uses: actions/cache/save@v4
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: rust-ubuntu-latest-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/**/Cargo.toml') }}
+
+ linux-tauri:
+ runs-on: ubuntu-22.04
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v6
+
+ - name: Install Linux dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y libwebkit2gtk-4.0-dev libsoup2.4-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
+
+ - name: Restore Rust cache
+ id: rust_cache
+ uses: actions/cache/restore@v4
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: rust-ubuntu-22.04-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/**/Cargo.toml') }}
+ restore-keys: |
+ rust-ubuntu-22.04-${{ runner.arch }}-
+
+ - name: Prepare Ensu desktop distDir
+ run: mkdir -p web/apps/ensu/out
+
+ - name: Build Rust workspace
+ run: cargo build --workspace --all-targets --all-features --locked
+ working-directory: rust
+
+ - name: Save Rust cache
+ if: github.ref == 'refs/heads/main' && steps.rust_cache.outputs.cache-hit != 'true'
+ uses: actions/cache/save@v4
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: rust-ubuntu-22.04-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/**/Cargo.toml') }}
+
+ macos-ios:
+ runs-on: macos-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v6
+
+ - name: Restore Rust cache
+ id: rust_cache
+ uses: actions/cache/restore@v4
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: rust-macos-latest-${{ runner.arch }}-ios-${{ hashFiles('rust/Cargo.lock', 'rust/**/Cargo.toml') }}
+ restore-keys: |
+ rust-macos-latest-${{ runner.arch }}-ios-
+
+ - name: Generate native bindings
+ run: cargo codegen native
+ working-directory: rust
+
+ - name: Build Ensu iOS simulator Rust libraries
+ run: |
+ SRCROOT="$PWD/mobile/native/darwin/Apps/Ensu" \
+ TARGET_TEMP_DIR="$RUNNER_TEMP/ensu-ios-cache" \
+ PLATFORM_NAME=iphonesimulator \
+ ARCHS="$(uname -m)" \
+ CONFIGURATION=Debug \
+ IPHONEOS_DEPLOYMENT_TARGET=16.0 \
+ bash mobile/native/darwin/Apps/Ensu/scripts/build-rust.sh
+
+ - name: Save Rust cache
+ if: github.ref == 'refs/heads/main' && steps.rust_cache.outputs.cache-hit != 'true'
+ uses: actions/cache/save@v4
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: rust-macos-latest-${{ runner.arch }}-ios-${{ hashFiles('rust/Cargo.lock', 'rust/**/Cargo.toml') }}
diff --git a/.github/workflows/rust-e2e-test.yml b/.github/workflows/rust-e2e-test.yml
index 9c9b084e87..79da51da21 100644
--- a/.github/workflows/rust-e2e-test.yml
+++ b/.github/workflows/rust-e2e-test.yml
@@ -32,14 +32,14 @@ jobs:
- name: Checkout code
uses: actions/checkout@v6
- - name: Cache cargo artifacts
- uses: actions/cache@v4
+ - name: Restore Rust cache
+ uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
- key: ${{ runner.os }}-cargo-rust-e2e-${{ hashFiles('rust/Cargo.lock') }}
+ key: rust-ubuntu-latest-${{ runner.arch }}-
- name: Run rust e2e suite
env:
diff --git a/.github/workflows/rust-lint-cli.yml b/.github/workflows/rust-lint-cli.yml
deleted file mode 100644
index 2bd5450378..0000000000
--- a/.github/workflows/rust-lint-cli.yml
+++ /dev/null
@@ -1,50 +0,0 @@
-name: "Lint (rust cli)"
-
-on:
- # Run on every pull request (open or push to it) that changes Rust CLI files.
- #
- # Kept as a separate workflow than rust-lint.yml since the CLI currently
- # has many dependencies and the lint takes longer, while most of the
- # work is happening on the lighter-weight core.
- pull_request:
- paths:
- - "rust/apps/cli/**"
- - "rust/Cargo.lock"
- - "rust/Cargo.toml"
- - ".github/workflows/rust-lint-cli.yml"
-
-permissions:
- contents: read
-
-# Cancel in-progress lint runs when a new commit is pushed.
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
-env:
- RUSTFLAGS: -D warnings
-
-jobs:
- lint:
- runs-on: ubuntu-latest
- defaults:
- run:
- working-directory: rust
- steps:
- - name: Checkout code
- uses: actions/checkout@v6
-
- - name: Cache
- uses: actions/cache@v4
- with:
- path: |
- ~/.cargo/registry
- ~/.cargo/git
- rust/target
- key: ${{ runner.os }}-cargo-cli-${{ hashFiles('rust/Cargo.lock') }}
-
- - run: cargo fmt --check -p ente-rs
-
- - run: cargo clippy -p ente-rs --all-targets --all-features
-
- - run: cargo build -p ente-rs
diff --git a/.github/workflows/rust-lint.yml b/.github/workflows/rust-lint.yml
index a5213620f5..5fb87047cd 100644
--- a/.github/workflows/rust-lint.yml
+++ b/.github/workflows/rust-lint.yml
@@ -1,24 +1,14 @@
name: "Lint (rust)"
on:
- # Run on every pull request (open or push to it) that changes Rust code
- #
- # See also: rust-lint-cli.yml
pull_request:
paths:
- - "rust/crates/core/**"
- - "rust/crates/contacts/**"
- - "rust/crates/image/**"
- - "rust/bindings/wasm/ente-wasm/**"
- - "rust/crates/photos/**"
- - "rust/Cargo.lock"
- - "rust/Cargo.toml"
+ - "rust/**"
- ".github/workflows/rust-lint.yml"
permissions:
contents: read
-# Cancel in-progress lint runs when a new commit is pushed.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@@ -28,64 +18,35 @@ env:
jobs:
lint:
- runs-on: ubuntu-latest
+ runs-on: ubuntu-22.04
+ defaults:
+ run:
+ working-directory: rust
steps:
- name: Checkout code
uses: actions/checkout@v6
- - name: Cache
- uses: actions/cache@v4
+ - name: Install Linux dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y libwebkit2gtk-4.0-dev libsoup2.4-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
+
+ - name: Restore Rust cache
+ uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
- key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
-
- - name: Check formatting (core)
- working-directory: rust
- run: cargo fmt --check -p ente-core
-
- - name: Run clippy (core)
- working-directory: rust
- run: cargo clippy -p ente-core --all-targets --all-features
-
- - name: Build (core)
- working-directory: rust
- run: cargo build -p ente-core
-
- - name: Test (core)
- working-directory: rust
- run: cargo test -p ente-core
-
- - name: Check formatting (photos)
- working-directory: rust
- run: cargo fmt --check -p ente_photos
-
- - name: Run clippy (photos)
- working-directory: rust
- run: cargo clippy -p ente_photos --all-targets --all-features
-
- - name: Build (photos)
- working-directory: rust
- run: cargo build -p ente_photos
+ key: rust-ubuntu-22.04-${{ runner.arch }}-
- - name: Test (photos)
- working-directory: rust
- run: cargo test -p ente_photos
+ - name: Prepare Ensu desktop distDir
+ run: mkdir -p ../web/apps/ensu/out
- - name: Check formatting (wasm)
- working-directory: rust
- run: cargo fmt --check -p ente-wasm
+ - run: cargo codegen frb
- - name: Run clippy (wasm)
- working-directory: rust
- run: cargo clippy -p ente-wasm --all-targets --all-features
+ - run: cargo fmt --all --check
- - name: Build (wasm)
- working-directory: rust
- run: cargo build -p ente-wasm
+ - run: cargo clippy --workspace --all-targets --all-features --locked
- - name: Test (wasm)
- working-directory: rust
- run: cargo test -p ente-wasm
+ - run: cargo test --workspace --locked
diff --git a/.github/workflows/web-lint.yml b/.github/workflows/web-lint.yml
index 814299fbee..f26479d575 100644
--- a/.github/workflows/web-lint.yml
+++ b/.github/workflows/web-lint.yml
@@ -46,6 +46,15 @@ jobs:
- run: yarn install --frozen-lockfile
+ - name: Restore Rust cache
+ uses: actions/cache/restore@v4
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: rust-ubuntu-latest-${{ runner.arch }}-
+
- run: yarn build:wasm
- run: yarn lint
diff --git a/rust/crates/ensu/sync/tests/sync_integration.rs b/rust/crates/ensu/sync/tests/sync_integration.rs
index 0f5607757f..5fd9572bca 100644
--- a/rust/crates/ensu/sync/tests/sync_integration.rs
+++ b/rust/crates/ensu/sync/tests/sync_integration.rs
@@ -1,4 +1,5 @@
use ensu_db::EnsuDb;
+use ensu_db::SyncStateDb;
use ensu_db::crypto::KEY_BYTES;
use ensu_sync::SyncAuth;
use ensu_sync::SyncEngine;
@@ -9,6 +10,7 @@ use ensu_sync::models::{
};
use httpmock::Method::{DELETE, GET, POST};
use httpmock::MockServer;
+use std::sync::{Mutex, MutexGuard, OnceLock};
use tempfile::TempDir;
use uuid::Uuid;
use zeroize::Zeroizing;
@@ -40,6 +42,13 @@ impl TestEnv {
}
}
+fn sync_test_lock() -> MutexGuard<'static, ()> {
+ static LOCK: OnceLock<Mutex<()>> = OnceLock::new();
+ LOCK.get_or_init(|| Mutex::new(()))
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner())
+}
+
fn make_auth(server: &MockServer, master_key: Vec<u8>) -> SyncAuth {
SyncAuth {
base_url: server.base_url(),
@@ -76,6 +85,7 @@ fn mock_empty_diff(server: &MockServer, timestamp: i64) {
#[test]
fn pull_applies_remote_sessions_and_messages() {
+ let _guard = sync_test_lock();
let env = TestEnv::new();
let db_key = vec![42u8; KEY_BYTES];
let engine = SyncEngine::new(
@@ -164,6 +174,7 @@ fn pull_applies_remote_sessions_and_messages() {
#[test]
fn push_only_needs_sync_messages() {
+ let _guard = sync_test_lock();
let env = TestEnv::new();
let db_key = vec![11u8; KEY_BYTES];
let engine = SyncEngine::new(
@@ -192,6 +203,11 @@ fn push_only_needs_sync_messages() {
.expect("message two");
db.mark_message_synced(message_one.uuid)
.expect("mark synced");
+ let sync_state = SyncStateDb::open_sqlite_with_defaults(env.attachments_db_path.clone())
+ .expect("sync state");
+ sync_state
+ .set_message_state(message_one.uuid, Some("remote-message-one"), Some(9))
+ .expect("message sync state");
let master_key = vec![7u8; KEY_BYTES];
let chat_key = ente_core::crypto::keys::generate_stream_key();
@@ -201,12 +217,18 @@ fn push_only_needs_sync_messages() {
let session_mock = server.mock(|when, then| {
when.method(POST).path("/llmchat/chat/session");
- then.status(200).json_body_obj(&serde_json::json!({}));
+ then.status(200).json_body_obj(&serde_json::json!({
+ "sessionUUID": Uuid::new_v4().to_string(),
+ "updatedAt": 20,
+ }));
});
let message_mock = server.mock(|when, then| {
when.method(POST).path("/llmchat/chat/message");
- then.status(200).json_body_obj(&serde_json::json!({}));
+ then.status(200).json_body_obj(&serde_json::json!({
+ "messageUUID": Uuid::new_v4().to_string(),
+ "updatedAt": 21,
+ }));
});
let auth = make_auth(&server, master_key);
@@ -221,6 +243,7 @@ fn push_only_needs_sync_messages() {
#[test]
fn tombstone_removes_messages() {
+ let _guard = sync_test_lock();
let env = TestEnv::new();
let db_key = vec![3u8; KEY_BYTES];
let engine = SyncEngine::new(