From ade8cbf8f2ee52fe3e8020518fcb23b0678917de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Thu, 9 May 2024 08:32:17 +0200 Subject: [PATCH 1/4] Split Maestro CI flow in 2 jobs. This way, if the Maestro test fails for some runtime reason we don't have to build the APK again to re-test it. --- .github/workflows/maestro.yml | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/workflows/maestro.yml b/.github/workflows/maestro.yml index d0e57497a5c..e4425ef1741 100644 --- a/.github/workflows/maestro.yml +++ b/.github/workflows/maestro.yml @@ -12,12 +12,10 @@ env: CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 --no-daemon jobs: - maestro-cloud: - name: Maestro test suite + build-apk: + name: Build APK runs-on: ubuntu-latest if: github.event_name == 'workflow_dispatch' || github.event.label.name == 'Run-Maestro' - strategy: - fail-fast: false # Allow one per PR. concurrency: group: ${{ format('maestro-{0}', github.ref) }} @@ -41,19 +39,43 @@ jobs: distribution: 'temurin' # See 'Supported distributions' for available options java-version: '17' - name: Assemble debug APK - run: ./gradlew :app:assembleDebug $CI_GRADLE_ARG_PROPERTIES + run: ./gradlew :app:assembleGplayDebug $CI_GRADLE_ARG_PROPERTIES if: (github.event_name == 'pull_request' && github.event.pull_request.fork == null) || github.event_name == 'workflow_dispatch' env: ELEMENT_ANDROID_MAPTILER_API_KEY: ${{ secrets.MAPTILER_KEY }} ELEMENT_ANDROID_MAPTILER_LIGHT_MAP_ID: ${{ secrets.MAPTILER_LIGHT_MAP_ID }} ELEMENT_ANDROID_MAPTILER_DARK_MAP_ID: ${{ secrets.MAPTILER_DARK_MAP_ID }} + - name: Upload APK as artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ format('elementx-apk-maestro-{0}', github.ref) }} + path: | + app/build/outputs/apk/debug/debug/app-gplay-x86_64-debug.apk + retention-days: 5 + overwrite: true + if-no-files-found: error + + maestro-cloud: + name: Maestro test suite + runs-on: ubuntu-latest + needs: build-apk + if: github.event_name == 'workflow_dispatch' || github.event.label.name == 'Run-Maestro' + # Allow one per PR. + concurrency: + group: ${{ format('maestro-{0}', github.ref) }} + cancel-in-progress: true + steps: + - name: Download APK artifact from previous job + uses: actions/download-artifact@v4 + with: + name: ${{ format('elementx-apk-maestro-{0}', github.ref) }} - uses: mobile-dev-inc/action-maestro-cloud@v1.8.1 if: (github.event_name == 'pull_request' && github.event.pull_request.fork == null) || github.event_name == 'workflow_dispatch' with: api-key: ${{ secrets.MAESTRO_CLOUD_API_KEY }} # Doc says (https://github.com/mobile-dev-inc/action-maestro-cloud#android): # app-file should point to an x86 compatible APK file, so upload the x86_64 one (much smaller than the universal APK). - app-file: app/build/outputs/apk/gplay/debug/app-gplay-x86_64-debug.apk + app-file: app-gplay-x86_64-debug.apk env: | MAESTRO_USERNAME=maestroelement MAESTRO_PASSWORD=${{ secrets.MATRIX_MAESTRO_ACCOUNT_PASSWORD }} From b6c030779e2c1c0f033b5ee9e5aecfb2497433e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Thu, 9 May 2024 08:44:39 +0200 Subject: [PATCH 2/4] Fix upload artifact path --- .github/workflows/maestro.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maestro.yml b/.github/workflows/maestro.yml index e4425ef1741..aadf5113d0a 100644 --- a/.github/workflows/maestro.yml +++ b/.github/workflows/maestro.yml @@ -50,7 +50,7 @@ jobs: with: name: ${{ format('elementx-apk-maestro-{0}', github.ref) }} path: | - app/build/outputs/apk/debug/debug/app-gplay-x86_64-debug.apk + app/build/outputs/apk/gplay/debug/app-gplay-x86_64-debug.apk retention-days: 5 overwrite: true if-no-files-found: error From 597421140e1f79cb00bc446fece8d8eb90d3f74e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Thu, 9 May 2024 08:58:04 +0200 Subject: [PATCH 3/4] Fix artifact bundle name --- .github/workflows/maestro.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maestro.yml b/.github/workflows/maestro.yml index aadf5113d0a..c408ea21ade 100644 --- a/.github/workflows/maestro.yml +++ b/.github/workflows/maestro.yml @@ -48,7 +48,7 @@ jobs: - name: Upload APK as artifact uses: actions/upload-artifact@v4 with: - name: ${{ format('elementx-apk-maestro-{0}', github.ref) }} + name: elementx-apk-maestro path: | app/build/outputs/apk/gplay/debug/app-gplay-x86_64-debug.apk retention-days: 5 @@ -68,7 +68,7 @@ jobs: - name: Download APK artifact from previous job uses: actions/download-artifact@v4 with: - name: ${{ format('elementx-apk-maestro-{0}', github.ref) }} + name: elementx-apk-maestro - uses: mobile-dev-inc/action-maestro-cloud@v1.8.1 if: (github.event_name == 'pull_request' && github.event.pull_request.fork == null) || github.event_name == 'workflow_dispatch' with: From 6dd19ac4641af854b4ea899c3c6c9264bccb3cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Thu, 9 May 2024 09:15:57 +0200 Subject: [PATCH 4/4] Add checkout step to the new job --- .github/workflows/maestro.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/maestro.yml b/.github/workflows/maestro.yml index c408ea21ade..dc625aba321 100644 --- a/.github/workflows/maestro.yml +++ b/.github/workflows/maestro.yml @@ -65,6 +65,12 @@ jobs: group: ${{ format('maestro-{0}', github.ref) }} cancel-in-progress: true steps: + - uses: actions/checkout@v4 + if: (github.event_name == 'pull_request' && github.event.pull_request.fork == null) || github.event_name == 'workflow_dispatch' + with: + # Ensure we are building the branch and not the branch after being merged on develop + # https://github.com/actions/checkout/issues/881 + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} - name: Download APK artifact from previous job uses: actions/download-artifact@v4 with: