fix avd home location #224
This file contains 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
name: Detox E2E Android Tests PR | |
on: | |
push: | |
branches: | |
- test_android_e2e | |
pull_request: | |
branches: | |
- main | |
- test_android_e2e | |
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' && false | |
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: 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" | |
detox-android-e2e: | |
runs-on: ubuntu-latest-8-cores | |
env: | |
ANDROID_HOME: /usr/local/lib/android/sdk | |
ANDROID_SDK_ROOT: /usr/local/lib/android/sdk | |
ANDROID_AVD_HOME: /home/runner/.android/avd | |
PATH: /usr/local/lib/android/sdk/platform-tools:/usr/local/lib/android/sdk/emulator:/usr/local/lib/android/sdk/cmdline-tools/latest/bin:$PATH | |
steps: | |
- name: ci/checkout-repo | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Debug AVD Location | |
run: | | |
ls -la $ANDROID_AVD_HOME | |
ls -la /home/runner/.android/avd | |
- name: Enable KVM | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- 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: Start Server | |
run: | | |
npm run start & | |
- name: Install Dependencies | |
run: | | |
cd detox | |
npm install | |
- name: Create destination path | |
run: mkdir -p android/app/build/outputs/apk | |
- name: Download artifact | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
curl -L -H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/mattermost/mattermost-mobile/actions/artifacts/2508660502/zip \ | |
--output android/app/build/outputs/apk/artifact.zip | |
- name: Unzip artifact | |
run: unzip android/app/build/outputs/apk/artifact.zip -d android/app/build/outputs/apk | |
- name: Cleanup | |
run: | | |
find android/app/build -type f | |
rm android/app/build/outputs/apk/artifact.zip | |
- name: Set up Android SDK | |
run: | | |
export ANDROID_HOME=/usr/local/lib/android/sdk | |
export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH | |
echo "ANDROID_HOME=$ANDROID_HOME" >> $GITHUB_ENV | |
echo "PATH=$PATH" >> $GITHUB_ENV | |
- name: Accept Android licenses | |
run: | | |
yes | sdkmanager --licenses || true | |
- name: Install Android system image | |
run: | | |
sdkmanager "system-images;android-31;default;x86_64" # Use x86_64 for KVM | |
sdkmanager "platform-tools" "emulator" | |
- name: Create and start Android emulator | |
run: | | |
cd detox | |
chmod +x ./create_android_emulator.sh | |
./create_android_emulator.sh | |
- name: Stop Android emulator | |
if: always() # Ensure the emulator is stopped even if the tests fail | |
run: | | |
adb emu kill |