Skip to content

BS - Android App Tests #207

BS - Android App Tests

BS - Android App Tests #207

name: BS - Android App Tests
env:
TAGS: "android_mobile_tests"
BROWSERSTACK_USER: ${{secrets.BROWSERSTACK_API_USERNAME}}
BROWSERSTACK_ACCESS_KEY: ${{secrets.BROWSERSTACK_ACCESS_KEY}}
USING_ENV: "BROWSERSTACK"
on:
schedule:
- cron: '30 21 * * *'
workflow_dispatch:
inputs:
tags:
description: Gherkin Tags
required: true
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: ./env_configs/android_mobile_BS.json
html_report: android-mobile
testrail_configuration_name: 'Samsung Galaxy S23 Ultra'
name: ${{ matrix.name }} - Regression
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: BrowserStack Env Setup
uses: browserstack/github-actions/setup-env@master
with:
username: ${{secrets.BROWSERSTACK_API_USERNAME}}
access-key: ${{secrets.BROWSERSTACK_ACCESS_KEY}}
- name: BrowserStack Local Tunnel Setup
uses: browserstack/github-actions/setup-local@master
with:
local-testing: start
local-identifier: random
- name: Check out code
uses: actions/checkout@v4
- name: Setup dependencies
run: |
sh setup_install.sh
- name: Run All Tests
run: |
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 \
- name: BrowserStackLocal Stop
uses: browserstack/github-actions/setup-local@master
with:
local-testing: stop
if: ${{ always() }}
- name: Upload HTML run report in the Artifacts Folder
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.html_report }}
path: |
./*.html
./output/
./assets/
if: ${{ always() }}
manual-run:
if: github.event_name != 'schedule'
name: Manual - ${{ inputs.tags }}
runs-on: ubuntu-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: BrowserStack Env Setup
id: bs_env_setup
if: steps.validate_input.outcome == 'success'
uses: browserstack/github-actions/setup-env@master
with:
username: ${{secrets.BROWSERSTACK_API_USERNAME}}
access-key: ${{secrets.BROWSERSTACK_ACCESS_KEY}}
- name: BrowserStack Local Tunnel Setup
id: bs_local_tunnel_setup
if: steps.bs_env_setup.outcome == 'success'
uses: browserstack/github-actions/setup-local@master
with:
local-testing: start
local-identifier: random
- name: Check out code
id: co_code
if: steps.bs_local_tunnel_setup.outcome == 'success'
uses: actions/checkout@v4
- name: Setup dependencies
id: setup_dependencies
if: steps.co_code.outcome == 'success'
run: |
sh setup_install.sh
- name: Run Manual Job 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 './env_configs/android_mobile_BS.json' \
--tags="$TAGS" --html=report.html \
--self-contained-html
- name: BrowserStackLocal Stop
uses: browserstack/github-actions/setup-local@master
with:
local-testing: stop
if: ${{ always() }}
- name: Upload HTML run report in the Artifacts Folder
uses: actions/upload-artifact@v4
with:
name: pytest-results
path: |
./*.html
./output/
./assets/
if: ${{ always() }}