Skip to content

Commit

Permalink
run e2e tests in pr
Browse files Browse the repository at this point in the history
  • Loading branch information
cipolleschi committed Sep 19, 2024
1 parent 0f60c01 commit 9272d1f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
18 changes: 10 additions & 8 deletions .github/actions/maestro-android/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,26 @@ runs:
api-level: 24
arch: x86
script: |
if [[ "${{ inputs.flavor }}" == debug ]]; then
echo "Running Metro in backgroud"
yarn start &
fi
echo "Install APK from ${{ inputs.app-path }}"
adb install "${{ inputs.app-path }}"
if [ "${{ inputs.flavor }}" == "Debug" ]; then
echo "Start Metro in Background"
yarn start &
fi
echo "Start recording to /sdcard/screen.mp4"
adb shell screenrecord /sdcard/screen.mp4
echo "Start testing ${{ inputs.maestro-flow }}"
$HOME/.maestro/bin/maestro test ${{ inputs.maestro-flow }} --format junit -e APP_ID=${{ inputs.app-id }} --debug-output /tmp/MaestroLogs
echo "Stop recording. Saving to screen.mp4"
adb pull /sdcard/screen.mp4
- name: Stop recording
shell: bash
if: always()
run: adb pull /sdcard/screen.mp4
- name: Store tests result
uses: actions/upload-artifact@v3
if: always()
with:
name: e2e_android_${{ inputs.app-id }}_report_${{ inputs.jsengine }}_${{ inputs.flavor }}
path: |
Expand Down
10 changes: 4 additions & 6 deletions .github/actions/maestro-ios/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ runs:
with:
java-version: '17'
distribution: 'zulu'
- name: Start Metro in Debug
shell: bash
if: ${{ inputs.flavor == 'Debug' }}
run: yarn start &
- name: Run tests
id: run-tests
shell: bash
Expand All @@ -41,12 +45,6 @@ runs:
# Maestro can fail in case of flakyness, we have some retry logic.
set +e
# Start metro in Debug mode
if [[ ${{ inputs.flavor }} == "Debug" ]]; then
echo "Starting Metro in background..."
yarn start &
fi
echo "Launching iOS Simulator: iPhone 15 Pro"
xcrun simctl boot "iPhone 15 Pro"
Expand Down
33 changes: 23 additions & 10 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }}

test_e2e_ios_rntester:
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests == 'true' }}
# if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests == 'true' }}
runs-on: macos-13
needs:
[build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos]
Expand Down Expand Up @@ -212,14 +212,14 @@ jobs:
- name: Run E2E Tests
uses: ./.github/actions/maestro-ios
with:
app-path: "/tmp/RNTesterBuild/Build/Products/${{ inputs.flavor }}-iphonesimulator/RNTester.app"
app-path: "/tmp/RNTesterBuild/Build/Products/${{ matrix.flavor }}-iphonesimulator/RNTester.app"
app-id: com.meta.RNTester.localDevelopment
jsengine: ${{ matrix.jsengine }}
maestro-flow: ./packages/rn-tester/.maestro/
flavor: ${{ matrix.flavor }}

test_e2e_ios_templateapp:
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests == 'true' }}
# if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests == 'true' }}
runs-on: macos-13
needs: build_npm_package
env:
Expand Down Expand Up @@ -264,7 +264,14 @@ jobs:
HERMES_PATH=$(find /tmp/react-native-tmp -type f -name "*.tar.gz")
echo "Hermes path is $HERMES_PATH"
node ./scripts/e2e/init-project-e2e.js --projectName RNTestProject --currentBranch ${{ github.ref_name }} --directory /tmp/RNTestProject --pathToLocalReactNative $REACT_NATIVE_PKG
# For stable branches, we want to use the stable branch of the template
# In all the other cases, we want to use "main"
BRANCH=${{ github.ref_name }}
if ! [[ $BRANCH == *-stable* ]]; then
BRANCH=main
fi
node ./scripts/e2e/init-project-e2e.js --projectName RNTestProject --currentBranch $BRANCH --directory /tmp/RNTestProject --pathToLocalReactNative $REACT_NATIVE_PKG
cd /tmp/RNTestProject/ios
bundle install
Expand All @@ -287,7 +294,7 @@ jobs:
flavor: ${{ matrix.flavor }}

test_e2e_android_templateapp:
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests == 'true'}}
# if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests == 'true'}}
runs-on: 4-core-ubuntu
needs: build_npm_package
continue-on-error: true
Expand Down Expand Up @@ -329,7 +336,13 @@ jobs:
MAVEN_LOCAL=/tmp/react-native-tmp/maven-local
echo "Maven local path is $MAVEN_LOCAL"
node ./scripts/e2e/init-project-e2e.js --projectName RNTestProject --currentBranch ${{ github.ref_name }} --directory /tmp/RNTestProject --pathToLocalReactNative $REACT_NATIVE_PKG
# For stable branches, we want to use the stable branch of the template
# In all the other cases, we want to use "main"
BRANCH=${{ github.ref_name }}
if ! [[ $BRANCH == *-stable* ]]; then
BRANCH=main
fi
node ./scripts/e2e/init-project-e2e.js --projectName RNTestProject --currentBranch $BRANCH --directory /tmp/RNTestProject --pathToLocalReactNative $REACT_NATIVE_PKG
echo "Feed maven local to gradle.properties"
cd /tmp/RNTestProject
Expand Down Expand Up @@ -401,10 +414,10 @@ jobs:
uses: ./.github/actions/build-android
with:
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
run-e2e-tests: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests == 'true'}}
run-e2e-tests: true #${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests == 'true'}}

test_e2e_android_rntester:
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests == 'true' }}
# if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests == 'true' }}
runs-on: ubuntu-latest
needs: [build_android]
strategy:
Expand All @@ -422,14 +435,14 @@ jobs:
- name: Download APK
uses: actions/download-artifact@v4
with:
name: rntester-${{ matrix.jsengine }}-release
name: rntester-${{ matrix.jsengine }}-${{ matrix.flavor }}
path: ./packages/rn-tester/android/app/build/outputs/apk/${{ matrix.jsengine }}/${{ matrix.flavor }}/
- name: Print folder structure
run: ls -lR ./packages/rn-tester/android/app/build/outputs/apk/${{ matrix.jsengine }}/${{ matrix.flavor }}/
- name: Run E2E Tests
uses: ./.github/actions/maestro-android
with:
app-path: ./packages/rn-tester/android/app/build/outputs/apk/${{ matrix.jsengine }}/release/app-${{ matrix.jsengine }}-x86-release.apk
app-path: ./packages/rn-tester/android/app/build/outputs/apk/${{ matrix.jsengine }}/${{ matrix.flavor }}/app-${{ matrix.jsengine }}-x86-${{ matrix.flavor }}.apk
app-id: com.facebook.react.uiapp
jsengine: ${{ matrix.jsengine }}
maestro-flow: ./packages/rn-tester/.maestro/
Expand Down

0 comments on commit 9272d1f

Please sign in to comment.