From 3ff60fd963b2cc1e0e31b9014c7a38510da0fad6 Mon Sep 17 00:00:00 2001 From: AJ Lauer Barinov Date: Wed, 6 Nov 2024 10:02:22 -0800 Subject: [PATCH] ci: deploy example to sauce labs --- .buildkite/pipeline.yml | 13 +++++++ ...pload-example-application-to-sauce-labs.sh | 38 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 .buildkite/pipeline.yml create mode 100755 scripts/upload-example-application-to-sauce-labs.sh diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml new file mode 100644 index 0000000..f335f74 --- /dev/null +++ b/.buildkite/pipeline.yml @@ -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" diff --git a/scripts/upload-example-application-to-sauce-labs.sh b/scripts/upload-example-application-to-sauce-labs.sh new file mode 100755 index 0000000..0424f93 --- /dev/null +++ b/scripts/upload-example-application-to-sauce-labs.sh @@ -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