UITest #9
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
name: UITest | |
on: | |
workflow_dispatch: | |
inputs: | |
runner: | |
required: true | |
default: 'debugmachine' | |
type: choice | |
options: | |
- 'debugmachine' | |
- 'macos-latest' | |
jobs: | |
build: | |
name: build ios application for ui tests | |
runs-on: ${{ github.event.inputs.runner || 'debugmachine' }} | |
timeout-minutes: 30 | |
steps: | |
- name: Print Env Variables | |
run: env | |
working-directory: ${{ github.workspace }} | |
- name: checkout source code of application | |
uses: actions/checkout@v4 | |
with: | |
clean: true | |
path: 'appodeal-ios-demo' | |
- name: instal ruby deps | |
working-directory: 'appodeal-ios-demo' | |
run: bundle install | |
- name: build ios app | |
working-directory: 'appodeal-ios-demo' | |
run: bundle exec fastlane ios build_app_for_uitests | |
- name: save debug build for aws | |
uses: actions/upload-artifact@v4 | |
with: | |
name: AppodealSwiftDemo | |
path: appodeal-ios-demo/appium/AppodealSwiftDemo.ipa | |
retention-days: 14 | |
tests: | |
name: run ui tests on aws with appium | |
needs: build | |
runs-on: ${{ github.event.inputs.runner || 'debugmachine' }} | |
timeout-minutes: 30 | |
steps: | |
- name: Print Env Variables | |
run: env | |
working-directory: ${{ github.workspace }} | |
- name: checkout source code of appium tests | |
uses: actions/checkout@v4 | |
with: | |
path: 'SDK-Auto-Test' | |
clean: true | |
repository: 'appodeal/SDK-Auto-Test' | |
ref: 'aws' | |
token: ${{ secrets.UITESTREPOACCESS }} | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
- name: download debug build | |
uses: actions/download-artifact@v4 | |
with: | |
name: AppodealSwiftDemo | |
path: ./SDK-Auto-Test/ipa | |
- name: prepare build | |
working-directory: ${{ github.workspace }}/SDK-Auto-Test | |
run: | | |
mvn clean | |
sleep 10 | |
mvn jar:jar | |
sleep 10 | |
mvn jar:test-jar | |
sleep 10 | |
mvn assembly:assembly -DskipTests -Ddescriptor=src/main/assembly/zip.xml | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
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: Upload IPA to AWS Device Farm | |
id: upload-ipa | |
run: | | |
APP_UPLOAD_RESPONSE=$(aws devicefarm create-upload --project-arn arn:aws:devicefarm:us-west-2:381491970378:project:4c28c1e5-8344-4d34-919c-a1e9377d3b2f --name AppodealSwiftDemo.ipa --type IOS_APP) | |
APP_ARN=$(echo $APP_UPLOAD_RESPONSE | jq -r .upload.arn) | |
echo "APP_ARN=$APP_ARN" >> $GITHUB_ENV | |
APP_URL=$(echo $APP_UPLOAD_RESPONSE | jq -r .upload.url) | |
curl -T ./SDK-Auto-Test/ipa/AppodealSwiftDemo.ipa "$APP_URL" | |
# Wait until the upload is processed | |
while [[ "$(aws devicefarm get-upload --arn $APP_ARN | jq -r '.upload.status')" != "SUCCEEDED" ]]; do | |
echo "Waiting for APK upload to complete..." | |
sleep 10 | |
done | |
- name: Upload Test Package to AWS Device Farm | |
id: upload-tests | |
run: | | |
TEST_PACKAGE_UPLOAD_RESPONSE=$(aws devicefarm create-upload --project-arn arn:aws:devicefarm:us-west-2:381491970378:project:4c28c1e5-8344-4d34-919c-a1e9377d3b2f --name zip-with-dependencies.zip --type APPIUM_JAVA_TESTNG_TEST_PACKAGE) | |
TEST_PACKAGE_ARN=$(echo $TEST_PACKAGE_UPLOAD_RESPONSE | jq -r .upload.arn) | |
echo "TEST_PACKAGE_ARN=$TEST_PACKAGE_ARN" >> $GITHUB_ENV | |
TEST_PACKAGE_URL=$(echo $TEST_PACKAGE_UPLOAD_RESPONSE | jq -r .upload.url) | |
curl -T ./SDK-Auto-Test/target/zip-with-dependencies.zip $TEST_PACKAGE_URL | |
# Wait until the upload is processed | |
while [[ "$(aws devicefarm get-upload --arn $TEST_PACKAGE_ARN | jq -r '.upload.status')" != "SUCCEEDED" ]]; do | |
echo "Waiting for Test Package upload to complete..." | |
sleep 10 | |
done | |
- name: Schedule Device Farm Automated Test | |
id: run-test | |
uses: aws-actions/[email protected] | |
with: | |
run-settings-json: | | |
{ | |
"name": "GitHubAction-${{ github.workflow }}_${{ github.run_id }}_${{ github.run_attempt }}", | |
"projectArn": "arn:aws:devicefarm:us-west-2:381491970378:project:4c28c1e5-8344-4d34-919c-a1e9377d3b2f", | |
"appArn": "${{ env.APP_ARN }}", | |
"devicePoolArn": "arn:aws:devicefarm:us-west-2:381491970378:devicepool:4c28c1e5-8344-4d34-919c-a1e9377d3b2f/fab38d5b-3c14-4a91-a3a2-9edbe0ea18a9", | |
"test": { | |
"type": "APPIUM_JAVA_TESTNG", | |
"testPackageArn": "${{ env.TEST_PACKAGE_ARN }}", | |
"testSpecArn": "default.yml" | |
} | |
} | |
artifact-types: ALL | |
# | |
# - uses: actions/upload-artifact@v4 | |
# if: always() | |
# with: | |
# name: AutomatedTestOutputFiles | |
# path: ${{ steps.run-test.outputs.artifact-folder }} | |
# | |
# - name: Adding summary | |
# if: ${{ always() }} | |
# run: | | |
# echo "### Results of test execution :fire:" >> $GITHUB_STEP_SUMMARY | |
# echo "Launch: ${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY | |
# echo "Device: ${{ github.event.inputs.device }}" >> $GITHUB_STEP_SUMMARY | |
# echo "Build agent: ${{ github.event.inputs.runner }}" >> $GITHUB_STEP_SUMMARY | |
# | |
## - name: Download allure-notifications.jar | |
## if: ${{ always() }} | |
## run: | | |
## curl -fSL https://github.com/qa-guru/allure-notifications/releases/download/4.7.0/allure-notifications-4.7.0.jar -o allure-notifications/allure-notifications.jar | |
## chmod +x allure-notifications/allure-notifications.jar | |
## | |
## - name: Send reports to slack | |
## if: ${{ always() }} | |
## run: java "-DconfigFile=allure_notifications/config.json" -jar allure-notifications/allure-notifications.jar |