Adding ability to install auxiliary apps #58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
release: | |
types: [created] | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
env: | |
python2_bundle_url: https://github.com/aardsoft/aws-devicefarm-sample-data/releases/download/0.3/sample_env_python2_wh.zip | |
python3_bundle_url: https://github.com/aardsoft/aws-devicefarm-sample-data/releases/download/0.3/sample_env_python3.zip | |
test_spec_url: https://github.com/aardsoft/aws-devicefarm-sample-data/releases/download/0.3/test_spec.yaml | |
test_app_url: https://github.com/aardsoft/aws-devicefarm-sample-data/releases/download/0.3/fi.aardsoft.devicefarmsample-debug.apk | |
name: Perform basic testing against a devicefarm | |
jobs: | |
package: | |
name: Package | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Install dependencies | |
run: npm ci | |
- name: Run package | |
run: npm run package | |
- name: Validate there are no uncommitted changes | |
run: | | |
changedFiles=$(git --no-pager diff -w) | |
if [ "$changedFiles" ]; then | |
git --no-pager diff -w | |
exit 1 | |
fi | |
shell: bash | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
environment: production | |
needs: | |
- package | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install additional packages | |
run: | | |
if [ `id -u` -eq 0 ]; then | |
apt-get update | |
apt-get install -y zip unzip | |
else | |
sudo apt-get update | |
sudo apt-get install -y zip unzip | |
fi | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-west-2 | |
- name: Get project | |
uses: ./get-project | |
id: get-project | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
- name: List device pools | |
uses: ./list-device-pools | |
id: list-device-pools | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
- name: Get device pool details | |
uses: ./get-device-pool | |
id: get-device-pool | |
with: | |
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }} | |
- name: List uploads | |
uses: ./list-uploads | |
id: list-uploads | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
# this fails with too many artifacts due to missing cleanup handlers. Only | |
# nice to have anyway, so ignore errors. | |
- name: Print uploads | |
continue-on-error: true | |
uses: ./pretty-print | |
with: | |
input: ${{ steps.list-uploads.outputs.data }} | |
- name: Create upload | |
uses: ./create-upload | |
id: create-upload-1 | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
name: test-via-action.yaml | |
type: APPIUM_PYTHON_TEST_SPEC | |
- name: Get upload details | |
uses: ./get-upload | |
id: get-upload | |
with: | |
resource_arn: ${{ steps.create-upload-1.outputs.arn }} | |
- name: Create upload 2 | |
uses: ./create-upload | |
id: create-upload-2 | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
name: test-via-action.yaml | |
type: APPIUM_PYTHON_TEST_SPEC | |
- name: Delete previously created upload | |
uses: ./delete-upload | |
with: | |
resource_arn: ${{ steps.create-upload-1.outputs.arn }} | |
- name: Delete previously created upload | |
uses: ./delete-upload | |
with: | |
resource_arn: ${{ steps.create-upload-2.outputs.arn }} | |
- name: Upload remote test specification | |
uses: ./upload-file | |
id: test-spec | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
file: ${{ env.test_spec_url }} | |
remote_src: true | |
type: APPIUM_PYTHON_TEST_SPEC | |
- name: Upload remote test bundle | |
uses: ./upload-file | |
id: test-bundle | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
file: ${{ env.python3_bundle_url }} | |
remote_src: true | |
type: APPIUM_PYTHON_TEST_PACKAGE | |
- name: Upload remote app | |
uses: ./upload-file | |
id: test-app | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
file: ${{ env.test_app_url }} | |
remote_src: true | |
type: ANDROID_APP | |
- name: Create incomplete upload | |
uses: ./create-upload | |
id: incomplete-upload | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
name: incomplete-app.apk | |
type: ANDROID_APP | |
# TODO: this should fail - check if we can abort if it passes | |
- name: Schedule test run with incomplete data | |
uses: ./test-application | |
continue-on-error: true | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }} | |
app_arn: ${{ steps.incomplete-upload.outputs.arn }} | |
test_type: APPIUM_PYTHON | |
test_package_file: ${{ env.python3_bundle_url }} | |
test_package_type: APPIUM_PYTHON_TEST_PACKAGE | |
test_spec_file: ${{ env.test_spec_url }} | |
test_spec_type: APPIUM_PYTHON_TEST_SPEC | |
remote_src: true | |
# this also is expected to fail due to AWS still defaulting to python2.7, | |
# while the test package requires python3 | |
- name: Schedule test run without custom test spec | |
uses: ./test-application | |
continue-on-error: true | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }} | |
app_arn: ${{ steps.test-app.outputs.arn }} | |
test_type: APPIUM_PYTHON | |
test_package_file: ${{ env.python3_bundle_url }} | |
test_package_type: APPIUM_PYTHON_TEST_PACKAGE | |
remote_src: true | |
# this requires a bundle with wheelhouse. It fails without getting real | |
# appium tests. | |
- name: Schedule python2 test run without custom test spec | |
continue-on-error: true | |
uses: ./test-application | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }} | |
app_arn: ${{ steps.test-app.outputs.arn }} | |
test_type: APPIUM_PYTHON | |
test_package_file: ${{ env.python_2_bundle_url }} | |
test_package_type: APPIUM_PYTHON_TEST_PACKAGE | |
remote_src: true | |
# this should fail due to the short timeout | |
- name: Schedule test run for previous uploads, short timeout | |
uses: ./test-application | |
continue-on-error: true | |
id: schedule-run-timeout | |
with: | |
name: run_with_uploaded_files_and_timeout | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }} | |
app_arn: ${{ steps.test-app.outputs.arn }} | |
test_type: APPIUM_PYTHON | |
test_package_arn: ${{ steps.test-bundle.outputs.arn }} | |
test_spec_arn: ${{ steps.test-spec.outputs.arn }} | |
timeout: 30 | |
- name: Schedule test run with inline test spec | |
uses: ./test-application | |
with: | |
name: inline-spec | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }} | |
app_arn: ${{ steps.test-app.outputs.arn }} | |
test_type: APPIUM_PYTHON | |
test_package_file: ${{ env.python3_bundle_url }} | |
test_package_type: APPIUM_PYTHON_TEST_PACKAGE | |
test_spec_file: inline_test_spec.yaml | |
test_spec_type: APPIUM_PYTHON_TEST_SPEC | |
test_spec: | | |
version: 0.1 | |
phases: | |
install: | |
commands: | |
- export PYTHON_VERSION=3 | |
pre_test: | |
commands: | |
- adb -s $DEVICEFARM_DEVICE_UDID shell pm grant fi.aardsoft.devicefarmsample android.permission.READ_EXTERNAL_STORAGE | |
- adb -s $DEVICEFARM_DEVICE_UDID shell pm grant fi.aardsoft.devicefarmsample android.permission.WRITE_EXTERNAL_STORAGE | |
test: | |
commands: | |
- adb -s $DEVICEFARM_DEVICE_UDID shell am instrument -w -r -e foo bar -e bar baz fi.aardsoft.devicefarmsample | |
post_test: | |
commands: | |
- adb -s $DEVICEFARM_DEVICE_UDID pull /storage/emulated/0/Android/data/fi.aardsoft.devicefarmsample/files/output.txt | |
- mv output.txt $DEVICEFARM_LOG_DIR/test-output.txt | |
artifacts: | |
- $DEVICEFARM_LOG_DIR | |
remote_src: false | |
- name: Schedule test run via API (non-blocking) | |
uses: ./schedule-run | |
with: | |
name: schedule_run | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }} | |
app_arn: ${{ steps.test-app.outputs.arn }} | |
test_type: APPIUM_PYTHON | |
test_package_arn: ${{ steps.test-bundle.outputs.arn }} | |
test_spec_arn: ${{ steps.test-spec.outputs.arn }} | |
- name: Schedule test run for previous uploads | |
uses: ./test-application | |
id: schedule-run | |
with: | |
name: run_with_uploaded_files | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }} | |
app_arn: ${{ steps.test-app.outputs.arn }} | |
test_type: APPIUM_PYTHON | |
test_package_arn: ${{ steps.test-bundle.outputs.arn }} | |
test_spec_arn: ${{ steps.test-spec.outputs.arn }} | |
- name: List runs | |
uses: ./list-runs | |
with: | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
- name: Get run details | |
uses: ./get-run | |
with: | |
run_arn: ${{ steps.schedule-run.outputs.arn }} | |
- name: List file artifacts for run | |
uses: ./list-artifacts | |
with: | |
resource_arn: ${{ steps.schedule-run.outputs.arn }} | |
type: FILE | |
- name: Download artifacts for run | |
uses: ./download-artifacts | |
with: | |
run_arn: ${{ steps.schedule-run.outputs.arn }} | |
file_artifacts: | | |
Test spec file.yml | |
Invalid Artifact Logging Warning.txt | |
Customer Artifacts.zip | |
- name: Print and clean downloaded artifacts | |
run: | | |
cat 'Test spec file.yml' | |
unzip -l 'Customer Artifacts.zip' | |
rm -f 'Test spec file.yml' 'Customer Artifacts.zip' | |
- name: Schedule test run with uploads | |
uses: ./test-application | |
with: | |
name: run_with_uploads | |
project_arn: ${{ secrets.AWS_PROJECT_ARN }} | |
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }} | |
app_file: ${{ env.test_app_url }} | |
app_type: ANDROID_APP | |
test_type: APPIUM_PYTHON | |
test_package_file: ${{ env.python3_bundle_url }} | |
test_package_type: APPIUM_PYTHON_TEST_PACKAGE | |
test_spec_file: ${{ env.test_spec_url }} | |
test_spec_type: APPIUM_PYTHON_TEST_SPEC | |
remote_src: true | |
file_artifacts: | | |
Test spec file.yml | |
Invalid Artifact Logging Warning.txt | |
Customer Artifacts.zip | |
- name: Print and clean downloaded artifacts | |
run: | | |
cat 'Test spec file.yml' | |
unzip -l 'Customer Artifacts.zip' | |
rm -f 'Test spec file.yml' 'Customer Artifacts.zip' |