diff --git a/.github/workflows/docker_android_workflow.yml b/.github/workflows/docker_android_workflow.yml index 158be6a6..94a6e21b 100644 --- a/.github/workflows/docker_android_workflow.yml +++ b/.github/workflows/docker_android_workflow.yml @@ -1,7 +1,7 @@ name: Docker Android Tests Workflow env: - TAGS: "ios_mobile_test" + TAGS: "android_mobile_tests" USING_DOCKER: 'True' on: @@ -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/ @@ -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 @@ -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 diff --git a/android_local_run.sh b/android_local_run.sh new file mode 100755 index 00000000..fbef14fe --- /dev/null +++ b/android_local_run.sh @@ -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" \ No newline at end of file diff --git a/configs/android_mobile_docker.json b/configs/android_mobile_docker.json index 7edf3918..a57b4fb4 100644 --- a/configs/android_mobile_docker.json +++ b/configs/android_mobile_docker.json @@ -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