Integration #450
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
| on: | |
| workflow_dispatch: | |
| inputs: | |
| patrol_test_target: | |
| description: "Optional path to Patrol integration test Dart file (e.g. integration_test/tests/chat/chat_list_test.dart). Leave empty to run all tests." | |
| required: false | |
| default: "" | |
| schedule: | |
| - cron: "0 0 * * *" | |
| name: Integration | |
| jobs: | |
| integration_test: | |
| name: Integration Test | |
| runs-on: self-hosted # Run on our self-hosted runner | |
| permissions: | |
| id-token: write | |
| contents: write | |
| actions: write | |
| checks: write | |
| pull-requests: write | |
| env: | |
| FLUTTER_VERSION: "3.32.8" | |
| JAVA_VERSION: 17 | |
| ANDROID_SDK_ROOT: "/opt/android-sdk" | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| project_id: ${{ secrets.GOOGLE_CLOUD_PROJECT_ID }} | |
| workload_identity_provider: ${{ secrets.GOOGLE_CLOUD_WORKLOAD_IDENTITY_PROVIDER_ID }} | |
| service_account: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT }} | |
| - name: Show runner resources | |
| run: | | |
| echo "CPU cores: $(nproc)" | |
| echo "Memory usage:" | |
| free -h | |
| echo "Disk usage:" | |
| df -h | |
| echo "Top processes by memory:" | |
| ps -eo pid,comm,%cpu,%mem --sort=-%mem | head -n 10 | |
| - name: Ensure PATH for Flutter, Android SDK and Patrol | |
| run: | | |
| echo "$HOME/fvm/versions/${{ env.FLUTTER_VERSION }}/bin" >> "$GITHUB_PATH" | |
| echo "${{ env.ANDROID_SDK_ROOT }}/cmdline-tools/latest/bin" >> "$GITHUB_PATH" | |
| echo "${{ env.ANDROID_SDK_ROOT }}/platform-tools" >> "$GITHUB_PATH" | |
| echo "$HOME/.pub-cache/bin" >> "$GITHUB_PATH" | |
| - name: Check flutter and sdkmanager version | |
| run: | | |
| flutter --version | |
| sdkmanager --version | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ env.JAVA_VERSION }} | |
| distribution: "temurin" | |
| - name: Accept Android SDK licenses | |
| run: | | |
| yes | sdkmanager --licenses || echo "Warning: License acceptance failed" | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install Rust targets for Android | |
| run: | | |
| rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android | |
| - uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.SSH_KEY }} | |
| - name: Setup project | |
| run: | | |
| flutter pub get && flutter pub run build_runner build --delete-conflicting-outputs | |
| - name: Run Patrol Tests | |
| shell: bash | |
| env: | |
| INTEGRATION_TEST_ENV_BASE64: ${{ secrets.INTEGRATION_TEST_ENV_BASE64 }} | |
| PATROL_TEST_TARGET: ${{ inputs.patrol_test_target }} | |
| run: | | |
| dart pub global activate patrol_cli 3.10.0 | |
| flutter build apk --config-only | |
| # export the secret file and clean it up after | |
| echo "$INTEGRATION_TEST_ENV_BASE64" | base64 --decode > .env.cicd | |
| trap 'rm -f .env.cicd' EXIT | |
| TARGET_FLAG="" | |
| if [ -n "$PATROL_TEST_TARGET" ]; then | |
| echo "Running Patrol tests defined in $PATROL_TEST_TARGET" | |
| TARGET_FLAG="--target $PATROL_TEST_TARGET" | |
| else | |
| echo "Running full Patrol test suite" | |
| fi | |
| patrol build android \ | |
| -v \ | |
| --dart-define-from-file .env.cicd \ | |
| ${TARGET_FLAG} | |
| gcloud firebase test android run \ | |
| --type instrumentation \ | |
| --app build/app/outputs/apk/debug/app-debug.apk \ | |
| --test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk \ | |
| --device model=MediumPhone.arm,version=34 \ | |
| --timeout 60m \ | |
| --use-orchestrator \ | |
| --environment-variables clearPackageData=true |