Skip to content

WDIO: automate iOS tests #15

WDIO: automate iOS tests

WDIO: automate iOS tests #15

Workflow file for this run

# The purpose of this GitHub action is to have a constant stream of data reporting to the following entities:
# NRTestApp-Auto: TBAdded
# This is accomplished by triggering npm scripts that execute a suite of tests in parallel
# The tests spin up simulated iOS and Android devices on LambdaTest that are instrumented with the Mobile agent
name: "WDIO: automate iOS tests"
on:
# enables option for workflow to be manually executed in Github UI
workflow_dispatch:
# Automatically trigger after uploadApp workflow completes successfully
workflow_run:
workflows: ["Upload iOS NRTestApp to LambdaTest"]
types:
- completed
# enables scheduled execution every 30 minutes
# schedule:
# - cron: "*/30 * * * *"
jobs:
ios-data:
name: Generate iOS data
runs-on: ubuntu-latest
# Only run if manually triggered or if uploadApp workflow succeeded
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
env:
LT_USERNAME: ${{ secrets.LAMBDA_USERNAME }}
LT_ACCESSKEY: ${{ secrets.LAMBDA_ACCESS_KEY }}
steps:
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # pin@v4
- name: Setup environment
uses: ./.github/actions/env-setup
- name: Download LambdaTest app ID artifact (from workflow_run)
if: github.event_name == 'workflow_run'
uses: actions/github-script@v7
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "lambdatest-app-id"
})[0];
if (matchArtifact) {
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/app-id.zip`, Buffer.from(download.data));
}
- name: Extract app ID (from workflow_run)
if: github.event_name == 'workflow_run'
run: |
if [ -f app-id.zip ]; then
unzip -q app-id.zip -d LambdaTest/
echo "Extracted app ID from workflow_run artifact"
fi
continue-on-error: true
- name: Download LambdaTest app ID artifact (from manual run)
if: github.event_name == 'workflow_dispatch'
uses: actions/download-artifact@v6
with:
name: lambdatest-app-id
path: ${{ github.workspace }}/LambdaTest
continue-on-error: true
- name: Set LT_APP_ID environment variable
run: |
if [ -f LambdaTest/last-app-id ]; then
echo "LT_APP_ID=$(tr -d '\n' < LambdaTest/last-app-id)" >> $GITHUB_ENV
echo "Using app ID: $(tr -d '\n' < LambdaTest/last-app-id)"
else
echo "No app ID artifact found, tests will use default app ID from config"
fi
- name: Execute iOS tests
run: for i in {1..1}; do echo "test run $i"; npm run test:wdio-ios; done
- name: Log success
if: ${{ success() }}
run: echo "[ RUNNER ] - successfully executed iOS tests"
- name: Log failure
if: ${{ failure() || cancelled() }}
run: echo "[ RUNNER ] - failed to execute iOS tests"
# - name: Notify failure
# if: ${{ failure() || cancelled() }}
# uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # pin@v2
# with:
# webhook-type: incoming-webhook
# webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
# payload: |
# blocks:
# - type: "header"
# text:
# type: "plain_text"
# text: ":rotating_light: GitHub Workflow Failure"
# - type: "divider"
# - type: "section"
# text:
# type: "mrkdwn"
# text: ":apple: Failed to generate *main-agent-test-app-iOS* data"
# accessory:
# type: "button"
# text:
# type: "plain_text"
# text: "View logs"
# emoji: true
# value: "view_logs"
# url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# action_id: "button-action"
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}