fix(ci): add --force to cargo install to handle cached binaries #42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ============================================================================ | |
| # OxiCloud Desktop — Continuous Integration | |
| # ============================================================================ | |
| # Runs on every push/PR to validate the build across platforms. | |
| # ============================================================================ | |
| name: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| FLUTTER_VERSION: '3.41.2' | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| # ── Analyze & Test ───────────────────────────────────────────────────── | |
| analyze: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: ${{ env.FLUTTER_VERSION }} | |
| channel: stable | |
| cache: true | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang cmake ninja-build pkg-config \ | |
| libgtk-3-dev liblzma-dev libstdc++-12-dev | |
| - name: Flutter pub get | |
| run: flutter pub get | |
| - name: Generate Flutter-Rust Bridge bindings | |
| run: | | |
| cargo install flutter_rust_bridge_codegen --version 2.11.1 --locked --force | |
| flutter_rust_bridge_codegen generate | |
| - name: Flutter analyze | |
| run: flutter analyze --no-fatal-infos | |
| - name: Flutter test | |
| run: flutter test || true | |
| - name: Rust fmt check | |
| run: cd rust && cargo fmt -- --check | |
| - name: Rust clippy | |
| run: cd rust && cargo clippy --all-targets -- -D warnings | |
| continue-on-error: true | |
| - name: Rust tests | |
| run: cd rust && cargo test | |
| # ── Build Linux ──────────────────────────────────────────────────────── | |
| build-linux: | |
| needs: analyze | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang cmake ninja-build pkg-config \ | |
| libgtk-3-dev liblzma-dev libstdc++-12-dev \ | |
| libappindicator3-dev libnotify-dev | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: ${{ env.FLUTTER_VERSION }} | |
| channel: stable | |
| cache: true | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/bin | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| rust/target | |
| key: ci-linux-rust-${{ hashFiles('rust/Cargo.lock') }} | |
| - name: Build | |
| run: | | |
| flutter pub get | |
| cargo install flutter_rust_bridge_codegen --version 2.11.1 --locked --force | |
| flutter_rust_bridge_codegen generate | |
| flutter build linux --release | |
| # ── Build Android ────────────────────────────────────────────────────── | |
| build-android: | |
| needs: analyze | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Setup Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| cache: 'gradle' | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: ${{ env.FLUTTER_VERSION }} | |
| channel: stable | |
| cache: true | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android | |
| - name: Install cargo-ndk | |
| run: cargo install cargo-ndk | |
| - name: Setup Android NDK | |
| uses: nttld/setup-ndk@v1 | |
| id: setup-ndk | |
| with: | |
| ndk-version: r26d | |
| - name: Build | |
| run: | | |
| flutter pub get | |
| cargo install flutter_rust_bridge_codegen --version 2.11.1 --locked --force | |
| flutter_rust_bridge_codegen generate | |
| flutter build apk --debug | |
| env: | |
| ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| # ── Build Windows ───────────────────────────────────────────────────── | |
| build-windows: | |
| needs: analyze | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: ${{ env.FLUTTER_VERSION }} | |
| channel: stable | |
| cache: true | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/bin | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| rust/target | |
| key: ci-windows-rust-${{ hashFiles('rust/Cargo.lock') }} | |
| - name: Build | |
| run: | | |
| flutter pub get | |
| cargo install flutter_rust_bridge_codegen --version 2.11.1 --locked --force | |
| flutter_rust_bridge_codegen generate | |
| flutter build windows --release | |
| - name: Verify Windows build artifacts | |
| shell: pwsh | |
| run: | | |
| $releaseDir = "build\windows\x64\runner\Release" | |
| # Critical files that must exist for the app to run | |
| $requiredFiles = @( | |
| "$releaseDir\OxiCloud.exe", | |
| "$releaseDir\oxicloud_core.dll", | |
| "$releaseDir\flutter_windows.dll", | |
| "$releaseDir\data\flutter_assets\AssetManifest.json" | |
| ) | |
| $allOk = $true | |
| foreach ($file in $requiredFiles) { | |
| if (Test-Path $file) { | |
| $size = [math]::Round((Get-Item $file).Length / 1KB, 1) | |
| Write-Host "OK: $file ($size KB)" | |
| } else { | |
| Write-Error "MISSING: $file" | |
| $allOk = $false | |
| } | |
| } | |
| # Check data directory exists | |
| if (-not (Test-Path "$releaseDir\data")) { | |
| Write-Error "MISSING: data directory" | |
| $allOk = $false | |
| } | |
| if (-not $allOk) { | |
| Write-Host "`nContents of Release directory:" | |
| Get-ChildItem $releaseDir -Recurse | Select-Object FullName, Length | |
| exit 1 | |
| } | |
| Write-Host "`nAll Windows build artifacts verified successfully." | |
| # ── Build macOS ────────────────────────────────────────────────────── | |
| build-macos: | |
| needs: analyze | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: ${{ env.FLUTTER_VERSION }} | |
| channel: stable | |
| cache: true | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/bin | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| rust/target | |
| key: ci-macos-rust-${{ hashFiles('rust/Cargo.lock') }} | |
| - name: Build | |
| run: | | |
| flutter pub get | |
| cargo install flutter_rust_bridge_codegen --version 2.11.1 --locked --force | |
| flutter_rust_bridge_codegen generate | |
| flutter build macos --release |