Skip to content

Commit

Permalink
new config
Browse files Browse the repository at this point in the history
  • Loading branch information
yasserfaraazkhan committed Mar 25, 2024
1 parent c0cec44 commit ca076f4
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 128 deletions.
349 changes: 228 additions & 121 deletions .github/workflows/e2e-detox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,41 +122,6 @@ jobs:
# name: ios-results-${{ matrix.runId }}
# path: detox/artifacts/

build-android-apk:
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Free up space on the runner
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- 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 Detox dependencies
run: cd detox && npm ci

- name: Build android apk
run: |
cd detox
npm run e2e:android-build
- name: Upload Android APK
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: android-build-apk-${{ github.run_id }}
path: android/app/build

# build-android-apk:
# runs-on: ubuntu-22.04
# steps:
Expand Down Expand Up @@ -188,50 +153,152 @@ jobs:
# name: android-build-apk-${{ github.run_id }}
# path: "*.apk"

e2e-android:
# e2e-android:
# env:
# IOS: false
# GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4096m"
# API_LEVEL: 31
# ANDROID_EMULATOR_IMAGE: 'system-images;android-33;google_apis;x86_64'
# ANDROID_EMULATOR_NAME: 'pixel_6_pro_android_33'
# ANDROID_EMULATOR_DEVICE: 'pixel_6_pro'
# runs-on: ubuntu-22.04
# name: android-detox-e2e-${{ matrix.runId }}
# needs:
# - generate-specs
# - build-android-apk
# strategy:
# fail-fast: false
# matrix: ${{fromJson(needs.generate-specs.outputs.specs)}}
# steps:
# - name: Checkout Repository
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

# - name: Install required libraries for emulator
# run: sudo apt-get install libpulse0 libpulse-dev

# - name: ci/prepare-node-deps
# uses: ./.github/actions/prepare-node-deps

# - name: Set Build ID
# run: echo "BUILD_ID=${{ github.run_id }}-${{ env.BUILD_SUFFIX }}" >> $GITHUB_ENV

# - name: Set up Android SDK
# uses: android-actions/setup-android@v2
# with:
# android-sdk-tools: 'latest'
# android-emulator-image: ${{ env.ANDROID_EMULATOR_IMAGE }}
# android-emulator-name: ${{ env.ANDROID_EMULATOR_NAME }}
# android-emulator-device: ${{ env.ANDROID_EMULATOR_DEVICE }}

# - name: Free up space on the runner
# run: |
# sudo rm -rf /usr/share/dotnet
# sudo rm -rf /opt/ghc
# sudo rm -rf "/usr/local/share/boost"
# sudo rm -rf "$AGENT_TOOLSDIRECTORY"

# - 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: Gradle cache
# uses: gradle/actions/setup-gradle@v3

# - name: AVD cache
# uses: actions/cache@v4
# id: avd-cache
# with:
# path: |
# ~/.android/avd/*
# ~/.android/adb*
# key: avd-${{ env.API_LEVEL }}

# - name: Download Android APK
# uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
# with:
# name: android-build-apk-${{ github.run_id }}
# path: android/app/build

# - name: List files in android/app/build
# run: ls -l android/app/build

# - name: Start React Native Metro Server
# run: npm run start &

# - name: Install Detox Dependencies
# run: cd detox && npm i

# - name: Detox test
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 31
# arch: x86_64
# avd-name: pixel_6_pro
# script: cd detox && npm run e2e:android-test -- ${{ matrix.specs }}

# - name: Upload Android Test Report
# if: always()
# uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
# with:
# name: android-results-${{ matrix.runId }}
# path: detox/artifacts

# download-e2e-results:
# runs-on: ubuntu-22.04
# if: always()
# needs:
# - generate-specs
# # - e2e-ios
# - e2e-android
# steps:
# - name: Checkout Repository
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

# - name: ci/prepare-node-deps
# uses: ./.github/actions/prepare-node-deps

# - name: Create artifacts directory
# run: |
# mkdir -p detox/artifacts/

# - name: Download All Android Artifacts
# uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
# with:
# path: detox/artifacts/
# pattern: android-results-*

# - name: Save report Detox Dependencies
# run: |
# cd detox
# npm ci
# npm run e2e:save-report
# env:
# IOS: false

build:
runs-on: ubuntu-latest
env:
IOS: false
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4096m"
API_LEVEL: 31
ANDROID_EMULATOR_IMAGE: 'system-images;android-33;google_apis;x86_64'
ANDROID_EMULATOR_NAME: 'pixel_6_pro_android_33'
ANDROID_EMULATOR_DEVICE: 'pixel_6_pro'
runs-on: ubuntu-22.04
name: android-detox-e2e-${{ matrix.runId }}
needs:
- generate-specs
- build-android-apk
strategy:
fail-fast: false
matrix: ${{fromJson(needs.generate-specs.outputs.specs)}}
API_LEVEL: 33
ARCH: x86_64
DETOX_CONFIGURATION: android.emu.release
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Checkout repository
uses: actions/checkout@v4

- name: Install required libraries for emulator
run: sudo apt-get install libpulse0 libpulse-dev

- name: ci/prepare-android-build
uses: ./.github/actions/prepare-android-build

- name: ci/prepare-node-deps
uses: ./.github/actions/prepare-node-deps

- name: Set Build ID
run: echo "BUILD_ID=${{ github.run_id }}-${{ env.BUILD_SUFFIX }}" >> $GITHUB_ENV

- name: Set up Android SDK
uses: android-actions/setup-android@v2
with:
android-sdk-tools: 'latest'
android-emulator-image: ${{ env.ANDROID_EMULATOR_IMAGE }}
android-emulator-name: ${{ env.ANDROID_EMULATOR_NAME }}
android-emulator-device: ${{ env.ANDROID_EMULATOR_DEVICE }}

- name: Free up space on the runner
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
Expand All @@ -240,74 +307,114 @@ jobs:
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3

- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.API_LEVEL }}

- name: Download Android APK
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
- name: Cache Detox build
id: cache-detox-build
uses: actions/cache@v4
with:
name: android-build-apk-${{ github.run_id }}
path: android/app/build

- name: List files in android/app/build
run: ls -l android/app/build

- name: Start React Native Metro Server
run: npm run start &
key: ${{ runner.os }}-detox-build
restore-keys: |
${{ runner.os }}-detox-build
- name: Install Detox Dependencies
run: cd detox && npm i
- name: Detox build
run: |
cd detox
npx detox build --configuration ${{ env.DETOX_CONFIGURATION }} --if-missing
- name: Detox test
uses: reactivecircus/android-emulator-runner@v2
- name: Upload Detox build
uses: actions/upload-artifact@v4
with:
api-level: 31
arch: x86_64
avd-name: pixel_6_pro
script: cd detox && npm run e2e:android-test -- ${{ matrix.specs }}

- name: Upload Android Test Report
if: always()
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: android-results-${{ matrix.runId }}
path: detox/artifacts
name: detox-build
path: android/app/build/outputs/apk/release/

download-e2e-results:
runs-on: ubuntu-22.04
if: always()
needs:
- generate-specs
# - e2e-ios
- e2e-android
android-test:
needs: build
runs-on: ubuntu-latest
env:
API_LEVEL: 33
ARCH: x86_64
DETOX_CONFIGURATION: android.emu.release
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Checkout repository
uses: actions/checkout@v4

- name: Install required libraries for emulator
run: sudo apt-get install libpulse0 libpulse-dev

- name: ci/prepare-android-build
uses: ./.github/actions/prepare-android-build

- name: ci/prepare-node-deps
uses: ./.github/actions/prepare-node-deps

- name: Set Build ID
run: echo "BUILD_ID=${{ github.run_id }}-${{ env.BUILD_SUFFIX }}" >> $GITHUB_ENV

- name: Create artifacts directory
- name: Enable KVM
run: |
mkdir -p detox/artifacts/
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: Download All Android Artifacts
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
- name: Download Detox build
uses: actions/download-artifact@v4
with:
path: detox/artifacts/
pattern: android-results-*
name: detox-build
path: android/app/build/outputs/apk/release/

- name: Display structure of downloaded files
run: ls -R android/app/build/outputs/

- name: Save report Detox Dependencies
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.API_LEVEL }}

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.API_LEVEL }}
arch: ${{ env.ARCH }}
disable-animations: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation: false
script: echo 'Generated AVD snapshot for caching.'

- name: Get device name
id: device
run: |
cd detox
npm ci
npm run e2e:save-report
env:
IOS: false
AVD_NAME=$(node -p "require('./.detoxrc').devices.android.device.avdName")
echo "AVD_NAME=$AVD_NAME" >> $GITHUB_OUTPUT
- name: Detox test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.API_LEVEL }}
arch: ${{ env.ARCH }}
avd-name: ${{ steps.device.outputs.AVD_NAME }}
disable-animations: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation: false
script: >
cd detox
npx detox test
--configuration ${{ env.DETOX_CONFIGURATION }}
--headless
--record-logs failing
--record-videos failing
--take-screenshots failing
- name: Upload artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: detox-artifacts
path: artifacts
retention-days: 14
Loading

0 comments on commit ca076f4

Please sign in to comment.