Skip to content

iOS Automation Tests Execution #27

iOS Automation Tests Execution

iOS Automation Tests Execution #27

name: iOS Automation Tests Execution
on:
workflow_dispatch:
inputs:
branch-to-checkout:
description: 'Branch to checkout'
type: choice
options:
- main
- develop
- milestone/2025.Q4
- milestone/2026.Q1
default: develop
test-cases:
description: 'Choose Test Cases'
type: string
default: "@automated"
platform:
description: 'Platform to test - iOS'
type: choice
options:
- IOS
default: IOS
# schedule:
# # WED,SAT 03:15 UTC
# - cron: '15 3 * * 3,6'
jobs:
build:
runs-on: macos-latest
timeout-minutes: 240 # increase IF needed
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
steps:
- uses: actions/checkout@v4 # Checkout the code
with:
clean: true
lfs: false
ref: ${{ inputs.branch-to-checkout || 'main' }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'oracle'
- name: Set up Node JS 16.20.2
uses: actions/setup-node@v4
with:
node-version: '16.20.2'
- name: Clean Old Results
run: |
rm -rf target/serenity
rm -rf target/site/reports
rm -rf target/site/serenity
- name: Initialize Session Map
run: echo "" > session_map.txt
- name: Check jq Installation
run: |
if ! command -v jq &> /dev/null; then
echo "jq not found, installing..."
brew install jq
else
echo "jq is already installed."
jq --version
fi
- name: Check BrowserStack Credentials
run: |
response=$(curl -u "${BROWSERSTACK_USERNAME}:${BROWSERSTACK_ACCESS_KEY}" https://api.browserstack.com/automate/plan.json)
echo "BrowserStack Response: $response"
- name: Get Latest BrowserStack Build ID
id: fetch-build
if: always()
run: |
BUILD_ID=$(curl -u "${{ secrets.BROWSERSTACK_USERNAME }}:${{ secrets.BROWSERSTACK_ACCESS_KEY }}" \
-X GET "https://api-cloud.browserstack.com/app-automate/builds.json" \
| jq -r '.[0].automation_build.hashed_id')
echo "BUILD_ID=$BUILD_ID"
echo "buildid=$BUILD_ID" >> $GITHUB_OUTPUT
- name: Run iOS Selenium Appium tests on BrowserStack Farm
if: ${{ inputs.platform == 'IOS' || inputs.platform == 'both' }}
continue-on-error: true
run: |
TEST_CASES="${{ inputs.test-cases }} and @IOS"
echo "Running iOS tests with tags: $TEST_CASES"
export CUCUMBER_FILTER_TAGS="$TEST_CASES"
mvn test -ntp -Dapp.url=$BROWSERSTACK_APP_URL -Dcucumber.filter.tags="$TEST_CASES"
- name: Generate Serenity Report
if: always()
run: |
mvn serenity:aggregate -Dtags="${{ inputs.test-cases }} and (@ANDROID or @IOS)"
- name: Replace Serenity Core CSS
if: always()
run: |
REPORT_DIR="target/site/reports/EUDI_Wallet_Version_2025.12.34-Demo"
echo "Replacing core.css using custom-style.css..."
cp src/test/resources/custom-style.css "$REPORT_DIR/css/core.css"
- name: Upload Serenity Report
uses: actions/upload-artifact@v4
if: always()
with:
name: iOS-serenity-report
path: target/site/reports/*
- name: Download BrowserStack Device Logs per Feature (iOS)
if: always() && (inputs.platform == 'IOS' || inputs.platform == 'both')
run: |
BUILD_ID="${{ steps.fetch-build.outputs.buildid }}"
mkdir -p ios-logs
while IFS='=' read FEATURE SESSION_ID; do
[[ "$FEATURE" != *"_IOS" && "$FEATURE" != *"_iOS" ]] && continue
FEATURE_CLEAN=$(echo "$FEATURE" | tr -d '[:space:]')
echo "Downloading logs for iOS: $FEATURE_CLEAN | Session: $SESSION_ID"
curl -u "${{ secrets.BROWSERSTACK_USERNAME }}:${{ secrets.BROWSERSTACK_ACCESS_KEY }}" \
-X GET "https://api-cloud.browserstack.com/app-automate/builds/$BUILD_ID/sessions/$SESSION_ID/devicelogs" \
-o "ios-logs/${FEATURE_CLEAN}.txt"
done < session_map.txt
- name: Upload iOS Logs
uses: actions/upload-artifact@v4
if: always()
with:
name: iOS-device-logs
path: ios-logs/
- name: Upload Serenity JSON Results
uses: actions/upload-artifact@v4
if: always()
with:
name: ios-serenity-json # or ios-serenity-json
path: target/site/reports/EUDI_Wallet_Version_2025.12.34-Demo/*.json