-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: e2e tesing on android ci/cd (#48)
* feat: e2e tesing on android ci/cd * fix: fastlane add to gemfile * fix: broken refer to non existing lane * add: fastlane-plugin-stream_actions to use sugar syntax * add: fastlane-plugin-stream_actions to use sugar syntax * add: Pluginfile * fix: changing test device * fix: api 30 pixel 5 * fix: upgrade jest and improve test performance by onky using fake timers, simulate delay after fetch
- Loading branch information
1 parent
d45f6a5
commit 327696e
Showing
13 changed files
with
474 additions
and
23 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
root: true, | ||
extends: '@react-native', | ||
ignorePatterns: ['e2e/'], | ||
ignorePatterns: ['e2e/', 'coverage'], | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: 'Bootstrap' | ||
description: 'Bootstrap Dependencies' | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- run: echo "IMAGE=${ImageOS}-${ImageVersion}" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- uses: actions/setup-node@v3 | ||
if: ${{ env.INSTALL_NODE == 'true' }} | ||
with: | ||
node-version: 18.x | ||
cache: 'yarn' | ||
|
||
- name: Install Yarn Dependencies | ||
if: ${{ env.INSTALL_NODE == 'true' }} | ||
run: yarn install --immutable | ||
shell: bash | ||
|
||
- name: Cache pods | ||
uses: actions/cache@v3 | ||
if: ${{ env.INSTALL_PODS == 'true' }} | ||
with: | ||
path: ios/Pods | ||
key: ${{ env.IMAGE }}-pods-${{ hashFiles('ios/Podfile.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-pods- | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.1 | ||
bundler-cache: true | ||
|
||
- name: Cache Gradle | ||
if: ${{ env.INSTALL_JAVA == 'true' }} | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ env.IMAGE }}-gradle-${{ hashFiles('*.gradle*', 'gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- uses: actions/setup-java@v3 | ||
if: ${{ env.INSTALL_JAVA == 'true' }} | ||
with: | ||
distribution: 'zulu' | ||
java-version: '11' | ||
check-latest: true | ||
|
||
- name: Install pods | ||
if: ${{ env.INSTALL_PODS == 'true' }} | ||
run: bundle exec fastlane pod_install | ||
shell: bash | ||
|
||
# Retrieve the cached emulator snapshot | ||
- uses: actions/cache@v3 | ||
if: ${{ env.INSTALL_ANDROID_EMULATOR == 'true' }} | ||
id: avd-cache | ||
with: | ||
path: | | ||
~/.android/avd/* | ||
~/.android/adb* | ||
key: ${{ env.IMAGE }}-android-emulator | ||
|
||
# Required for Maestro on iOS | ||
- uses: actions/[email protected] | ||
if: ${{ env.INSTALL_PYTHON == 'true' }} | ||
with: | ||
python-version: 3.8 | ||
cache: 'pip' | ||
|
||
# Required to run E2E testing | ||
- name: Install Maestro | ||
if: ${{ env.INSTALL_MAESTRO == 'true' }} | ||
shell: bash | ||
run: | | ||
if [ "${{ env.INSTALL_PYTHON }}" = "true" ]; then | ||
brew install facebook/fb/idb-companion | ||
pip install fb-idb | ||
fi | ||
env MAESTRO_VERSION="1.29.0" curl -Ls 'https://get.maestro.mobile.dev' | bash | ||
echo "$HOME/.maestro/bin" >> $GITHUB_PATH | ||
# Required to capture Android video during E2E testing | ||
- name: Install FFmpeg | ||
if: ${{ env.INSTALL_FFMPEG == 'true' }} | ||
uses: FedericoCarboni/setup-ffmpeg@v2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: E2E Testing | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
concurrency: | ||
group: react-native-workflow-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build_android: | ||
name: Build Android | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/bootstrap | ||
timeout-minutes: 15 | ||
env: | ||
INSTALL_NODE: true | ||
INSTALL_JAVA: true | ||
|
||
- name: Build | ||
run: bundle exec fastlane build_android | ||
|
||
- name: Upload .apk | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: apk | ||
path: '**/dist/*.apk' | ||
|
||
test_android: | ||
name: Test Android | ||
needs: build_android | ||
timeout-minutes: 100 | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/bootstrap | ||
timeout-minutes: 15 | ||
env: | ||
INSTALL_NODE: true | ||
INSTALL_FFMPEG: true | ||
INSTALL_MAESTRO: true | ||
INSTALL_ANDROID_EMULATOR: true | ||
|
||
- name: Download .apk | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: apk | ||
|
||
- name: Create AVD Snapshot | ||
if: steps.avd-cache.outputs.cache-hit != 'true' | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: 30 | ||
arch: x86_64 | ||
target: google_apis | ||
profile: pixel_5 | ||
force-avd-creation: false | ||
avd-name: test | ||
ram-size: 8192M | ||
disk-size: 2048M | ||
emulator-boot-timeout: 1000 | ||
emulator-options: -no-window -no-boot-anim -no-audio -no-snapshot-load -gpu swiftshader_indirect | ||
script: echo 'AVD snapshot is generated and will be cached for the future runs.' | ||
|
||
- name: Test | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: 30 | ||
arch: x86_64 | ||
target: google_apis | ||
profile: pixel_5 | ||
force-avd-creation: false | ||
avd-name: test | ||
ram-size: 8192M | ||
disk-size: 2048M | ||
emulator-boot-timeout: 1000 | ||
emulator-options: -no-window -no-boot-anim -no-audio -no-snapshot-load -gpu swiftshader_indirect | ||
script: bundle exec fastlane test_android | ||
|
||
- uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
name: Android Test Data | ||
path: | | ||
**/fastlane/recordings | ||
~/.maestro/tests | ||
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
Oops, something went wrong.