Skip to content

Commit

Permalink
ci: deploy example to sauce labs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjl-mux committed Nov 6, 2024
1 parent e1f76fa commit 3ff60fd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
agents:
queue: "macOS-Monterey-12-4"

steps:
- command: "./scripts/create-example-application-archive.sh MuxStatsGoogleIMAPluginSPMExampleIOS"
label: ":xcode: Export Test Application Archive"
artifact_paths:
- "./Examples/MuxStatsGoogleIMAPluginSPMExampleIOS/MuxStatsGoogleIMAPluginSPMExampleIOS.ipa"
- "./Examples/MuxStatsGoogleIMAPluginSPMExampleIOS/Packaging.log"
- "./Examples/MuxStatsGoogleIMAPluginSPMExampleIOS/DistributionSummary.plist"
- 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"
38 changes: 38 additions & 0 deletions scripts/upload-example-application-to-sauce-labs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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="MuxStatsGoogleIMAPluginSPMExampleIOS.ipa"
# TODO: make this an argument
readonly APPLICATION_PAYLOAD_PATH="Examples/MuxStatsGoogleIMAPluginSPMExampleIOS/${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

0 comments on commit 3ff60fd

Please sign in to comment.