Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions scripts/run_test_in_devicefarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
project_arn=$DEVICEFARM_PROJECT_ARN
max_devices=$NUMBER_OF_DEVICES_TO_TEST
test_spec_arn=$DEVICEFARM_TEST_SPEC_ARN
module_path=$1
# Extract everything after the last "/" if it exists, otherwise use the full value
module_name=${1##*/}

commit_sha=$COMMIT_SHA
module_name=$1
file_name="$module_name-debug-androidTest.apk"
full_path="$module_path/build/outputs/apk/androidTest/debug/$file_name"

if [[ -z "${project_arn}" ]]; then
echo "DEVICEFARM_PROJECT_ARN environment variable not set."
Expand Down Expand Up @@ -38,15 +35,15 @@ read -a result <<< $(createUpload "INSTRUMENTATION_TEST_PACKAGE")
test_package_url=${result[0]}
test_package_upload_arn=${result[1]}
# Upload the apk
curl -H "Content-Type:application/octet-stream" -T $full_path $test_package_url
curl -H "Content-Type:application/octet-stream" -T $file_name $test_package_url

# Create an upload for the app package (They're the same, but they have to be setup in device farm)
echo 'Uploading app package'
read -a result <<< $(createUpload "ANDROID_APP")
app_package_url=${result[0]}
app_package_upload_arn=${result[1]}
# Upload the apk
curl -H "Content-Type:application/octet-stream" -T $full_path $app_package_url
curl -H "Content-Type:application/octet-stream" -T $file_name $app_package_url

# Wait to make sure the upload completes. This should actually make a get-upload call and check the status.
echo "Waiting for uploads to complete"
Expand Down Expand Up @@ -96,7 +93,7 @@ fi
# Function to cancel duplicate runs for same code source in device farm.
function stopDuplicates {
echo "Stopping duplicate runs"
name="$file_name-$CODEBUILD_SOURCE_VERSION"
name="$file_name-$commit_sha"
read -a running_arns <<< $(aws devicefarm list-runs \
--arn="$project_arn" \
--query="runs[?(status == 'RUNNING' || status == 'PENDING') && name == '${name}'].arn" \
Expand All @@ -122,7 +119,7 @@ run_arn=`aws devicefarm schedule-run --project-arn=$project_arn \
],
"maxDevices": '$max_devices'
}' \
--name="$file_name-$CODEBUILD_SOURCE_VERSION" \
--name="$file_name-$commit_sha" \
--test="testSpecArn=$test_spec_arn,type=INSTRUMENTATION,testPackageArn=$test_package_upload_arn" \
--execution-configuration="jobTimeoutMinutes=30,videoCapture=false" \
--query="run.arn" \
Expand Down