Skip to content

Commit 62df07f

Browse files
committed
win mac merge init commit
1 parent dbfa2ed commit 62df07f

27 files changed

+2091
-2459
lines changed

.github/workflows/test-scripts.yml

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,40 @@ jobs:
3434
run: |
3535
echo "Validating mac/run.sh syntax..."
3636
bash -n mac/run.sh
37+
bash -n common/mac/run.sh
3738
echo "✅ mac/run.sh syntax is valid"
3839
3940
- name: Validate supporting scripts syntax
4041
run: |
4142
echo "Validating supporting scripts..."
42-
bash -n mac/common-utils.sh
43-
bash -n mac/logging-utils.sh
44-
bash -n mac/env-setup-run.sh
45-
bash -n mac/user-interaction.sh
46-
bash -n mac/env-prequisite-checks.sh
43+
bash -n common/mac/common-utils.sh
44+
bash -n common/mac/logging-utils.sh
45+
bash -n common/mac/env-setup-run.sh
46+
bash -n common/mac/user-interaction.sh
47+
bash -n common/mac/env-prequisite-checks.sh
4748
echo "✅ All supporting scripts are valid"
4849
4950
- name: Check if scripts are executable
5051
run: |
5152
chmod +x mac/run.sh
52-
chmod +x mac/common-utils.sh
53-
chmod +x mac/logging-utils.sh
54-
chmod +x mac/env-setup-run.sh
55-
chmod +x mac/user-interaction.sh
56-
chmod +x mac/env-prequisite-checks.sh
53+
chmod +x common/mac/common-utils.sh
54+
chmod +x common/mac/logging-utils.sh
55+
chmod +x common/mac/env-setup-run.sh
56+
chmod +x common/mac/user-interaction.sh
57+
chmod +x common/mac/env-prequisite-checks.sh
5758
echo "✅ All scripts are executable"
5859
5960
- name: Run ShellCheck on mac scripts
6061
run: |
6162
brew install shellcheck
6263
echo "Running ShellCheck on mac scripts..."
6364
shellcheck -x mac/run.sh || true
64-
shellcheck -x mac/common-utils.sh || true
65-
shellcheck -x mac/logging-utils.sh || true
66-
shellcheck -x mac/env-setup-run.sh || true
67-
shellcheck -x mac/user-interaction.sh || true
68-
shellcheck -x mac/env-prequisite-checks.sh || true
65+
shellcheck -x common/mac/run.sh || true
66+
shellcheck -x common/mac/common-utils.sh || true
67+
shellcheck -x common/mac/logging-utils.sh || true
68+
shellcheck -x common/mac/env-setup-run.sh || true
69+
shellcheck -x common/mac/user-interaction.sh || true
70+
shellcheck -x common/mac/env-prequisite-checks.sh || true
6971
echo "✅ ShellCheck analysis complete"
7072
7173
- name: Verify required dependencies
@@ -81,7 +83,7 @@ jobs:
8183
run: |
8284
set -e
8385
echo "Testing script sourcing..."
84-
bash -c "source mac/common-utils.sh && echo '✅ common-utils.sh sourced successfully'"
86+
bash -c "source common/mac/common-utils.sh && echo '✅ common-utils.sh sourced successfully'"
8587
echo "✅ Script sourcing successful"
8688
8789
- name: Integration Test - Silent Mode Execution
@@ -205,18 +207,20 @@ jobs:
205207
Write-Host "Validating win/run.ps1 syntax..."
206208
$ScriptPath = "win/run.ps1"
207209
$null = [System.Management.Automation.PSParser]::Tokenize((Get-Content -Raw $ScriptPath), [ref]$null)
210+
$CommonScriptPath = "common/win/run.ps1"
211+
$null = [System.Management.Automation.PSParser]::Tokenize((Get-Content -Raw $CommonScriptPath), [ref]$null)
208212
Write-Host "✅ win/run.ps1 syntax is valid"
209213
210214
- name: Validate supporting PowerShell scripts syntax
211215
run: |
212216
Write-Host "Validating supporting PowerShell scripts..."
213217
$Scripts = @(
214-
"win/common-utils.ps1",
215-
"win/logging-utils.ps1",
216-
"win/env-prequisite-checks.ps1",
217-
"win/user-interaction.ps1",
218-
"win/env-setup-run.ps1",
219-
"win/device-machine-allocation.ps1"
218+
"common/win/common-utils.ps1",
219+
"common/win/logging-utils.ps1",
220+
"common/win/env-prequisite-checks.ps1",
221+
"common/win/user-interaction.ps1",
222+
"common/win/env-setup-run.ps1",
223+
"common/win/device-machine-allocation.ps1"
220224
)
221225
foreach ($Script in $Scripts) {
222226
$null = [System.Management.Automation.PSParser]::Tokenize((Get-Content -Raw $Script), [ref]$null)
@@ -400,26 +404,27 @@ jobs:
400404
run: |
401405
echo "Validating mac/run.sh syntax..."
402406
bash -n mac/run.sh
407+
bash -n common/mac/run.sh
403408
echo "✅ mac/run.sh syntax is valid"
404409
405410
- name: Validate supporting scripts syntax
406411
run: |
407412
echo "Validating supporting scripts..."
408-
bash -n mac/common-utils.sh
409-
bash -n mac/logging-utils.sh
410-
bash -n mac/env-setup-run.sh
411-
bash -n mac/user-interaction.sh
412-
bash -n mac/env-prequisite-checks.sh
413+
bash -n common/mac/common-utils.sh
414+
bash -n common/mac/logging-utils.sh
415+
bash -n common/mac/env-setup-run.sh
416+
bash -n common/mac/user-interaction.sh
417+
bash -n common/mac/env-prequisite-checks.sh
413418
echo "✅ All supporting scripts are valid"
414419
415420
- name: Check if scripts are executable
416421
run: |
417422
chmod +x mac/run.sh
418-
chmod +x mac/common-utils.sh
419-
chmod +x mac/logging-utils.sh
420-
chmod +x mac/env-setup-run.sh
421-
chmod +x mac/user-interaction.sh
422-
chmod +x mac/env-prequisite-checks.sh
423+
chmod +x common/mac/common-utils.sh
424+
chmod +x common/mac/logging-utils.sh
425+
chmod +x common/mac/env-setup-run.sh
426+
chmod +x common/mac/user-interaction.sh
427+
chmod +x common/mac/env-prequisite-checks.sh
423428
echo "✅ All scripts are executable"
424429
425430
- name: Install ShellCheck
@@ -433,11 +438,12 @@ jobs:
433438
run: |
434439
echo "Running ShellCheck on mac scripts..."
435440
shellcheck -x mac/run.sh || true
436-
shellcheck -x mac/common-utils.sh || true
437-
shellcheck -x mac/logging-utils.sh || true
438-
shellcheck -x mac/env-setup-run.sh || true
439-
shellcheck -x mac/user-interaction.sh || true
440-
shellcheck -x mac/env-prequisite-checks.sh || true
441+
shellcheck -x common/mac/run.sh || true
442+
shellcheck -x common/mac/common-utils.sh || true
443+
shellcheck -x common/mac/logging-utils.sh || true
444+
shellcheck -x common/mac/env-setup-run.sh || true
445+
shellcheck -x common/mac/user-interaction.sh || true
446+
shellcheck -x common/mac/env-prequisite-checks.sh || true
441447
echo "✅ ShellCheck analysis complete"
442448
443449
- name: Verify required dependencies
@@ -453,7 +459,7 @@ jobs:
453459
run: |
454460
set -e
455461
echo "Testing script sourcing..."
456-
bash -c "source mac/common-utils.sh && echo '✅ common-utils.sh sourced successfully'"
462+
bash -c "source common/mac/common-utils.sh && echo '✅ common-utils.sh sourced successfully'"
457463
echo "✅ Script sourcing successful"
458464
459465
- name: Integration Test - Silent Mode Execution

common/config/devices.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Format: TYPE|PLATFORM|DEVICE_OR_BROWSER
2+
# Web
3+
WEB|Windows|Chrome
4+
WEB|Windows|Firefox
5+
WEB|Windows|Edge
6+
MOBILE|ios|iPhone 1[234567]*
7+
MOBILE|android|Samsung Galaxy S*
8+
WEB|OS X|Chrome
9+
WEB|OS X|Safari
10+
WEB|OS X|Firefox
11+
MOBILE|ios|iPad Air*
12+
MOBILE|android|Samsung Galaxy Tab*
13+
MOBILE|android|Samsung Galaxy M*
14+
MOBILE|android|Google Pixel [56789]*
15+
MOBILE|android|Vivo Y*
16+
MOBILE|android|Oppo*
17+
MOBILE|ios|iPad Pro*
18+
MOBILE|android|Samsung Galaxy A*
19+
MOBILE|android|Google Pixel 10*
20+
MOBILE|android|OnePlus *
21+
MOBILE|android|Vivo V*
22+
MOBILE|android|Xiaomi *
23+
MOBILE|android|Huawei *

common/config/repos.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
web_java|now-testng-browserstack
2+
app_java|now-testng-appium-app-browserstack
3+
web_python|now-pytest-browserstack
4+
app_python|now-pytest-appium-app-browserstack
5+
web_nodejs|now-webdriverio-browserstack
6+
app_nodejs|now-webdriverio-appium-app-browserstack
Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#!/bin/bash
22

3+
# shellcheck source=/dev/null
34
# shellcheck source=/dev/null
45
source "$(dirname "$0")/device-machine-allocation.sh"
56

67
# # ===== Global Variables =====
78
WORKSPACE_DIR="$HOME/.browserstack"
89
PROJECT_FOLDER="NOW"
10+
GUI_SCRIPT="$(dirname "${BASH_SOURCE[0]}")/windows-gui.ps1"
11+
912

1013
# URL handling
1114
DEFAULT_TEST_URL="https://bstackdemo.com"
@@ -81,6 +84,11 @@ setup_workspace() {
8184
# ===== App Upload Management =====
8285
handle_app_upload() {
8386
local app_platform=""
87+
if [[ -n "$CLI_APP_PATH" ]]; then
88+
upload_custom_app "$CLI_APP_PATH"
89+
return
90+
fi
91+
8492
if [[ "$RUN_MODE" == *"--silent"* || "$RUN_MODE" == *"--debug"* ]]; then
8593
upload_sample_app
8694
app_platform="android"
@@ -96,6 +104,8 @@ handle_app_upload() {
96104
buttons {"Use Sample App", "Upload my App (.apk/.ipa)", "Cancel"} ¬
97105
default button "Upload my App (.apk/.ipa)"
98106
' 2>/dev/null)
107+
elif [[ "$NOW_OS" == "windows" ]]; then
108+
choice=$(powershell.exe -ExecutionPolicy Bypass -File "$GUI_SCRIPT" -Command "ClickChoice" -Title "BrowserStack App Upload" -Prompt "How would you like to select your app?" -Choices "Use Sample App,Upload my App (.apk/.ipa),Cancel" -DefaultChoice "Upload my App (.apk/.ipa)" | tr -d '\r')
99109
else
100110
echo "How would you like to select your app?"
101111
select opt in "Use Sample App" "Upload my App (.apk/.ipa)" "Cancel"; do
@@ -144,21 +154,25 @@ upload_sample_app() {
144154

145155
upload_custom_app() {
146156
local app_platform=""
147-
local file_path
157+
local file_path="$1"
148158

149-
# Convert to POSIX path
159+
if [ -z "$file_path" ]; then
160+
# Convert to POSIX path
150161
# Convert to POSIX path
151162
if [[ "$NOW_OS" == "macos" ]]; then
152163
file_path=$(osascript -e \
153164
'POSIX path of (choose file with prompt "Select your .apk or .ipa file:" of type {"apk", "ipa"})' \
154165
2>/dev/null)
166+
elif [[ "$NOW_OS" == "windows" ]]; then
167+
file_path=$(powershell.exe -ExecutionPolicy Bypass -File "$GUI_SCRIPT" -Command "OpenFileDialog" -Title "Select your .apk or .ipa file" -Filter "App Files (*.apk;*.ipa)|*.apk;*.ipa|All files (*.*)|*.*" | tr -d '\r')
155168
else
156169
echo "Please enter the full path to your .apk or .ipa file:"
157170
read -r file_path
158171
# Remove quotes if user added them
159172
file_path="${file_path%\"}"
160173
file_path="${file_path#\"}"
161174
fi
175+
fi
162176

163177
# Trim whitespace
164178
file_path="${file_path%"${file_path##*[![:space:]]}"}"
@@ -217,7 +231,7 @@ generate_mobile_platforms() {
217231
local platformsListContentFormat=$2
218232
local app_platform="$APP_PLATFORM"
219233
local platformsList=""
220-
platformsList=$(pick_terminal_devices "$app_platform" "$max_total_parallels", "$platformsListContentFormat")
234+
platformsList=$(pick_terminal_devices "$app_platform" "$max_total_parallels" "$platformsListContentFormat")
221235
echo "$platformsList"
222236
}
223237

@@ -277,7 +291,7 @@ fetch_plan_details() {
277291
TEAM_PARALLELS_MAX_ALLOWED_MOBILE=5
278292
export TEAM_PARALLELS_MAX_ALLOWED_MOBILE=5
279293
fi
280-
log_info "Resetting Plan summary: Web $WEB_PLAN_FETCHED ($TEAM_PARALLELS_MAX_ALLOWED_WEB max), Mobile $MOBILE_PLAN_FETCHED ($TEAM_PARALLELS_MAX_ALLOWED_MOBILE max)"
294+
log_info "Silent mode: Plan summary: Web $WEB_PLAN_FETCHED ($TEAM_PARALLELS_MAX_ALLOWED_WEB max), Mobile $MOBILE_PLAN_FETCHED ($TEAM_PARALLELS_MAX_ALLOWED_MOBILE max)"
281295
fi
282296
}
283297

@@ -340,6 +354,15 @@ resolve_ip() {
340354
echo "$ip"
341355
}
342356

357+
report_bstack_local_status() {
358+
local local_flag=$1
359+
if [ "$local_flag" == "true" ]; then
360+
log_info "BrowserStack Local: ENABLED"
361+
else
362+
log_info "BrowserStack Local: DISABLED"
363+
fi
364+
}
365+
343366

344367
identify_run_status_java() {
345368
local log_file=$1
@@ -391,7 +414,7 @@ identify_run_status_nodejs() {
391414
log_success "Success: $passed test(s) passed"
392415
return 0
393416
else
394-
log_error "Error: No tests passed"
417+
log_error "Error: No tests passed"
395418
return 1
396419
fi
397420
}

0 commit comments

Comments
 (0)