Skip to content

Commit

Permalink
Develop (#41)
Browse files Browse the repository at this point in the history
### To be filled by the PR creator:

* A brief description of the changes made - 

* Do we have clean latest run report attached with this PR?
  * [ ] Yes
  * [ ] No (Please explain why)

* Does the PR contain changes to any BP core file?
  * [ ] Yes (Needs approval from at least 2 people)
  * [ ] No

* Does the PR contain changes to modules shared with other teams?
* [ ] Yes (Needs approval from at least one of the other teams that use
the module)
  * [ ] No

* Is it
  * [ ] New Testcase
  * [ ] Fix


### To be filled by the PR reviewer:

* [ ] Verify the attached run report passed in GitHub Actions (Justify
if local run)

* General
    * [ ] Use the best strategy to locate the elements
    * [ ] Comments wherever the code is not readable by itself
    * [ ] Use of the right data structure for the use case
    * [ ] Reuse logic/functionality as much as possible
    * [ ] Cleanup of any test data that is generated by the tests
    * [ ] No static waits
  • Loading branch information
Tauqir Sarwar authored Mar 19, 2024
2 parents 0d4a07e + a18a9bc commit 53a427a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 67 deletions.
144 changes: 78 additions & 66 deletions .github/workflows/docker_android_workflow.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Docker Android Tests Workflow

env:
TAGS: "ios_mobile_test"
TAGS: "android_mobile_tests"
USING_DOCKER: 'True'

on:
Expand All @@ -12,52 +12,86 @@ on:
tags:
description: Gherkin Tags
required: true
default: android_mobile_test
default: android_mobile_tests

jobs:
scheduled-regression:
if: github.event_name == 'schedule'
strategy:
max-parallel: 1
fail-fast: false
matrix:
include:
- name: Android Mobile
tags: 'android_mobile_tests'
config_file: ./configs/android_mobile_BS.json
html_report: android-mobile
testrail_configuration_name: 'Samsung Galaxy S23 Ultra'

name: ${{ matrix.name }} - Regression
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Validate Input Parameter
id: validate_input
run: |
if [[ -z "${{ github.event.inputs.tags }}" ]]; then
echo "Invalid input: 'tags' is required but not provided."
exit 1
fi
- name: Setup Python
id: setup_python
if: steps.validate_input.outcome == 'success'
uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Check out code
id: co_code
if: steps.setup_python.outcome == 'success'
uses: actions/checkout@v4

- name: Set up JDK 21
id: setup_java
if: steps.co_code.outcome == 'success'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21

- name: Install and Run Appium Server
id: setup_appium
if: steps.setup_java.outcome == 'success'
run: |
npm install -g appium
appium --log-level info &
sleep 5
appium -v
- name: Run Emulator
id: run_emulator
uses: ReactiveCircus/android-emulator-runner@v2
with:
api-level: 30
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -grpc-use-jwt -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
target: default
arch: x86_64
script: echo "Generated AVD"

- name: Setup dependencies
id: setup_dependencies
if: steps.run_emulator.outcome == 'success'
run: |
sh install.sh
- name: Run All Tests
- name: Run Tests
id: run_manual_job
if: steps.setup_dependencies.outcome == 'success'
run: |
TAGS="${{ github.event.inputs.tags }}"
env
source $HOME/.bp-venv/bin/activate
python -m pytest -v --driver Appium --selenium-host '${{secrets.BROWSERSTACK_API_USERNAME}}:${{secrets.BROWSERSTACK_ACCESS_KEY}}@hub-cloud.browserstack.com' \
--variables ${{ matrix.config_file }} --tags="${{ matrix.tags }}" \
--html=report.html \
--self-contained-html \
source $HOME/.bp-venv/bin/activate
python -m pytest -v --driver Appium --selenium-host 'localhost' --selenium-port '4723' \
--variables './configs/android_mobile_docker.json'
--tags="$TAGS" \
--html=report.html \
--self-contained-html \
- name: Upload HTML run report in the Artifacts Folder
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.html_report }}
name: pytest-results
path: |
./*.html
./output/
Expand All @@ -67,7 +101,7 @@ jobs:
docker-manual-android-run:
if: github.event_name != 'schedule'
name: Manual - ${{ inputs.tags }}
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Validate Input Parameter
id: validate_input
Expand All @@ -89,66 +123,44 @@ jobs:
if: steps.setup_python.outcome == 'success'
uses: actions/checkout@v4

- name: Set up JDK 21
id: setup_java
if: steps.co_code.outcome == 'success'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21

- name: Install and Run Appium Server
id: setup_appium
if: steps.co_code.outcome == 'success'
if: steps.setup_java.outcome == 'success'
run: |
npm install -g appium
appium --log-level info &
sleep 5
appium -v
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: start emulator
id: start_emulator
uses: reactivecircus/android-emulator-runner@v2
- name: Run Emulator
id: run_emulator
uses: ReactiveCircus/android-emulator-runner@v2
with:
api-level: 29
api-level: 30
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
emulator-options: -no-snapshot-save -no-window -grpc-use-jwt -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
target: default
arch: x86_64
script: echo "Generated AVD"

- name: Setup dependencies
id: setup_dependencies
if: steps.co_code.outcome == 'success'
if: steps.run_emulator.outcome == 'success'
run: |
sh install.sh
- name: Setup Java
id: setup_java
if: steps.co_code.outcome == 'success'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Run Env Job Tests
- name: Run Tests
id: run_manual_job
if: steps.start_emulator.outcome == 'success'
if: steps.setup_dependencies.outcome == 'success'
run: |
TAGS="${{ github.event.inputs.tags }}"
env
Expand Down
5 changes: 5 additions & 0 deletions android_local_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

# Run API tests
python -m pytest -v -s --disable-warnings --gherkin-terminal-reporter --driver=Appium --html="./output/reports/" --self-contained-html \
--variables="configs/android_mobile_docker.json" --reruns 1 --reruns-delay 2 --tags="android_mobile_tests"
2 changes: 1 addition & 1 deletion configs/android_mobile_docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"capabilities": {
"browserstack": "False",
"deviceName": "emulator-5554",
"platformName": "Android",
"platformName": "android",
"app": "app files/builds/Android-MyDemoAppRN.1.3.0.build-244.apk",
"noReset": false,
"newCommandTimeout": 3600
Expand Down

0 comments on commit 53a427a

Please sign in to comment.