111 lines
3.8 KiB
YAML
111 lines
3.8 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
|
|
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
|
|
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
|
|
uses: realm/aws-devicefarm/test-application@master
|
|
with:
|
|
name: MapLibre Native ${{ matrix.test.name }}
|
|
project_arn: ${{ inputs.AWS_DEVICE_FARM_PROJECT_ARN }}
|
|
device_pool_arn: ${{ inputs.AWS_DEVICE_FARM_DEVICE_POOL_ARN }}
|
|
app_arn: ${{ env.app_arn }}
|
|
app_type: ${{ inputs.appType }}
|
|
test_type: ${{ inputs.testType }}
|
|
test_package_arn: ${{ env.test_package_arn }}
|
|
timeout: 28800
|