-
Notifications
You must be signed in to change notification settings - Fork 0
implement e2e testing with Maestro and Browserstack #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
achou11
wants to merge
39
commits into
main
Choose a base branch
from
e2e-maestro
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
f9896f6
introduce initial maestro flow
achou11 4fa4528
record test
achou11 b4ea31b
update app id used in test
achou11 b4ddadc
rename maestro flow
achou11 9ca36be
wip workflow
achou11 bafab2b
specify maestro version to use
achou11 d38fb7a
remove stopRecording command
achou11 ab12dde
simplify test jobs
achou11 2571dfa
allow test suite upload to happen immediately
achou11 1135e42
minor cleanup
achou11 a8ffdcd
fix test-android env
achou11 afadca4
add polling for result step
achou11 eb5cf3c
update secrets and vars names
achou11 ea4303c
fix missing npm install step for build-ios
achou11 2ff9c2a
fix e2e app setup step for build-ios
achou11 e8ab704
rename flow file
achou11 1762251
maybe fix -F curl usage
achou11 4c6bcd1
fix build-android
achou11 e5fe3ff
improve curl calls
achou11 101e0ce
fix upload step in build-ios
achou11 6254152
add commented out needs spec to upload-test-suite
achou11 3dbcd6c
rename zip file used for upload
achou11 93c6f61
curl fixes
achou11 b01826b
fix caching of nodejs-mobile for ios
achou11 0d72bc1
minor fixup
achou11 44335e7
limit devices used due to browserstack plan limitations
achou11 f9cebcf
browserstack project adjustements
achou11 490d6f7
fix url used when executing build
achou11 ec186be
fix dumb mistake
achou11 fd2ee69
update devices
achou11 557529e
increase timeout for flow in CI
achou11 f9a6b47
fix timeout interpolation
achou11 4b7fe32
stick with (larger) hardcoded timeout for now
achou11 132f414
remove startRecording command
achou11 d8c6387
Merge branch 'main' into e2e-maestro
gmaclennan f4d47e8
stop browserstack build/tests on workflow cancel
gmaclennan 8545120
fix cache step ID
gmaclennan 2430a78
fix(e2e): raise jasmine timeout, close projects, surface done signal
gmaclennan 749a791
ci(e2e): drop --ignore-scripts so root prepare runs
gmaclennan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,130 @@ | ||
| name: Run BrowserStack Maestro Tests | ||
|
|
||
| description: Triggers a BrowserStack Maestro build and polls until completion | ||
|
|
||
| inputs: | ||
| platform: | ||
| description: Platform to run tests on (android or ios) | ||
| required: true | ||
| app_url: | ||
| description: BrowserStack app URL (bs://...) | ||
| required: true | ||
| test_suite_url: | ||
| description: BrowserStack test suite URL (bs://...) | ||
| required: true | ||
| devices: | ||
| description: JSON array of device strings | ||
| required: true | ||
| browserstack_project: | ||
| description: BrowserStack project | ||
| required: true | ||
| browserstack_username: | ||
| description: BrowserStack username | ||
| required: true | ||
| browserstack_access_key: | ||
| description: BrowserStack access key | ||
| required: true | ||
| timeout: | ||
| description: Test run timeout in seconds | ||
| required: false | ||
| default: "600" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Validate inputs | ||
| env: | ||
| PLATFORM: ${{ inputs.platform }} | ||
| TIMEOUT: ${{ fromJson(inputs.timeout) }} | ||
| shell: bash | ||
| run: | | ||
| if [[ "$PLATFORM" != "android" && "$PLATFORM" != "ios" ]]; then | ||
| echo "platform must be android or ios" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$TIMEOUT" -lt 30 ]]; then | ||
| echo "timeout must be at least 30 seconds" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Trigger build | ||
| id: trigger | ||
| env: | ||
| APP_URL: ${{ inputs.app_url }} | ||
| TEST_SUITE_URL: ${{ inputs.test_suite_url }} | ||
| DEVICES: ${{ inputs.devices }} | ||
| BROWSERSTACK_PROJECT: ${{ inputs.browserstack_project }} | ||
| BROWSERSTACK_USERNAME: ${{ inputs.browserstack_username }} | ||
| BROWSERSTACK_ACCESS_KEY: ${{ inputs.browserstack_access_key }} | ||
| PLATFORM: ${{ inputs.platform }} | ||
| shell: bash | ||
| run: | | ||
| PAYLOAD=$(jq -n \ | ||
| --arg app "$APP_URL" \ | ||
| --arg suite "$TEST_SUITE_URL" \ | ||
| --argjson devices "$DEVICES" \ | ||
| --arg project "$BROWSERSTACK_PROJECT" \ | ||
| '{ | ||
| app: $app, | ||
| testSuite: $suite, | ||
| devices: $devices, | ||
| project: $project, | ||
| deviceLogs: true, | ||
| maestroVersion: "latest" | ||
| }' | ||
| ) | ||
|
|
||
| BUILD_ID=$(curl --fail --show-error -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \ | ||
| -X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/$PLATFORM/build" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d "$PAYLOAD" \ | ||
| | jq -r '.build_id') | ||
|
|
||
| echo "Triggered build: $BUILD_ID" | ||
| echo "build_id=$BUILD_ID" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Poll for result | ||
| env: | ||
| BUILD_ID: ${{ steps.trigger.outputs.build_id }} | ||
| BROWSERSTACK_USERNAME: ${{ inputs.browserstack_username }} | ||
| BROWSERSTACK_ACCESS_KEY: ${{ inputs.browserstack_access_key }} | ||
| TIMEOUT: ${{ fromJson(inputs.timeout) }} | ||
| shell: bash | ||
| run: | | ||
| MAX_WAIT=$TIMEOUT | ||
| POLL_INTERVAL=30 | ||
| ELAPSED=0 | ||
|
|
||
| while [ "$ELAPSED" -lt "$MAX_WAIT" ]; do | ||
| RESPONSE=$(curl --fail --show-error -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \ | ||
| "https://api-cloud.browserstack.com/app-automate/maestro/v2/builds/$BUILD_ID") | ||
|
|
||
| STATUS=$(echo "$RESPONSE" | jq -r '.status') | ||
| echo "[${ELAPSED}s] Build $BUILD_ID status: $STATUS" | ||
|
|
||
| case "$STATUS" in | ||
| passed|completed) echo "Tests passed"; exit 0 ;; | ||
| failed) echo "Tests failed"; exit 1 ;; | ||
| esac | ||
|
|
||
| sleep "$POLL_INTERVAL" | ||
| ELAPSED=$((ELAPSED + POLL_INTERVAL)) | ||
| done | ||
|
|
||
| echo "Timed out after ${MAX_WAIT}s waiting for build $BUILD_ID" | ||
| exit 1 | ||
|
|
||
| - name: Stop BrowserStack build on cancel | ||
| if: cancelled() && steps.trigger.outputs.build_id != '' | ||
| env: | ||
| BUILD_ID: ${{ steps.trigger.outputs.build_id }} | ||
| BROWSERSTACK_USERNAME: ${{ inputs.browserstack_username }} | ||
| BROWSERSTACK_ACCESS_KEY: ${{ inputs.browserstack_access_key }} | ||
| shell: bash | ||
| run: | | ||
| [[ "$BUILD_ID" == "null" ]] && exit 0 | ||
| echo "Stopping BrowserStack build $BUILD_ID" | ||
| curl --show-error -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \ | ||
| -X POST "https://api-cloud.browserstack.com/app-automate/maestro/builds/$BUILD_ID/stop" \ | ||
| -H "Content-Type: application/json" || true |
This file contains hidden or 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,264 @@ | ||
| name: E2E Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| NODEJS_MOBILE_VERSION: v18.20.4 | ||
|
|
||
| jobs: | ||
| build-android: | ||
| if: ${{ github.event.pull_request.draft == false }} | ||
| name: Build (Android) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| permissions: | ||
| contents: read | ||
| outputs: | ||
| app_url: ${{ steps.upload.outputs.app_url }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: package.json | ||
|
|
||
| - uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: temurin | ||
| java-version: 17 | ||
|
|
||
| - name: Setup Android SDK | ||
| uses: android-actions/setup-android@v3 | ||
|
|
||
| - name: Cache nodejs-mobile binaries | ||
| id: cache-libnode | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: android/libnode | ||
| # hashFiles(...) folds the BASE_URL (defined inside the | ||
| # download script) into the cache key, so any swap of the | ||
| # source repo automatically invalidates stale caches. | ||
| key: nodejs-mobile-${{ env.NODEJS_MOBILE_VERSION }}-android-${{ hashFiles('scripts/download-nodejs-mobile.sh') }} | ||
|
|
||
| - name: Download nodejs-mobile binaries | ||
| if: steps.cache-libnode.outputs.cache-hit != 'true' | ||
| run: ./scripts/download-nodejs-mobile.sh | ||
|
|
||
| - name: Set up Gradle | ||
| uses: gradle/actions/setup-gradle@v4 | ||
|
|
||
| - name: Install npm dependencies | ||
| run: npm install | ||
|
|
||
| - name: Build backend bundle | ||
| run: npm run backend:build | ||
|
|
||
| - name: Set up E2E app | ||
| working-directory: apps/e2e | ||
| run: | | ||
| npm install | ||
| npx expo prebuild --platform android --no-install | ||
|
|
||
| - name: Build APK | ||
| working-directory: apps/e2e/android | ||
| run: | | ||
| ./gradlew assembleRelease --no-daemon | ||
|
|
||
| - name: Upload APK | ||
| id: upload | ||
| env: | ||
| BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY_TESTS }} | ||
| BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME_TESTS }} | ||
| run: | | ||
| APK_RELATIVE_PATH="./apps/e2e/android/app/build/outputs/apk/release/app-release.apk" | ||
|
|
||
| APP_URL=$(curl --fail --show-error -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \ | ||
| -X POST "https://api-cloud.browserstack.com/app-automate/upload" \ | ||
| -F "file=@$APK_RELATIVE_PATH" | jq -r '.app_url') | ||
|
|
||
| echo "app_url=$APP_URL" >> $GITHUB_OUTPUT | ||
|
|
||
| build-ios: | ||
| if: ${{ github.event.pull_request.draft == false }} | ||
| name: Build (iOS) | ||
| runs-on: macos-15 | ||
| timeout-minutes: 15 | ||
| permissions: | ||
| contents: read | ||
| outputs: | ||
| app_url: ${{ steps.upload.outputs.app_url }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Select Xcode | ||
| run: sudo xcode-select -s /Applications/Xcode_26.3.app/Contents/Developer | ||
|
|
||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: package.json | ||
|
|
||
| - name: Cache nodejs-mobile binaries | ||
| id: cache-ios-framework | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ios/NodeMobile.xcframework | ||
| # hashFiles(...) folds the BASE_URL (defined inside the | ||
| # download script) into the cache key, so any swap of the | ||
| # source repo automatically invalidates stale caches. | ||
| key: nodejs-mobile-${{ env.NODEJS_MOBILE_VERSION }}-ios-${{ hashFiles('scripts/download-nodejs-mobile.sh') }} | ||
|
|
||
| - name: Download nodejs-mobile binaries | ||
| if: steps.cache-ios-framework.outputs.cache-hit != 'true' | ||
| run: ./scripts/download-nodejs-mobile.sh | ||
|
|
||
| - name: Install npm dependencies | ||
| run: npm install | ||
|
|
||
| - name: Build backend bundle | ||
| run: npm run backend:build | ||
|
|
||
| - name: Set up E2E app | ||
| working-directory: apps/e2e | ||
| run: | | ||
| npm install | ||
| npx expo prebuild --platform ios | ||
|
|
||
| - name: Build .ipa | ||
| working-directory: apps/e2e/ios | ||
| run: | | ||
| xcodebuild archive \ | ||
| -workspace corereactnativee2e.xcworkspace \ | ||
| -scheme corereactnativee2e \ | ||
| -sdk iphoneos \ | ||
| -destination 'generic/platform=iOS' \ | ||
| -archivePath ./build/corereactnativee2e.xcarchive \ | ||
| CODE_SIGNING_ALLOWED='NO' | ||
|
|
||
| mkdir -p Payload | ||
| cp -r ./build/corereactnativee2e.xcarchive/Products/Applications/corereactnativee2e.app Payload/ | ||
| zip -r corereactnativee2e.ipa Payload/ | ||
|
|
||
| - name: Upload | ||
| id: upload | ||
| env: | ||
| BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY_TESTS }} | ||
| BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME_TESTS }} | ||
| run: | | ||
| IPA_RELATIVE_PATH="./apps/e2e/ios/corereactnativee2e.ipa" | ||
|
|
||
| APP_URL=$(curl --fail --show-error -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \ | ||
| -X POST "https://api-cloud.browserstack.com/app-automate/upload" \ | ||
| -F "file=@$IPA_RELATIVE_PATH" | jq -r '.app_url') | ||
|
|
||
| echo "app_url=$APP_URL" >> $GITHUB_OUTPUT | ||
|
|
||
| upload-test-suite: | ||
| if: ${{ github.event.pull_request.draft == false }} | ||
| name: Upload test suite | ||
| # TODO: Enable when we know this job works | ||
| # needs: [build-android, build-ios] | ||
|
Comment on lines
+171
to
+172
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to re-enable this now? |
||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| outputs: | ||
| test_suite_url: ${{ steps.upload.outputs.test_suite_url }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
| sparse-checkout: maestro | ||
|
|
||
| - name: Upload test suite to Browserstack | ||
| id: upload | ||
| env: | ||
| BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY_TESTS }} | ||
| BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME_TESTS }} | ||
| run: | | ||
| ZIP_NAME="flows.zip" | ||
|
|
||
| zip -r "$ZIP_NAME" maestro/e2e.yaml | ||
|
|
||
| TEST_SUITE_URL=$(curl --fail --show-error -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \ | ||
| -X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/test-suite" \ | ||
| -F "file=@$ZIP_NAME" | jq -r '.test_suite_url') | ||
|
|
||
| echo "test_suite_url=$TEST_SUITE_URL" >> $GITHUB_OUTPUT | ||
|
|
||
| test-android: | ||
| name: Run tests (Android) | ||
| needs: [build-android, upload-test-suite] | ||
| runs-on: ubuntu-latest | ||
| # TODO: Adjust based on actual timing | ||
| timeout-minutes: 60 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
| sparse-checkout: .github/actions | ||
|
|
||
| - uses: ./.github/actions/run-browserstack-maestro | ||
| with: | ||
| platform: android | ||
| app_url: ${{ needs.build-android.outputs.app_url }} | ||
| test_suite_url: ${{ needs.upload-test-suite.outputs.test_suite_url }} | ||
| browserstack_project: ${{ vars.BROWSERSTACK_PROJECT_TESTS }} | ||
| browserstack_username: ${{ secrets.BROWSERSTACK_USERNAME_TESTS }} | ||
| browserstack_access_key: ${{ secrets.BROWSERSTACK_ACCESS_KEY_TESTS }} | ||
| # TODO: Adjust based on actual timing | ||
| timeout: 1800 | ||
| devices: >- | ||
| [ | ||
| "Google Pixel 9-16.0", | ||
| "Huawei Nova 11 SE-12.0", | ||
| "Motorola Moto G71 5G-11.0", | ||
| "OnePlus 13R-15.0", | ||
| "Oppo Reno 6-11.0", | ||
| "Samsung Galaxy Note 9-8.1", | ||
| "Vivo Y21-11.0", | ||
| "Xiaomi Redmi Note 11-11.0" | ||
| ] | ||
|
|
||
| test-ios: | ||
| name: Run tests (iOS) | ||
| needs: [build-ios, upload-test-suite] | ||
| runs-on: ubuntu-latest | ||
| # TODO: Adjust based on actual timing | ||
| timeout-minutes: 60 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
| sparse-checkout: .github/actions | ||
|
|
||
| - uses: ./.github/actions/run-browserstack-maestro | ||
| with: | ||
| platform: ios | ||
| app_url: ${{ needs.build-ios.outputs.app_url }} | ||
| test_suite_url: ${{ needs.upload-test-suite.outputs.test_suite_url }} | ||
| browserstack_project: ${{ vars.BROWSERSTACK_PROJECT_TESTS }} | ||
| browserstack_username: ${{ secrets.BROWSERSTACK_USERNAME_TESTS }} | ||
| browserstack_access_key: ${{ secrets.BROWSERSTACK_ACCESS_KEY_TESTS }} | ||
| # TODO: Adjust based on actual timing | ||
| timeout: 1800 | ||
| devices: >- | ||
| [ | ||
| "iPhone 15-17", | ||
| "iPhone 17-26" | ||
| ] | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leaves the browserstack build running. I've added a step to the composite action to stop it on cancel.