Skip to content

Commit

Permalink
-added steps for aws actions
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlitvinov committed Aug 12, 2024
1 parent b3c66c8 commit 0973fbf
Showing 1 changed file with 122 additions and 82 deletions.
204 changes: 122 additions & 82 deletions .github/workflows/uitests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,93 +24,133 @@ jobs:
runs-on: ${{ github.event.inputs.runner || 'autotestdebug' }}
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-android-sdk'

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
# settings-path: ${{ github.workspace }} # location for the settings.xml file
# - name: Setup Gradle
# uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2

# - name: Gradle clean cache
# uses: burrunan/gradle-cache-action@v1
# with:
# job-id: jdk17
# arguments: build
# gradle-version: wrapper
# properties: |
# kotlin.js.compiler=ir
# kotlin.parallel.tasks.in.project=true

- name: Build with Gradle
working-directory: ${{ github.workspace }}/appodeal-android-sdk
run: ./gradlew :banner:assembleDebug

- name: save debug build for aws
uses: actions/upload-artifact@v4
with:
name: banner-debug.apk
path: appodeal-android-sdk/banner/build/outputs/apk/debug/banner-debug.apk
retention-days: 14
- 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-android-sdk'

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Build with Gradle
working-directory: ${{ github.workspace }}/appodeal-android-sdk
run: ./gradlew :banner:assembleDebug

- name: save debug build for aws
uses: actions/upload-artifact@v4
with:
name: banner-debug.apk
path: appodeal-android-sdk/banner/build/outputs/apk/debug/banner-debug.apk
retention-days: 14

tests:
name: run ui tests on aws with appium
needs: build
runs-on: ${{ github.event.inputs.runner || 'autotestdebug' }}
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:
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: banner-debug.apk
path: ./SDK-Auto-Test/apk

- 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@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: Print Env Variables
run: env
working-directory: ${{ github.workspace }}

- name: checkout source code of application
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: banner-debug.apk
path: ./SDK-Auto-Test/apk

- 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@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: Upload APK to AWS Device Farm
id: upload-apk
run: |
apk_url=$(aws devicefarm create-upload \
--project-arn ${{ secrets.AWS_PROJECT_ARN }} \
--name banner-debug.apk \
--type ANDROID_APP \
--region us-west-2 \
--query 'upload.url' \
--output text)
curl -T ./SDK-Auto-Test/apk/banner-debug.apk "$apk_url"
- name: Upload Test ZIP to AWS Device Farm
id: upload-test-zip
run: |
zip_url=$(aws devicefarm create-upload \
--project-arn ${{ secrets.AWS_PROJECT_ARN }} \
--name test-dependencies.zip \
--type APPIUM_NODE_TEST_PACKAGE \
--region us-west-2 \
--query 'upload.url' \
--output text)
curl -T ./SDK-Auto-Test/target/zip-with-dependencies.zip "$zip_url"
- name: Schedule Test Run
id: schedule-run
run: |
run_arn=$(aws devicefarm schedule-run \
--project-arn ${{ secrets.AWS_PROJECT_ARN }} \
--app-arn $(aws devicefarm list-uploads --project-arn ${{ secrets.AWS_PROJECT_ARN }} --type ANDROID_APP --query 'uploads[?name==`banner-debug.apk`].arn' --output text) \
--device-pool-arn ${{ secrets.AWS_DEVICE_POOL_ARN }} \
--name "UI Test Run" \
--test '{"type":"APPIUM_NODE","testPackageArn":"$(aws devicefarm list-uploads --project-arn ${{ secrets.AWS_PROJECT_ARN }} --type APPIUM_NODE_TEST_PACKAGE --query 'uploads[?name==`test-dependencies.zip`].arn' --output text)"}' \
--region us-west-2 \
--query 'run.arn' \
--output text)
echo "RUN_ARN=$run_arn" >> $GITHUB_ENV
- name: Wait for Test Run to Complete
run: |
aws devicefarm get-run \
--arn $RUN_ARN \
--region us-west-2 \
--query 'run.status' \
--output text
- name: Download Test Results
run: |
aws devicefarm list-artifacts \
--arn $RUN_ARN \
--type FILE \
--region us-west-2 \
--query 'artifacts[*].[type,url]' \
--output text

0 comments on commit 0973fbf

Please sign in to comment.