From 0ad2679595db0fe84c7a96f627ab0358eae575ab Mon Sep 17 00:00:00 2001 From: yasserfaraazkhan Date: Thu, 16 Jan 2025 12:26:10 +0530 Subject: [PATCH] Add android detox apk build workflow (#8405) --- .github/workflows/e2e-android-detox.yml | 73 +++++++++++++++++++++++++ detox/README.md | 3 +- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/e2e-android-detox.yml diff --git a/.github/workflows/e2e-android-detox.yml b/.github/workflows/e2e-android-detox.yml new file mode 100644 index 000000000..4544f3646 --- /dev/null +++ b/.github/workflows/e2e-android-detox.yml @@ -0,0 +1,73 @@ +name: Detox E2E Android Tests PR + +on: + pull_request: + branches: + - main + types: + - labeled + +concurrency: + group: "${{ github.workflow }}-${{ github.event.pull_request.number }}-${{ github.event.label.name }}" + cancel-in-progress: true + +jobs: + build-android-apk: + if: github.event.label.name == 'E2E Android tests for PR' + runs-on: ubuntu-latest-8-cores + env: + ORG_GRADLE_PROJECT_jvmargs: -Xmx8g + steps: + - name: Prune Docker to free up space + run: docker system prune -af + + - name: Remove npm Temporary Files + run: | + rm -rf ~/.npm/_cacache + + - name: ci/checkout-repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: ci/prepare-android-build + uses: ./.github/actions/prepare-android-build + env: + STORE_FILE: "${{ secrets.MM_MOBILE_STORE_FILE }}" + STORE_ALIAS: "${{ secrets.MM_MOBILE_STORE_ALIAS }}" + STORE_PASSWORD: "${{ secrets.MM_MOBILE_STORE_PASSWORD }}" + MATTERMOST_BUILD_GH_TOKEN: "${{ secrets.MATTERMOST_BUILD_GH_TOKEN }}" + + - name: Install Dependencies + run: sudo apt-get clean && sudo apt-get update && sudo apt-get install -y default-jdk + + - name: Cache Gradle dependencies + uses: actions/cache@v4 + with: + path: ~/.gradle/caches/modules-2/ + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-gradle- + + - name: Validate Gradle wrapper + uses: gradle/actions/wrapper-validation@v3 + + - name: Inject Detox settings + run: cd detox && npm run e2e:android-inject-settings + + - name: Update minSdkVersion for react-native-image-picker + run: | + sed -i 's/minSdkVersion 21/minSdkVersion 23/' ./node_modules/react-native-image-picker/android/build.gradle + cat ./node_modules/react-native-image-picker/android/build.gradle | grep minSdkVersion + + - name: Detox build + run: | + cd detox + npm install + npm install -g detox-cli + npm run e2e:android-build + + - name: ci/upload-android-pr-build + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + with: + name: android-build-apk-${{ github.run_id }} + path: "android/app/build/outputs/apk/**/app-*.apk" diff --git a/detox/README.md b/detox/README.md index c30cc25d8..a52a925cb 100644 --- a/detox/README.md +++ b/detox/README.md @@ -20,7 +20,8 @@ npm run inject-detox-settings ### Update `minSdkVersion` for `react-native-image-picker` -On macOS machines, update the `minSdkVersion` of `react-native-image-picker` to 23 by running the following command from the root directory: +On macOS machines, update the `minSdkVersion` of `react-native-image-picker` to 23 by running the following command from the root directory. +This is required for Detox to build the test apk targeting android API 31 or higher. ```sh sed -i '' 's/minSdkVersion 21/minSdkVersion 23/' ./node_modules/react-native-image-picker/android/build.gradle