Content-Length: 546716 | pFad | http://github.com/muxinc/mux-player-swift/commit/f65842095cc08ad9b84a5f0f7961f22d7bb9f84e

A4 ci: add sauce labs (#60) · muxinc/mux-player-swift@f658420 · GitHub
Skip to content

Commit

Permalink
ci: add sauce labs (#60)
Browse files Browse the repository at this point in the history
* 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
andrewjl-mux and daytime-em authored Oct 14, 2024
1 parent 763abe3 commit f658420
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 11 deletions.
13 changes: 12 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ steps:
label: ":xcode_simulator: Unit Test Pass"
- wait
- command: "./scripts/run-ui-tests.sh MuxPlayerSwiftExample"
label: ":xcode_simulator: Baseline Unit Test Pass"
label: ":xcode_simulator: UI Test Pass"
- wait
- command: "./scripts/create-example-application-archive.sh MuxPlayerSwiftExample"
label: ":xcode: Export Test Application and Test Runner Archives"
artifact_paths:
- "./Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.ipa"
- "./Examples/MuxPlayerSwiftExample/Packaging.log"
- "./Examples/MuxPlayerSwiftExample/DistributionSummary.plist"
- "./Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExampleUITests-Runner.ipa"
- wait
- command: "echo $BUILDKITE_HOOKS_PATH && ls -ls $BUILDKITE_HOOKS_PATH && buildkite-agent artifact download \"Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.ipa\" \"$PWD\" && buildkite-agent artifact download \"Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExampleUITests-Runner.ipa\" \"$PWD\" && ./scripts/upload-example-application-to-sauce-labs.sh"
label: ":saucelabs: Upload Test Application to Sauce Labs App Storage"
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ DerivedData/
*.dSYM.zip
*.dSYM

## App export
**/Packaging.log
**/DistributionSummary.plist
**/ExportOptions.plist

## Sauce Labs Test Packaging
**/Payload

## Playgrounds
timeline.xctimeline
playground.xcworkspace
Expand Down
22 changes: 22 additions & 0 deletions .sauce/config.yml
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
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 1500;
LastUpgradeCheck = 1600;
TargetAttributes = {
193228B62ACF6AC700966FE1 = {
CreatedOnToolsVersion = 15.0;
Expand Down Expand Up @@ -466,6 +466,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = XX95P4Y787;
Expand All @@ -484,6 +485,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mux.player.example.MuxPlayerSwiftExample.MuxPlayerSwiftExample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -495,6 +497,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = XX95P4Y787;
Expand All @@ -513,6 +516,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mux.player.example.MuxPlayerSwiftExample.MuxPlayerSwiftExample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -522,7 +526,6 @@
193228E52ACF6AC900966FE1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
Expand All @@ -542,7 +545,6 @@
193228E62ACF6AC900966FE1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
Expand All @@ -562,7 +564,6 @@
193228E82ACF6AC900966FE1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = XX95P4Y787;
Expand All @@ -580,7 +581,6 @@
193228E92ACF6AC900966FE1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = XX95P4Y787;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,5 @@
</array>
</dict>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
</dict>
</plist>
124 changes: 124 additions & 0 deletions scripts/create-example-application-archive.sh
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"

51 changes: 51 additions & 0 deletions scripts/upload-example-application-to-sauce-labs.sh
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

0 comments on commit f658420

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/muxinc/mux-player-swift/commit/f65842095cc08ad9b84a5f0f7961f22d7bb9f84e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy