iOS Development

android – Integrating Patrol with GitHub Actions for Automated Flutter Integration Exams

Spread the love


I’m engaged on establishing a steady integration pipeline with automated integration assessments for a Flutter utility. My purpose is to run the assessments utilizing Patrol and subsequently deploy to Firebase Check Lab. Nonetheless, I am encountering points with constructing the take a look at APK utilizing Patrol within the GitHub Actions workflow.

I’ve configured my workflow to arrange the setting, set up dependencies, and construct the take a look at APK for Android and iOS. Regardless of a number of makes an attempt and totally different configurations, the construct course of fails, and I’ve not been in a position to effectively run an emulator throughout the pipeline.

on:
  push:
    branches: [ staging ]
  pull_request:
    branches: [ staging ]
  workflow_dispatch:

jobs:
  setup:
    runs-on: ubuntu-latest
     
    steps:
      - identify: Checkout Repository
        makes use of: actions/checkout@v2

      - identify: Set Git person data
        run: | 
       
      - identify: Set up Google Cloud SDK
        run: |
          curl -sSL https://sdk.cloud.google.com | bash
          echo "$HOME/google-cloud-sdk/bin" >> $GITHUB_PATH
      - identify: Decode and Write Service Account to File
        run: |
            echo "${{ secrets and techniques.KEY}}" | base64 -d > /tmp/temp.json
            echo "GOOGLE_APPLICATION_CREDENTIALS=/tmp/temp.json" >> $GITHUB_ENV
      - identify: Extract Undertaking ID from Service Account
        run: |
            PROJECT_ID=$(jq -r '.project_id' /tmp/temp.json)
            echo "PROJECT_ID=$PROJECT_ID" >> $GITHUB_ENV
      - identify: Set up Firebase CLI
        run: curl -sL firebase.instruments | bash
        
      - identify: Set up Google Cloud SDK
        run: |
          curl -sSL https://sdk.cloud.google.com | bash
          echo "$HOME/google-cloud-sdk/bin" >> $GITHUB_PATH
    
      - identify: Authenticate with Google Cloud
        run: |
            gcloud auth activate-service-account --key-file=/tmp/temp.json
            gcloud config set challenge "$PROJECT_ID"
      - identify: Retrieve and Masks all GCP Secrets and techniques
        run: |
            secrets and techniques=$(gcloud secrets and techniques checklist --format="get(identify)")
            for secret_full_name in $secrets and techniques; do
              secret_name=${secret_full_name##*/}
              secret_value=$(gcloud secrets and techniques variations entry newest --secret="$secret_name" --project="$PROJECT_ID" --quiet)
              echo "::add-mask::***"
              echo "$secret_name"='***' >> $GITHUB_ENV
            achieved
      
    
        
  

  android-tests:
    wants: setup
    runs-on: ubuntu-latest
    steps:
      - identify: Checkout Repository
        makes use of: actions/checkout@v2

      - identify: Arrange Flutter
        makes use of: subosito/flutter-action@v1
        with:
          flutter-version: '3.16.5'

      - identify: Set up Dependencies
        run: flutter pub get

      - identify: Set up Patrol
        run: flutter pub international activate patrol

      - identify: Construct Android App and Check APK with Patrol
        run: patrol construct android -t integration_test/example_test.dart --flavor manufacturing

      - identify: Run Exams on Firebase Check Lab (Android)
        run: |
          gcloud firebase take a look at android run 
            --type instrumentation 
            --app construct/app/outputs/apk/debug/app-debug.apk 
            --test construct/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk 
            --device mannequin="nexus6", model="30", locale=en, orientation=portrait 
            --timeout 10m 
            --results-bucket="patrol_runs" 
            --use-orchestrator 
            --environment-variables clearPackageData=true
      - identify: Fastlane Android Deployment
        run: fastlane android deploy

  ios-tests:
    wants: setup
    runs-on: macos-latest
    steps:
      - identify: Checkout Repository
        makes use of: actions/checkout@v2

      - identify: Arrange Flutter
        makes use of: subosito/flutter-action@v1
        with:
          flutter-version: '3.16.5'

      - identify: Set up Dependencies
        run: flutter pub get

      - identify: Set up Patrol
        run: flutter pub international activate patrol

      - identify: Construct iOS App for Testing
        run: patrol construct ios --target integration_test/example_test.dart --release

      - identify: Package deal iOS Exams
        run: |
          pushd construct/ios_integ/Construct/Merchandise
          zip -r ios_tests.zip Launch-iphoneos Runner_iphoneos16.2-arm64.xctestrun
          popd
      - identify: Run Exams on Firebase Check Lab (iOS)
        run: |
          gcloud firebase take a look at ios run 
            --test construct/ios_integ/Construct/Merchandise/ios_tests.zip 
            --device mannequin=iphone13, model=16.2, locale=en_US, orientation=portrait 
            --timeout 10m 
            --results-bucket="patrol_runs"
      - identify: Fastlane iOS Deployment
        run: fastlane ios deploy 

I tried to make use of an emulator construct immediately within the pipeline, nevertheless it proved to be inefficient. I am now exploring how one can greatest make the most of Firebase Check Lab for working the assessments.

I might recognize any steering on the next factors:

How can I efficiently construct the take a look at APK with Patrol in a GitHub Actions workflow?

What’s the most effective option to run these assessments on Firebase Check Lab?

Are there greatest practices or beneficial approaches for establishing one of these CI/CD pipeline for a Flutter app?

Leave a Reply

Your email address will not be published. Required fields are marked *