22project_arn=$DEVICEFARM_PROJECT_ARN
33max_devices=$NUMBER_OF_DEVICES_TO_TEST
44test_spec_arn=$DEVICEFARM_TEST_SPEC_ARN
5- module_path=$1
6- # Extract everything after the last "/" if it exists, otherwise use the full value
7- module_name=${1##*/ }
8-
5+ commit_sha=$COMMIT_SHA
6+ module_name=$1
97file_name=" $module_name -debug-androidTest.apk"
10- full_path=" $module_path /build/outputs/apk/androidTest/debug/$file_name "
118
129if [[ -z " ${project_arn} " ]]; then
1310 echo " DEVICEFARM_PROJECT_ARN environment variable not set."
@@ -38,15 +35,15 @@ read -a result <<< $(createUpload "INSTRUMENTATION_TEST_PACKAGE")
3835test_package_url=${result[0]}
3936test_package_upload_arn=${result[1]}
4037# Upload the apk
41- curl -H " Content-Type:application/octet-stream" -T $full_path $test_package_url
38+ curl -H " Content-Type:application/octet-stream" -T $file_name $test_package_url
4239
4340# Create an upload for the app package (They're the same, but they have to be setup in device farm)
4441echo ' Uploading app package'
4542read -a result <<< $( createUpload " ANDROID_APP" )
4643app_package_url=${result[0]}
4744app_package_upload_arn=${result[1]}
4845# Upload the apk
49- curl -H " Content-Type:application/octet-stream" -T $full_path $app_package_url
46+ curl -H " Content-Type:application/octet-stream" -T $file_name $app_package_url
5047
5148# Wait to make sure the upload completes. This should actually make a get-upload call and check the status.
5249echo " Waiting for uploads to complete"
9693# Function to cancel duplicate runs for same code source in device farm.
9794function stopDuplicates {
9895 echo " Stopping duplicate runs"
99- name=" $file_name -$CODEBUILD_SOURCE_VERSION "
96+ name=" $file_name -$commit_sha "
10097 read -a running_arns <<< $( aws devicefarm list-runs \
10198 --arn=" $project_arn " \
10299 --query=" runs[?(status == 'RUNNING' || status == 'PENDING') && name == '${name} '].arn" \
@@ -122,7 +119,7 @@ run_arn=`aws devicefarm schedule-run --project-arn=$project_arn \
122119 ],
123120 "maxDevices": ' $max_devices '
124121 }' \
125- --name=" $file_name -$CODEBUILD_SOURCE_VERSION " \
122+ --name=" $file_name -$commit_sha " \
126123 --test=" testSpecArn=$test_spec_arn ,type=INSTRUMENTATION,testPackageArn=$test_package_upload_arn " \
127124 --execution-configuration=" jobTimeoutMinutes=30,videoCapture=false" \
128125 --query=" run.arn" \
0 commit comments