Skip to content

Commit

Permalink
add script for uploading app to LambdaTest
Browse files Browse the repository at this point in the history
Signed-off-by: Filipe-Santos <[email protected]>
  • Loading branch information
fc-santos committed May 12, 2023
1 parent 4734397 commit 2e03af7
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Upload an app to SauceLabs
Upload an app to LambdaTest

```bash
./upload_app_to_LT.sh <device_cloud_username> <device_cloud_access_key> /<full path to app>/apps/bifold-bc/app-release.apk
./upload_app_to_LT.sh <device_cloud_username> <device_cloud_access_key> /<full path to app>/apps/bifold-bc/app-release.apk "Android Bifold BC App"
```

Build and run the tests
Expand Down
119 changes: 119 additions & 0 deletions upload_app_to_LT.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/bash
#
# This is a positional arguments-only example of Argbash potential
#
# ARG_HELP([This script uploads an Android apk or iOS ipa to LambdaTest given the User Name and Access Token passed])
# ARG_POSITIONAL_SINGLE([lt_user_name],[LambdaTest User Name])
# ARG_POSITIONAL_SINGLE([lt_access_token],[LambdaTest Access Token])
# ARG_POSITIONAL_SINGLE([app_location],[Name and Location of the App apk or iOS ipa])
# ARG_POSITIONAL_SINGLE([app_name], [Name of the App])
# ARGBASH_GO()
# needed because of Argbash --> m4_ignore([
### START OF CODE GENERATED BY Argbash v2.9.0 one line above ###
# Argbash is a bash code generator used to get arguments parsing right.
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
# Generated online by https://argbash.io/generate


die()
{
local _ret="${2:-1}"
test "${_PRINT_HELP:-no}" = yes && print_help >&2
echo "$1" >&2
exit "${_ret}"
}


begins_with_short_option()
{
local first_option all_short_options='h'
first_option="${1:0:1}"
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
}

# THE DEFAULTS INITIALIZATION - POSITIONALS
_positionals=()
# THE DEFAULTS INITIALIZATION - OPTIONALS


print_help()
{
printf '%s\n' "This script uploads an Android apk or iOS ipa to LambdaTest given the User Name and Access Token passed"
printf 'Usage: %s [-h|--help] <lt_user_name> <lt_access_token> <app_location>\n' "$0"
printf '\t%s\n' "<lt_user_name>: LambdaTest User Name"
printf '\t%s\n' "<lt_access_token>: LambdaTest Access Token"
printf '\t%s\n' "<app_location>: Location of the App apk or iOS ipa"
printf '\t%s\n' "<app_name>: Name of the app"
printf '\t%s\n' "-h, --help: Prints help"
}


parse_commandline()
{
_positionals_count=0
while test $# -gt 0
do
_key="$1"
case "$_key" in
-h|--help)
print_help
exit 0
;;
-h*)
print_help
exit 0
;;
*)
_last_positional="$1"
_positionals+=("$_last_positional")
_positionals_count=$((_positionals_count + 1))
;;
esac
shift
done
}


handle_passed_args_count()
{
local _required_args_string="'lt_user_name', 'lt_access_token', 'app_location' and 'app_name'"
test "${_positionals_count}" -ge 4 || _PRINT_HELP=yes die "FATAL ERROR: Not enough positional arguments - we require exactly 4 (namely: $_required_args_string), but got only ${_positionals_count}." 1
test "${_positionals_count}" -le 4 || _PRINT_HELP=yes die "FATAL ERROR: There were spurious positional arguments --- we expect exactly 4 (namely: $_required_args_string), but got ${_positionals_count} (the last one was: '${_last_positional}')." 1
}


assign_positional_args()
{
local _positional_name _shift_for=$1
_positional_names="_arg_lt_user_name _arg_lt_access_token _arg_app_location _arg_app_name"

shift "$_shift_for"
for _positional_name in ${_positional_names}
do
test $# -gt 0 || break
eval "$_positional_name=\${1}" || die "Error during argument parsing, possibly an Argbash bug." 1
shift
done
}

parse_commandline "$@"
handle_passed_args_count
assign_positional_args 1 "${_positionals[@]}"

# OTHER STUFF GENERATED BY Argbash

### END OF CODE GENERATED BY Argbash (sortof) ### ])
# [ <-- needed because of Argbash


echo "Value of first argument: $_arg_lt_user_name"
echo "Value of second argument: $_arg_lt_access_token"
echo "Value of third argument: $_arg_app_location"
echo "Value of fourth argument: $_arg_app_name"

echo "------------------UPLOADING-APP-TO-LAMBDATEST------------------"

curl -u "$_arg_lt_user_name:$_arg_lt_access_token" \
--request POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
--form "appFile=@$_arg_app_location" \
--form "name=$_arg_app_name" \

0 comments on commit 2e03af7

Please sign in to comment.