-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowserstack-e2e-android-core.yml
More file actions
222 lines (200 loc) · 8.5 KB
/
Copy pathbrowserstack-e2e-android-core.yml
File metadata and controls
222 lines (200 loc) · 8.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#
# Copyright (c) 2026 Ping Identity Corporation. All rights reserved.
#
# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE file for details.
#
name: BrowserStack E2E — Android Foundation Modules
on:
workflow_call:
inputs:
browserstack_project_name:
description: BrowserStack project name used for Android E2E runs
required: false
type: string
default: rn-sdk-test
browserstack_session_name:
description: BrowserStack session name used by Detox
required: false
type: string
default: android-detox-e2e-core
secrets:
BROWSERSTACK_USERNAME:
description: BrowserStack account username
required: true
BROWSERSTACK_ACCESS_KEY:
description: BrowserStack account access key
required: true
PING_SERVER_URL:
description: Ping server base URL for Tier 2 E2E coverage
required: false
PING_REALM_PATH:
description: Ping realm path for journey and OIDC E2E coverage
required: false
PING_COOKIE_NAME:
description: Ping cookie name used by the test environment
required: false
PING_JOURNEY_NAME:
description: Ping journey name exercised by BrowserStack E2E tests
required: false
PING_TEST_USERNAME:
description: Test account username for server-backed BrowserStack scenarios
required: false
PING_TEST_PASSWORD:
description: Test account password for server-backed BrowserStack scenarios
required: false
PING_DISCOVERY_ENDPOINT:
description: OIDC discovery endpoint used by BrowserStack E2E tests
required: false
PING_CLIENT_ID:
description: OIDC client identifier used by BrowserStack E2E tests
required: false
PING_REDIRECT_URI:
description: OIDC redirect URI used by BrowserStack E2E tests
required: false
PING_CALLBACK_TREES_ENABLED:
description: Flag enabling callback tree coverage in BrowserStack E2E tests
required: false
permissions:
contents: read
jobs:
e2e-android-core:
name: E2E — Android BrowserStack (foundation)
runs-on: ubuntu-latest
timeout-minutes: 45
defaults:
run:
working-directory: PingTestRunner
shell: bash
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
PING_SERVER_URL: ${{ secrets.PING_SERVER_URL }}
PING_REALM_PATH: ${{ secrets.PING_REALM_PATH }}
PING_COOKIE_NAME: ${{ secrets.PING_COOKIE_NAME }}
PING_JOURNEY_NAME: ${{ secrets.PING_JOURNEY_NAME }}
PING_TEST_USERNAME: ${{ secrets.PING_TEST_USERNAME }}
PING_TEST_PASSWORD: ${{ secrets.PING_TEST_PASSWORD }}
PING_DISCOVERY_ENDPOINT: ${{ secrets.PING_DISCOVERY_ENDPOINT }}
PING_CLIENT_ID: ${{ secrets.PING_CLIENT_ID }}
PING_REDIRECT_URI: ${{ secrets.PING_REDIRECT_URI }}
PING_CALLBACK_TREES_ENABLED: ${{ secrets.PING_CALLBACK_TREES_ENABLED }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js and install dependencies
uses: ./.github/actions/setup-proj
- name: Install global Jest and Detox CLI
run: |
npm install -g jest
npm install -g detox-cli
- name: Download app APK artifact
uses: actions/download-artifact@v4
with:
name: pingtestrunner-android-bs-app
path: PingTestRunner/android/app/build/outputs/apk/release
- name: Download test APK artifact
uses: actions/download-artifact@v4
with:
name: pingtestrunner-android-bs-test-suite
path: PingTestRunner/android/app/build/outputs/apk/androidTest/release
- name: Compute BrowserStack identifiers
# Naming convention:
# Project : rn-<moduleName>-test → rn-sdk-test
# Build : <EVENT_PREFIX>-<RUN_ID>-<RUN_ATTEMPT>-<SHORT_SHA>-core
# Session : <platform>-<framework>-core
run: |
set -euo pipefail
SHORT_SHA="${GITHUB_SHA:0:7}"
case "${{ github.event_name }}" in
pull_request)
BUILD_PREFIX="pr"
;;
push)
BUILD_PREFIX="push"
;;
*)
BUILD_PREFIX="run"
;;
esac
echo "BROWSERSTACK_BUILD_ID=${BUILD_PREFIX}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-${SHORT_SHA}-core" >> "$GITHUB_ENV"
echo "BROWSERSTACK_PROJECT_NAME=${{ inputs.browserstack_project_name }}" >> "$GITHUB_ENV"
echo "BROWSERSTACK_SESSION_NAME=${{ inputs.browserstack_session_name }}" >> "$GITHUB_ENV"
- name: Upload app to BrowserStack
id: upload-app
run: |
response=$(curl --silent --fail-with-body \
-u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/detox/v2/android/app" \
-F "file=@android/app/build/outputs/apk/release/app-release.apk")
app_url=$(echo "$response" | jq -r '.app_url')
if [[ "$app_url" == "null" || -z "$app_url" ]]; then
echo "::error::Failed to get app_url from BrowserStack response: $response"
exit 1
fi
echo "app_url=$app_url" >> "$GITHUB_OUTPUT"
- name: Upload app client to BrowserStack
id: upload-test
run: |
response=$(curl --silent --fail-with-body \
-u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/detox/v2/android/app-client" \
-F "file=@android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk")
test_url=$(echo "$response" | jq -r '.app_client_url')
if [[ "$test_url" == "null" || -z "$test_url" ]]; then
echo "::error::Failed to get app_client_url from BrowserStack response: $response"
exit 1
fi
echo "test_url=$test_url" >> "$GITHUB_OUTPUT"
- name: Run E2E core tests on BrowserStack real devices
id: run-tests
run: yarn test:runner:bs:android:core 2>&1 | tee /tmp/detox-bs.log; exit "${PIPESTATUS[0]}"
working-directory: ${{ github.workspace }}
env:
BROWSERSTACK_APP_URL: ${{ steps.upload-app.outputs.app_url }}
BROWSERSTACK_TEST_URL: ${{ steps.upload-test.outputs.test_url }}
- name: View BrowserStack test results
if: always() && steps.run-tests.outcome != 'skipped'
shell: bash
run: |
set -euo pipefail
session_id="$(grep -oP '(?<=session_id=)[^[:space:]]+' /tmp/detox-bs.log | head -1 || true)"
if [ -z "$session_id" ]; then
echo "Session ID not found in Detox logs — visit https://app-automate.browserstack.com/dashboard/v2 to view results."
exit 0
fi
echo "Fetching BrowserStack session details for session: $session_id"
curl -s \
-u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/detox/v2/android/sessions/${session_id}"
- name: Prepare test summary report
if: always()
shell: bash
run: |
set -euo pipefail
overall_status="${{ steps.run-tests.outcome }}"
build_id="${BROWSERSTACK_BUILD_ID}"
if [ "$overall_status" = "success" ]; then
result_label="✅ Passed"
else
result_label="❌ Failed"
fi
test_detail=""
if [ -f /tmp/detox-bs.log ]; then
suites_line="$(grep -E "^Test Suites:" /tmp/detox-bs.log | tail -1 || true)"
tests_line="$(grep -E "^Tests:" /tmp/detox-bs.log | tail -1 || true)"
if [ -n "$suites_line" ] || [ -n "$tests_line" ]; then
test_detail=$'\n### Test Results\n'
[ -n "$suites_line" ] && test_detail+=$'\n'"- ${suites_line}"
[ -n "$tests_line" ] && test_detail+=$'\n'"- ${tests_line}"
fi
fi
{
echo "## BrowserStack Android Detox Summary — Core"
echo
echo "- Build ID: \`${build_id}\`"
echo "- Overall status: ${overall_status}"
echo "- Result: ${result_label}"
echo "- [BrowserStack dashboard](https://app-automate.browserstack.com/dashboard/v2/builds/${build_id})"
echo -e "$test_detail"
} >> "$GITHUB_STEP_SUMMARY"