Update Rust usage in README #322
Workflow file for this run
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
| name: Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test-rust: | |
| name: Rust Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf | |
| - uses: taiki-e/install-action@cargo-llvm-cov | |
| - name: Run tests with coverage | |
| run: cargo llvm-cov --all-features --lcov --output-path coverage.lcov | |
| - name: Upload coverage to Codecov | |
| if: ${{ github.actor != 'dependabot[bot]' }} | |
| uses: codecov/codecov-action@v6 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| with: | |
| files: coverage.lcov | |
| flags: rust | |
| name: rust-coverage | |
| test-js: | |
| name: JavaScript/TypeScript Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v6 | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Run tests with coverage | |
| run: pnpm test:coverage | |
| - name: Upload coverage to Codecov | |
| if: ${{ github.actor != 'dependabot[bot]' }} | |
| uses: codecov/codecov-action@v6 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| with: | |
| files: ./coverage/coverage-final.json | |
| flags: javascript | |
| name: javascript-coverage | |
| - name: Upload coverage reports | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: js-coverage | |
| path: coverage/ | |
| test-android: | |
| name: Android Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-linux-android | |
| - name: Build Android bindings | |
| run: cargo build --target aarch64-linux-android | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x android/gradlew | |
| - name: Run Android unit tests with coverage | |
| run: | | |
| cd android | |
| ./gradlew clean testDebugUnitTest createDebugUnitTestCoverageReport --stacktrace --no-daemon | |
| - name: Upload coverage to Codecov | |
| if: ${{ github.actor != 'dependabot[bot]' }} | |
| uses: codecov/codecov-action@v6 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| with: | |
| files: ./android/build/reports/coverage/test/debug/report.xml | |
| flags: android | |
| name: android-coverage | |
| root_dir: ${{ github.workspace }} | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: android-test-results | |
| path: android/build/test-results/ | |
| - name: Upload coverage reports | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: android-coverage | |
| path: android/build/reports/coverage/test/debug/ | |
| test-android-instrumented: | |
| name: Android Instrumented Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-linux-android | |
| - name: Build Android bindings | |
| run: cargo build --target aarch64-linux-android | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x android/gradlew | |
| - name: Enable KVM group perms | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: Run instrumented tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: 30 | |
| target: google_apis | |
| arch: x86_64 | |
| profile: pixel_6 | |
| disable-animations: true | |
| emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| script: cd android && ./gradlew clean connectedDebugAndroidTest createDebugAndroidTestCoverageReport --stacktrace --no-daemon | |
| - name: Upload coverage to Codecov | |
| if: ${{ github.actor != 'dependabot[bot]' }} | |
| uses: codecov/codecov-action@v6 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| with: | |
| files: ./android/build/reports/coverage/androidTest/debug/report.xml | |
| flags: android-instrumented | |
| name: android-instrumented-coverage | |
| root_dir: ${{ github.workspace }} | |
| - name: Upload instrumented test results | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: android-instrumented-test-results | |
| path: android/build/outputs/androidTest-results/ | |
| - name: Upload instrumented coverage reports | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: android-instrumented-coverage | |
| path: android/build/reports/coverage/androidTest/debug/ | |
| test-ios: | |
| name: iOS Unit Tests | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-apple-ios | |
| - name: Build iOS bindings | |
| run: cargo build --target aarch64-apple-ios | |
| - name: Run iOS unit tests | |
| run: | | |
| cd ios | |
| xcodebuild test \ | |
| -scheme tauri-plugin-iap \ | |
| -destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' \ | |
| -enableCodeCoverage YES \ | |
| -resultBundlePath TestResults.xcresult | |
| - name: Generate coverage report | |
| run: | | |
| cd ios | |
| xcrun xccov view --report --json TestResults.xcresult > coverage.json | |
| - name: Upload coverage to Codecov | |
| if: ${{ github.actor != 'dependabot[bot]' }} | |
| uses: codecov/codecov-action@v6 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| with: | |
| files: ./ios/coverage.json | |
| flags: ios | |
| name: ios-coverage | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: ios-test-results | |
| path: ios/TestResults.xcresult | |
| - name: Upload coverage reports | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: ios-coverage | |
| path: ios/coverage.json | |
| test-macos: | |
| name: macOS Unit Tests | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-apple-darwin | |
| - name: Build macOS bindings | |
| run: cargo build --target aarch64-apple-darwin | |
| - name: Run macOS unit tests | |
| run: | | |
| cd macos | |
| xcodebuild test \ | |
| -scheme tauri-plugin-iap \ | |
| -destination 'platform=macOS' \ | |
| -enableCodeCoverage YES \ | |
| -resultBundlePath TestResults.xcresult | |
| - name: Generate coverage report | |
| run: | | |
| cd macos | |
| xcrun xccov view --report --json TestResults.xcresult > coverage.json | |
| - name: Upload coverage to Codecov | |
| if: ${{ github.actor != 'dependabot[bot]' }} | |
| uses: codecov/codecov-action@v6 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| with: | |
| files: ./macos/coverage.json | |
| flags: macos | |
| name: macos-coverage | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: macos-test-results | |
| path: macos/TestResults.xcresult | |
| - name: Upload coverage reports | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: macos-coverage | |
| path: macos/coverage.json |