134 lines
4.9 KiB
YAML
134 lines
4.9 KiB
YAML
name: 'aws-device-farm-run'
|
|
description: 'Run device test on AWS Device Farm'
|
|
inputs:
|
|
name:
|
|
description: 'Name of the test'
|
|
required: true
|
|
appType:
|
|
description: 'Type of upload for app'
|
|
required: true
|
|
appFile:
|
|
description: 'Application file to be uploaded'
|
|
required: false
|
|
testFile:
|
|
description: 'Application file to be uploaded'
|
|
required: false
|
|
testPackageType:
|
|
description: 'e.g. INSTRUMENTATION_TEST_PACKAGE, XCTEST_TEST_PACKAGE'
|
|
required: true
|
|
testType:
|
|
description: 'e.g. INSTRUMENTATION, XCTEST'
|
|
required: true
|
|
testFilter:
|
|
description: 'Filter tests'
|
|
required: false
|
|
externalData:
|
|
description: 'ARN of external data package'
|
|
required: false
|
|
AWS_ACCESS_KEY_ID:
|
|
description: "AWS_ACCESS_KEY_ID"
|
|
required: true
|
|
AWS_SECRET_ACCESS_KEY:
|
|
description: "AWS_SECRET_ACCESS_KEY"
|
|
required: true
|
|
AWS_ROLE_TO_ASSUME:
|
|
description: "AWS_ROLE_TO_ASSUME"
|
|
required: true
|
|
AWS_DEVICE_FARM_PROJECT_ARN:
|
|
description: "AWS_DEVICE_FARM_PROJECT_ARN"
|
|
required: true
|
|
AWS_DEVICE_FARM_DEVICE_POOL_ARN:
|
|
description: "AWS_DEVICE_FARM_DEVICE_POOL_ARN"
|
|
required: true
|
|
testSpecArn:
|
|
description: "ARN of test spec"
|
|
required: false
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Configure AWS Credentials
|
|
uses: aws-actions/configure-aws-credentials@v3
|
|
with:
|
|
aws-access-key-id: ${{ inputs.AWS_ACCESS_KEY_ID }}
|
|
aws-secret-access-key: ${{ inputs.AWS_SECRET_ACCESS_KEY }}
|
|
aws-region: us-west-2
|
|
role-to-assume: ${{ inputs.AWS_ROLE_TO_ASSUME }}
|
|
role-duration-seconds: 3600
|
|
role-session-name: MySessionName
|
|
|
|
- name: Create upload app
|
|
shell: bash
|
|
run: |
|
|
response=$(aws devicefarm create-upload --type ${{ inputs.appType }} --name ${{ inputs.appFile }} --project-arn ${{ inputs.AWS_DEVICE_FARM_PROJECT_ARN }})
|
|
echo "$response"
|
|
arn="$(jq -r '.upload.arn' <<< "$response")"
|
|
url="$(jq -r '.upload.url' <<< "$response")"
|
|
echo "app_arn=$arn" >> "$GITHUB_ENV"
|
|
echo "app_url=$url" >> "$GITHUB_ENV"
|
|
|
|
- name: Create upload test package
|
|
shell: bash
|
|
run: |
|
|
response=$(aws devicefarm create-upload --type ${{ inputs.testPackageType }} --name ${{ inputs.testFile }} --project-arn ${{ inputs.AWS_DEVICE_FARM_PROJECT_ARN }})
|
|
echo "$response"
|
|
arn="$(jq -r '.upload.arn' <<< "$response")"
|
|
url="$(jq -r '.upload.url' <<< "$response")"
|
|
echo "test_package_arn=$arn" >> "$GITHUB_ENV"
|
|
echo "test_package_url=$url" >> "$GITHUB_ENV"
|
|
|
|
- name: Upload ${{ inputs.appFile }}, ${{ inputs.testFile }}
|
|
shell: bash
|
|
run: |
|
|
curl -T ${{ inputs.appFile }} "${{ env.app_url }}"
|
|
curl -T ${{ inputs.testFile }} "${{ env.test_package_url }}"
|
|
|
|
max_checks=10
|
|
sleep_time=5
|
|
|
|
check_status() {
|
|
aws devicefarm get-upload --arn "$1" | jq -r '.upload.status'
|
|
}
|
|
|
|
while ((max_checks--)); do
|
|
status_app="$(check_status "${{ env.app_arn }}")"
|
|
status_test_package="$(check_status "${{ env.test_package_arn }}")"
|
|
|
|
echo status_app="$status_app"
|
|
echo status_test_package="$status_test_package"
|
|
|
|
if [[ "$status_app" == "SUCCEEDED" && "$status_test_package" == "SUCCEEDED" ]]; then
|
|
exit 0
|
|
elif ((max_checks == 0)); then
|
|
echo "App or test package failed to upload"
|
|
exit 1
|
|
fi
|
|
|
|
sleep $sleep_time
|
|
done
|
|
|
|
- name: Schedule test run
|
|
shell: bash
|
|
run: |
|
|
arn="$(aws devicefarm schedule-run \
|
|
--project-arn ${{ inputs.AWS_DEVICE_FARM_PROJECT_ARN }} \
|
|
--name "MapLibre Native ${{ matrix.test.name }}" \
|
|
--app-arn ${{ env.app_arn }} \
|
|
--device-pool-arn ${{ inputs.AWS_DEVICE_FARM_DEVICE_POOL_ARN }} \
|
|
--test type=${{ inputs.testType }},testPackageArn=${{ env.test_package_arn }}${{ inputs.testFilter && ',filter=' }}${{ inputs.testFilter }}${{ inputs.testSpecArn && ',testSpecArn=' }}${{ inputs.testSpecArn }} \
|
|
${{ inputs.externalData && '--configuration extraDataPackageArn=' }}${{ inputs.externalData }} \
|
|
--output text --query "run.arn")"
|
|
|
|
# wait until result is not PENDING
|
|
# https://awscli.amazonaws.com/v2/documentation/api/latest/reference/devicefarm/get-run.html#output
|
|
while true; do
|
|
sleep 30
|
|
result="$(aws devicefarm get-run --arn "$arn" --output text --query "run.result")"
|
|
case $result in
|
|
FAILED|ERRORED|STOPPED) echo "Run $result" && exit 1 ;;
|
|
SKIPPED|PASSED) echo "Run $result" && exit 0 ;;
|
|
PENDING) continue ;;
|
|
*) echo "Unexpected run result $result" && exit 1 ;;
|
|
esac
|
|
done
|
|
|