From 99a72c91b0f5647bbf54f2cc9b7bdf3daed67596 Mon Sep 17 00:00:00 2001 From: Deep Panchal Date: Mon, 21 Aug 2023 17:10:43 -0500 Subject: [PATCH 1/9] ci(e2e): add e2e.yml for running maestro tests --- .github/workflows/e2e.yml | 86 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/e2e.yml diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 000000000..e9226371f --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,86 @@ +name: Maestro E2E + +on: + push: + branches: + - main + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true # auto cancel prev. run + +env: + MAESTRO_VERSION: 1.31.0 + ANDROID_ARCH: x86_64 + +jobs: + android-e2e: + name: E2e Tests ๐Ÿงช + runs-on: macos-12 # or buildjet-4vcpu-ubuntu-2204, ubuntu-22.04-4core, macos-12-xl + steps: + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v3 + + - name: Installing Maestro ๐Ÿ“ฅ + run: curl -Ls "https://get.maestro.mobile.dev" | bash # will use `MAESTRO_VERSION` from env + + - name: Validate Gradle Wrapper ๐Ÿ“ + uses: gradle/wrapper-validation-action@v1 + + - name: Copy CI gradle.properties ๐Ÿ“‹ + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Set up JDK 17 โš™๏ธ + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 17 + + - name: Setup Gradle โš™๏ธ + uses: gradle/gradle-build-action@v2 + + - name: Setup environment โš™๏ธ + env: + ENV_VAR_FILE_NAME: debug.properties + API_BASE_URL: ${{ secrets.API_BASE_URL }} + BASE_URL: ${{ secrets.BASE_URL }} + MAPS_API_KEY: ${{ secrets.MAPS_API_KEY }} + DEBUG_EMAIL_ADDRESS: ${{ secrets.DEBUG_EMAIL_ADDRESS }} + DEBUG_ACCOUNT_PASSWORD: ${{ secrets.DEBUG_ACCOUNT_PASSWORD }} + MAESTRO_APP_ID: com.crisiscleanup.demo.debug + MAESTRO_APP_EMAIL: ${{ secrets.TEST_APP_EMAIL_STAGING }} + MAESTRO_APP_PASSWORD: ${{ secrets.TEST_APP_PASSWORD_STAGING }} + run: | + echo 'API_BASE_URL=${{ secrets.API_BASE_URL }}' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'BASE_URL=${{ secrets.BASE_URL }}' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'MAPS_API_KEY=${{ secrets.MAPS_API_KEY }}' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'DEBUG_EMAIL_ADDRESS=${{ secrets.DEBUG_EMAIL_ADDRESS }}' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'DEBUG_ACCOUNT_PASSWORD=${{ secrets.DEBUG_ACCOUNT_PASSWORD }}' >> ${{ env.ENV_VAR_FILE_NAME }} + + - name: Build apk for emulator + working-directory: android + run: | + ./gradlew assembleDebug --no-daemon -PreactNativeArchitectures=${{ env.ANDROID_ARCH }} + + echo "Print path to *.apk file" + find . -type f -name "*.apk" + + - name: Install Maestro and run e2e tests + uses: reactivecircus/android-emulator-runner@v2 + env: + APK_PATH: ./app/build/outputs/apk/demo/release/app-demo-release.apk + with: + api-level: 33 + arch: ${{ env.ANDROID_ARCH }} + script: | + adb install "${{ env.APK_PATH }}" + $HOME/.maestro/bin/maestro test .maestro/auth-tests --format junit + $HOME/.maestro/bin/maestro test .maestro/work-tests --format junit + + - name: Store tests result + uses: actions/upload-artifact@v3 + with: + name: e2e_android_report + path: | + report.xml From 47c0da56ab15845ff7ab6ac707d0473318698e83 Mon Sep 17 00:00:00 2001 From: Deep Panchal Date: Mon, 21 Aug 2023 17:14:46 -0500 Subject: [PATCH 2/9] ci(e2e): remove invalid working-directory from build apk step --- .github/workflows/e2e.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e9226371f..7bb2a2e79 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -59,7 +59,6 @@ jobs: echo 'DEBUG_ACCOUNT_PASSWORD=${{ secrets.DEBUG_ACCOUNT_PASSWORD }}' >> ${{ env.ENV_VAR_FILE_NAME }} - name: Build apk for emulator - working-directory: android run: | ./gradlew assembleDebug --no-daemon -PreactNativeArchitectures=${{ env.ANDROID_ARCH }} From f8ede023a8318518e31f5374a8c575c840ae393f Mon Sep 17 00:00:00 2001 From: Deep Panchal Date: Tue, 22 Aug 2023 15:15:19 -0500 Subject: [PATCH 3/9] test(e2e): fix incident search and select e2e flow, force pick an incident before searching --- .maestro/work-tests/incident-search-and-select.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.maestro/work-tests/incident-search-and-select.yaml b/.maestro/work-tests/incident-search-and-select.yaml index a36850c66..61f7dff32 100644 --- a/.maestro/work-tests/incident-search-and-select.yaml +++ b/.maestro/work-tests/incident-search-and-select.yaml @@ -7,10 +7,21 @@ tags: - pull-request env: SEARCH_QUERY: '11' + INCIDENT_REGEX: ".*(flood|tornado).*" onFlowStart: - runFlow: ../auth-tests/login.yaml --- # wait for incidents to load +- waitForAnimationToEnd: + timeout: 5000 +# Pick a random incident from incident selector +- tapOn: + id: "workIncidentSelectorFab" +- scrollUntilVisible: + element: ${INCIDENT_REGEX} +- tapOn: + text: ${INCIDENT_REGEX} + index: 0 - waitForAnimationToEnd: timeout: 5000 # start searching after loading spinner is invisible From 33571ac3f5861ee77d0a21455cb1dab9a3d80c67 Mon Sep 17 00:00:00 2001 From: Deep Panchal Date: Tue, 22 Aug 2023 15:15:55 -0500 Subject: [PATCH 4/9] ci(e2e): remove unnecessary env in setup env step --- .github/workflows/e2e.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 7bb2a2e79..a54669445 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -43,14 +43,6 @@ jobs: - name: Setup environment โš™๏ธ env: ENV_VAR_FILE_NAME: debug.properties - API_BASE_URL: ${{ secrets.API_BASE_URL }} - BASE_URL: ${{ secrets.BASE_URL }} - MAPS_API_KEY: ${{ secrets.MAPS_API_KEY }} - DEBUG_EMAIL_ADDRESS: ${{ secrets.DEBUG_EMAIL_ADDRESS }} - DEBUG_ACCOUNT_PASSWORD: ${{ secrets.DEBUG_ACCOUNT_PASSWORD }} - MAESTRO_APP_ID: com.crisiscleanup.demo.debug - MAESTRO_APP_EMAIL: ${{ secrets.TEST_APP_EMAIL_STAGING }} - MAESTRO_APP_PASSWORD: ${{ secrets.TEST_APP_PASSWORD_STAGING }} run: | echo 'API_BASE_URL=${{ secrets.API_BASE_URL }}' >> ${{ env.ENV_VAR_FILE_NAME }} echo 'BASE_URL=${{ secrets.BASE_URL }}' >> ${{ env.ENV_VAR_FILE_NAME }} From 867b512deee1f36fa47d7f3e9910495e5b949375 Mon Sep 17 00:00:00 2001 From: Deep Panchal Date: Tue, 22 Aug 2023 15:16:12 -0500 Subject: [PATCH 5/9] ci(e2e): set required env vars for maestro tests --- .github/workflows/e2e.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index a54669445..3b64effee 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -61,6 +61,9 @@ jobs: uses: reactivecircus/android-emulator-runner@v2 env: APK_PATH: ./app/build/outputs/apk/demo/release/app-demo-release.apk + MAESTRO_APP_ID: com.crisiscleanup.demo.debug + MAESTRO_APP_EMAIL: ${{ secrets.TEST_APP_EMAIL_PROD }} + MAESTRO_APP_PASSWORD: ${{ secrets.TEST_APP_PASSWORD_PROD }} with: api-level: 33 arch: ${{ env.ANDROID_ARCH }} From e8fc8bf190709bb9ac2da4710d4770d60cbe61cd Mon Sep 17 00:00:00 2001 From: Deep Panchal Date: Tue, 22 Aug 2023 15:16:45 -0500 Subject: [PATCH 6/9] ci(e2e): fix incorrect env vars getting written to properties file for building apk --- .github/workflows/e2e.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 3b64effee..ce89f3fed 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -44,11 +44,11 @@ jobs: env: ENV_VAR_FILE_NAME: debug.properties run: | - echo 'API_BASE_URL=${{ secrets.API_BASE_URL }}' >> ${{ env.ENV_VAR_FILE_NAME }} - echo 'BASE_URL=${{ secrets.BASE_URL }}' >> ${{ env.ENV_VAR_FILE_NAME }} - echo 'MAPS_API_KEY=${{ secrets.MAPS_API_KEY }}' >> ${{ env.ENV_VAR_FILE_NAME }} - echo 'DEBUG_EMAIL_ADDRESS=${{ secrets.DEBUG_EMAIL_ADDRESS }}' >> ${{ env.ENV_VAR_FILE_NAME }} - echo 'DEBUG_ACCOUNT_PASSWORD=${{ secrets.DEBUG_ACCOUNT_PASSWORD }}' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'API_BASE_URL="https://api.staging.crisiscleanup.io"' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'BASE_URL="http://localhost:8080"' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'MAPS_API_KEY="${{ secrets.MAPS_API_KEY }}"' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'DEBUG_EMAIL_ADDRESS="${{ secrets.TEST_APP_EMAIL_PROD }}"' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'DEBUG_ACCOUNT_PASSWORD="${{ secrets.TEST_APP_PASSWORD_PROD }}"' >> ${{ env.ENV_VAR_FILE_NAME }} - name: Build apk for emulator run: | From fcf1ace725e03c9ef043a7568c1da6bdfdfa8ef4 Mon Sep 17 00:00:00 2001 From: Deep Panchal Date: Tue, 22 Aug 2023 15:36:12 -0500 Subject: [PATCH 7/9] ci(e2e): set android emulator action target to google_apis --- .github/workflows/e2e.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index ce89f3fed..62e6f2ccf 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -66,6 +66,7 @@ jobs: MAESTRO_APP_PASSWORD: ${{ secrets.TEST_APP_PASSWORD_PROD }} with: api-level: 33 + target: google_apis arch: ${{ env.ANDROID_ARCH }} script: | adb install "${{ env.APK_PATH }}" From a7ff564d8b4c107ac0d84a6bd78a4f74d2880033 Mon Sep 17 00:00:00 2001 From: Deep Panchal Date: Tue, 22 Aug 2023 15:40:28 -0500 Subject: [PATCH 8/9] ci(e2e): fix output apk path from release to debug for emulator runner step --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 62e6f2ccf..79693ef78 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -60,7 +60,7 @@ jobs: - name: Install Maestro and run e2e tests uses: reactivecircus/android-emulator-runner@v2 env: - APK_PATH: ./app/build/outputs/apk/demo/release/app-demo-release.apk + APK_PATH: ./app/build/outputs/apk/demo/debug/app-demo-debug.apk MAESTRO_APP_ID: com.crisiscleanup.demo.debug MAESTRO_APP_EMAIL: ${{ secrets.TEST_APP_EMAIL_PROD }} MAESTRO_APP_PASSWORD: ${{ secrets.TEST_APP_PASSWORD_PROD }} From 461c0927c86f27c420980fa558ba711ef8346510 Mon Sep 17 00:00:00 2001 From: Deep Panchal Date: Wed, 23 Aug 2023 14:24:35 -0500 Subject: [PATCH 9/9] ci(e2e): set MAESTRO_DRIVER_STARTUP_TIMEOUT to 60 seconds from default of 15 seconds --- .github/workflows/e2e.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 79693ef78..624e3be87 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -61,6 +61,7 @@ jobs: uses: reactivecircus/android-emulator-runner@v2 env: APK_PATH: ./app/build/outputs/apk/demo/debug/app-demo-debug.apk + MAESTRO_DRIVER_STARTUP_TIMEOUT: 60000 MAESTRO_APP_ID: com.crisiscleanup.demo.debug MAESTRO_APP_EMAIL: ${{ secrets.TEST_APP_EMAIL_PROD }} MAESTRO_APP_PASSWORD: ${{ secrets.TEST_APP_PASSWORD_PROD }}