Skip to content

Commit 04209f9

Browse files
authored
chore: Modularize Integration Test Runs (#3073)
1 parent 6b78fef commit 04209f9

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

scripts/run_test_in_devicefarm.sh

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
project_arn=$DEVICEFARM_PROJECT_ARN
33
max_devices=$NUMBER_OF_DEVICES_TO_TEST
44
test_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
97
file_name="$module_name-debug-androidTest.apk"
10-
full_path="$module_path/build/outputs/apk/androidTest/debug/$file_name"
118

129
if [[ -z "${project_arn}" ]]; then
1310
echo "DEVICEFARM_PROJECT_ARN environment variable not set."
@@ -38,15 +35,15 @@ read -a result <<< $(createUpload "INSTRUMENTATION_TEST_PACKAGE")
3835
test_package_url=${result[0]}
3936
test_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)
4441
echo 'Uploading app package'
4542
read -a result <<< $(createUpload "ANDROID_APP")
4643
app_package_url=${result[0]}
4744
app_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.
5249
echo "Waiting for uploads to complete"
@@ -96,7 +93,7 @@ fi
9693
# Function to cancel duplicate runs for same code source in device farm.
9794
function 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

Comments
 (0)