-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* upload example application to SL app storage for live testing * build and package example application and UI test runner for upload to SL * add sauce labs test config, deploy tests to physical SL devices --------- Co-authored-by: Emily Dixon <edixon@mux.com>
- Loading branch information
1 parent
763abe3
commit f658420
Showing
8 changed files
with
223 additions
and
11 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
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
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,22 @@ | ||
apiVersion: v1alpha | ||
kind: xcuitest | ||
sauce: | ||
region: us-west-1 | ||
xcuitest: | ||
app: storage:filename=MuxPlayerSwiftExample.ipa | ||
appDescription: Mux Player Swift example application | ||
testApp: Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExampleUITests-Runner.ipa | ||
testAppDescription: Mux Player Swift test application for user interface testing | ||
|
||
suites: | ||
- name: "example application xcuitest" | ||
testOptions: | ||
class: | ||
- MUXSDKStatsExampleSPMUITests.MUXSDKStatsExampleSPMUITests | ||
devices: | ||
- name: "iPhone 15" | ||
platformVersion: "18.0" | ||
options: | ||
carrierConnectivity: false | ||
deviceType: PHONE | ||
private: false |
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
2 changes: 1 addition & 1 deletion
2
...ple/MuxPlayerSwiftExample.xcodeproj/xcshareddata/xcschemes/MuxPlayerSwiftExample.xcscheme
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
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 |
---|---|---|
|
@@ -21,9 +21,5 @@ | |
</array> | ||
</dict> | ||
</dict> | ||
<key>UIBackgroundModes</key> | ||
<array> | ||
<string>audio</string> | ||
</array> | ||
</dict> | ||
</plist> |
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,124 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
readonly EXPORT_OPTIONS_TEAM_ID="XX95P4Y787" | ||
|
||
readonly XCODE=$(xcodebuild -version | grep Xcode | cut -d " " -f2) | ||
readonly EXAMPLE_APPLICATION_ARCHIVE_NAME=MuxPlayerSwiftExample | ||
readonly EXAMPLE_APPLICATION_ARCHIVE_PATH="${PWD}/Examples/MuxPlayerSwiftExample/.build/${EXAMPLE_APPLICATION_ARCHIVE_NAME}.xcarchive" | ||
readonly EXAMPLE_APPLICATION_EXPORT_PATH="${PWD}/Examples/MuxPlayerSwiftExample" | ||
readonly EXPORT_OPTIONS_PLIST_NAME="ExportOptions" | ||
readonly EXPORT_OPTIONS_PLIST_PATH="${EXAMPLE_APPLICATION_EXPORT_PATH}/${EXPORT_OPTIONS_PLIST_NAME}.plist" | ||
readonly PROJECT_DIR="${PWD}/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.xcodeproj" | ||
|
||
if [ $# -ne 1 ]; then | ||
echo "▸ Usage: $0 SCHEME" | ||
exit 1 | ||
fi | ||
|
||
readonly SCHEME="$1" | ||
|
||
if ! command -v xcbeautify &> /dev/null | ||
then | ||
echo -e "\033[1;31m ERROR: xcbeautify could not be found please install it... \033[0m" | ||
exit 1 | ||
fi | ||
|
||
echo "▸ Current Xcode Path:" | ||
|
||
xcode-select -p | ||
|
||
echo "▸ Using Xcode Version: ${XCODE}" | ||
|
||
echo "▸ Using Swift Toolchain Version:" | ||
|
||
swift --version DEVELOPER_DIR=$(xcode-select -p) | ||
|
||
echo "▸ Available Xcode SDKs:" | ||
|
||
xcodebuild -showsdks -json | ||
|
||
echo "▸ Resolve Package Dependencies" | ||
|
||
xcodebuild -resolvePackageDependencies | ||
|
||
cd Examples/MuxPlayerSwiftExample | ||
|
||
echo "▸ Available Schemes:" | ||
|
||
xcodebuild -list -json -project $PROJECT_DIR | ||
|
||
echo "▸ Creating example application archive" | ||
|
||
xcodebuild clean archive -project $PROJECT_DIR \ | ||
-scheme $SCHEME \ | ||
-destination generic/platform=iOS \ | ||
-archivePath $EXAMPLE_APPLICATION_ARCHIVE_PATH \ | ||
-allowProvisioningUpdates \ | ||
CODE_SIGNING_REQUIRED=YES | xcbeautify | ||
|
||
if [[ $? == 0 ]]; then | ||
echo "▸ Successfully created archive at ${EXAMPLE_APPLICATION_ARCHIVE_PATH}" | ||
else | ||
echo -e "\033[1;31m ERROR: Failed to create archive at ${EXAMPLE_APPLICATION_ARCHIVE_PATH} \033[0m" | ||
exit 1 | ||
fi | ||
|
||
echo "▸ Creating export options plist" | ||
|
||
rm -rf "${EXPORT_OPTIONS_PLIST_PATH}" | ||
|
||
plutil -create xml1 "${EXPORT_OPTIONS_PLIST_PATH}" | ||
|
||
/usr/libexec/PlistBuddy -c "Add method string debugging" "${EXPORT_OPTIONS_PLIST_PATH}" | ||
|
||
/usr/libexec/PlistBuddy -c "Add teamID string ${EXPORT_OPTIONS_TEAM_ID}" "${EXPORT_OPTIONS_PLIST_PATH}" | ||
|
||
/usr/libexec/PlistBuddy -c "Add thinning string <none>" "${EXPORT_OPTIONS_PLIST_PATH}" | ||
|
||
/usr/libexec/PlistBuddy -c "Add compileBitcode bool false" "${EXPORT_OPTIONS_PLIST_PATH}" | ||
|
||
echo "▸ Created export options plist: $(cat $EXPORT_OPTIONS_PLIST_PATH)" | ||
|
||
echo "▸ Exporting example application archive to ${EXAMPLE_APPLICATION_EXPORT_PATH}" | ||
|
||
# If exportArchive is failing and rvm is installed locally then run: rvm use system | ||
# Xcode 15 ipatool requires system ruby to export an archive. | ||
# To confirm this: run xcodebuild with -verbose flag and check IDEDistribution | ||
# distribution logs (.xcdistributionlogs) to see if there is a sqlite installation error. | ||
|
||
xcodebuild -exportArchive \ | ||
-archivePath $EXAMPLE_APPLICATION_ARCHIVE_PATH \ | ||
-exportPath $EXAMPLE_APPLICATION_EXPORT_PATH \ | ||
-exportOptionsPlist $EXPORT_OPTIONS_PLIST_PATH | xcbeautify | ||
|
||
if [[ $? == 0 ]]; then | ||
echo "▸ Successfully exported archive at ${EXAMPLE_APPLICATION_EXPORT_PATH}" | ||
else | ||
echo -e "\033[1;31m ERROR: Failed to export archive to ${EXAMPLE_APPLICATION_EXPORT_PATH} \033[0m" | ||
exit 1 | ||
fi | ||
|
||
echo "▸ Creating example application test runner archive" | ||
|
||
xcodebuild build-for-testing -project $PROJECT_DIR \ | ||
-scheme $SCHEME \ | ||
-destination generic/platform=iOS \ | ||
-derivedDataPath $PWD/Build | xcbeautify | ||
|
||
if [[ $? == 0 ]]; then | ||
echo "▸ Successfully created test runner archive." | ||
else | ||
echo -e "\033[1;31m ERROR: Failed to create test runner archive. \033[0m" | ||
exit 1 | ||
fi | ||
|
||
mkdir -p $PWD/Payload | ||
|
||
cp -r "$(find $PWD/Build -name 'MuxPlayerSwiftExampleUITests-Runner.app')" $PWD/Payload | ||
|
||
zip -ry "${SCHEME}UITests-Runner.ipa" Payload | ||
|
||
echo "▸ Created example application test runner archive at $PWD/MuxPlayerSwiftExampleUITests-Runner.ipa" | ||
|
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,51 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
if ! command -v saucectl &> /dev/null | ||
then | ||
echo -e "\033[1;31m ERROR: saucectl could not be found please install it... \033[0m" | ||
exit 1 | ||
fi | ||
|
||
if ! command -v jq &> /dev/null | ||
then | ||
echo -e "\033[1;31m ERROR: jq could not be found please install it... \033[0m" | ||
exit 1 | ||
fi | ||
|
||
readonly APPLICATION_NAME="MuxPlayerSwiftExample.ipa" | ||
# TODO: make this an argument | ||
readonly APPLICATION_PAYLOAD_PATH="Examples/MuxPlayerSwiftExample/${APPLICATION_NAME}" | ||
|
||
if [ ! -f $APPLICATION_PAYLOAD_PATH ]; then | ||
echo -e "\033[1;31m ERROR: application archive not found \033[0m" | ||
fi | ||
|
||
# re-exported so saucectl CLI can use them | ||
export SAUCE_USERNAME=$BUILDKITE_MAC_STADIUM_SAUCE_USERNAME | ||
export SAUCE_ACCESS_KEY=$BUILDKITE_MAC_STADIUM_SAUCE_ACCESS_KEY | ||
|
||
echo "▸ Uploading test application to Sauce Labs App Storage" | ||
|
||
curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" --location --request POST 'https://api.us-west-1.saucelabs.com/v1/storage/upload' --form "payload=@\"${APPLICATION_PAYLOAD_PATH}\"" --form "name=\"${APPLICATION_NAME}\"" | ||
|
||
if [[ $? == 0 ]]; then | ||
echo "▸ Successfully uploaded to Sauce Labs application storage." | ||
else | ||
echo -e "\033[1;31m ERROR: Failed to upload to Sauce Labs application storage. Check for valid credentials. \033[0m" | ||
exit 1 | ||
fi | ||
|
||
echo "▸ Deploying tests to Sauce Labs" | ||
|
||
echo "▸ Sauce Labs config: $(cat $PWD/.sauce/config.yml)" | ||
|
||
saucectl run -c "$PWD/.sauce/config.yml" | ||
|
||
if [[ $? == 0 ]]; then | ||
echo "▸ Successfully deployed Sauce Labs tests" | ||
else | ||
echo -e "\033[1;31m ERROR: Failed to deploy Sauce Labs tests \033[0m" | ||
exit 1 | ||
fi |