Skip to content
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

[Mobile] Add E2E BrowserStack tests for iOS tests #22610

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

carzh
Copy link
Contributor

@carzh carzh commented Oct 25, 2024

Description

  • Changes running the E2E iOS tests from running in App Center to running in BrowserStack
  • Steps for running locally can be found in the OneNote

Motivation and Context

Misc info

Additional build steps were required to get the necessary testing artifacts for BrowserStack. App Center consumed an entire folder, while BrowserStack requests the following:

  1. a ZIP file of all the tests
  2. an IPA file of the test app

Flow

Here is a rough outline of what is happening in the pipeline:

  1. The build_and_assemble_apple_pods.py script builds the relevant frameworks (currently, this means packages for iOS and Mac)
  2. The test_apple_packages.py script installs the necessary cocoapods for later steps
  3. XCode task to build for testing builds the iOS target for the test app
  4. Now that the test app and the tests have been built, we can zip them, creating the tests .zip file
  5. To create the IPA file, we need to create a .plist XML file which is generated by the generate_plist.py script.
    • Attempts to use the Xcode@5 task to automatically generate the plist file failed.
    • Also, building for testing generates some plist files -- these cannot be used to export an IPA file.
  6. We run the Xcode task to build an .xcarchive file, which is required for creating an IPA file.
  7. We use xcodebuild in a script step to build an IPA file with the xcarchive and plist files from the last two steps.
  8. Finally, we can run the tests using the BrowserStack script.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can commit the suggested changes from lintrunner.

Comment on lines +32 to +36
provisioning_profile_uuid = os.environ["PROVISIONING_PROFILE_UUID"]
formatted_plist = plist_file_content.format(team_id = team_id, provisioning_profile_uuid = provisioning_profile_uuid)

with open(args.dest_file, 'w') as file:
file.write(formatted_plist)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
provisioning_profile_uuid = os.environ["PROVISIONING_PROFILE_UUID"]
formatted_plist = plist_file_content.format(team_id = team_id, provisioning_profile_uuid = provisioning_profile_uuid)
with open(args.dest_file, 'w') as file:
file.write(formatted_plist)
provisioning_profile_uuid = os.environ["PROVISIONING_PROFILE_UUID"]
formatted_plist = plist_file_content.format(team_id=team_id, provisioning_profile_uuid=provisioning_profile_uuid)
with open(args.dest_file, "w") as file:
file.write(formatted_plist)

@@ -0,0 +1,41 @@
import argparse

Check warning

Code scanning / lintrunner

BLACK-ISORT/format Warning

Run lintrunner -a to apply this patch.
@carzh
Copy link
Contributor Author

carzh commented Oct 26, 2024

Working mac packaging pipeline run

Working android packaging pipeline run


# Use script step because exporting the .ipa file using the Xcode@5 task was too brittle (Xcode@5 is designed
# to handle both the .xcarchive step and the .ipa step in the same step -- ran into countless issues with signing
# and the .plist file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm completely fine with directly calling xcodebuild in script steps. the Xcode steps seem to add extra complexity.

do you think it would be simpler to directly run the corresponding xcodebuild commands from the other Xcode steps too?

workingDirectory: '$(Build.BinariesDirectory)/app_center_test/apple_package_test/'
displayName: "Create .ipa file"
env:
DEVELOPER_DIR: /Applications/Xcode_${{ variables.xcodeVersion }}.app/Contents/Developer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to set DEVELOPER_DIR here? there's a call to xcode-select in the earlier use-xcode-version.yml step

<string>{team_id}</string>
<key>provisioningProfiles</key>
<dict>
<key>ai.onnxruntime.tests.ios-package-test</key>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a pretty specific plist file, right? maybe put the script together with the other ios package test files? and consider a more specific name like generate_export_options_plist.py

Comment on lines +31 to +32
team_id = os.environ["APPLE_TEAM_ID"]
provisioning_profile_uuid = os.environ["PROVISIONING_PROFILE_UUID"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: unless these are secret, I'd prefer using command line options for them.

Comment on lines 95 to 96
"Path to the test APK. "
"Typically, the test APK is in "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this help text still refers to APK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants