Skip to content

Commit dbfa2ed

Browse files
Ci test win (#16)
* win changes init * win changes compat checks * win changes compat checks * win changes compat checks * win changes gha * win changes proxy * win changes proxy test-scripts.yml * win changes gha win * win changes gha win * updated windows setup * Test Windows-only CI * increase time gha * app js * app js * revert * multi file logs + remove both option * only run app nodejs * logs for app node * logs for app node * timeout changes for appnode * win changes for 5 parallel in silent mode * mac changes in win-changes branch done by samiran * updated workflow * undo if:false for linux & mac --------- Co-authored-by: Samiran Saha <samiran.s89@gmail.com>
1 parent de0d60a commit dbfa2ed

File tree

12 files changed

+2253
-2050
lines changed

12 files changed

+2253
-2050
lines changed

.github/workflows/test-scripts.yml

Lines changed: 225 additions & 159 deletions
Large diffs are not rendered by default.

mac/common-utils.sh

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,25 @@ handle_app_upload() {
8888
log_msg_to "Exported APP_PLATFORM=$APP_PLATFORM"
8989
else
9090
local choice
91-
choice=$(osascript -e '
92-
display dialog "How would you like to select your app?" ¬
93-
with title "BrowserStack App Upload" ¬
94-
with icon note ¬
95-
buttons {"Use Sample App", "Upload my App (.apk/.ipa)", "Cancel"} ¬
96-
default button "Upload my App (.apk/.ipa)"
97-
' 2>/dev/null)
91+
if [[ "$NOW_OS" == "macos" ]]; then
92+
choice=$(osascript -e '
93+
display dialog "How would you like to select your app?" ¬
94+
with title "BrowserStack App Upload" ¬
95+
with icon note ¬
96+
buttons {"Use Sample App", "Upload my App (.apk/.ipa)", "Cancel"} ¬
97+
default button "Upload my App (.apk/.ipa)"
98+
' 2>/dev/null)
99+
else
100+
echo "How would you like to select your app?"
101+
select opt in "Use Sample App" "Upload my App (.apk/.ipa)" "Cancel"; do
102+
case $opt in
103+
"Use Sample App") choice="Use Sample App"; break ;;
104+
"Upload my App (.apk/.ipa)") choice="Upload my App"; break ;;
105+
"Cancel") choice="Cancel"; break ;;
106+
*) echo "Invalid option";;
107+
esac
108+
done
109+
fi
98110

99111
if [[ "$choice" == *"Use Sample App"* ]]; then
100112
upload_sample_app
@@ -135,9 +147,18 @@ upload_custom_app() {
135147
local file_path
136148

137149
# Convert to POSIX path
138-
file_path=$(osascript -e \
139-
'POSIX path of (choose file with prompt "Select your .apk or .ipa file:" of type {"apk", "ipa"})' \
140-
2>/dev/null)
150+
# Convert to POSIX path
151+
if [[ "$NOW_OS" == "macos" ]]; then
152+
file_path=$(osascript -e \
153+
'POSIX path of (choose file with prompt "Select your .apk or .ipa file:" of type {"apk", "ipa"})' \
154+
2>/dev/null)
155+
else
156+
echo "Please enter the full path to your .apk or .ipa file:"
157+
read -r file_path
158+
# Remove quotes if user added them
159+
file_path="${file_path%\"}"
160+
file_path="${file_path#\"}"
161+
fi
141162

142163
# Trim whitespace
143164
file_path="${file_path%"${file_path##*[![:space:]]}"}"
@@ -210,7 +231,7 @@ fetch_plan_details() {
210231
local web_unauthorized=false
211232
local mobile_unauthorized=false
212233

213-
if [[ "$test_type" == "web" || "$test_type" == "both" ]]; then
234+
if [[ "$test_type" == "web" ]]; then
214235
RESPONSE_WEB=$(curl -s -w "\n%{http_code}" -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" https://api.browserstack.com/automate/plan.json)
215236
HTTP_CODE_WEB=$(echo "$RESPONSE_WEB" | tail -n1)
216237
RESPONSE_WEB_BODY=$(echo "$RESPONSE_WEB" | sed '$d')
@@ -225,7 +246,7 @@ fetch_plan_details() {
225246
fi
226247
fi
227248

228-
if [[ "$test_type" == "app" || "$test_type" == "both" ]]; then
249+
if [[ "$test_type" == "app" ]]; then
229250
RESPONSE_MOBILE=$(curl -s -w "\n%{http_code}" -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" https://api-cloud.browserstack.com/app-automate/plan.json)
230251
HTTP_CODE_MOBILE=$(echo "$RESPONSE_MOBILE" | tail -n1)
231252
RESPONSE_MOBILE_BODY=$(echo "$RESPONSE_MOBILE" | sed '$d')
@@ -243,11 +264,21 @@ fetch_plan_details() {
243264
log_info "Plan summary: Web $WEB_PLAN_FETCHED ($TEAM_PARALLELS_MAX_ALLOWED_WEB max), Mobile $MOBILE_PLAN_FETCHED ($TEAM_PARALLELS_MAX_ALLOWED_MOBILE max)"
244265

245266
if [[ "$test_type" == "web" && "$web_unauthorized" == true ]] || \
246-
[[ "$test_type" == "app" && "$mobile_unauthorized" == true ]] || \
247-
[[ "$test_type" == "both" && "$web_unauthorized" == true && "$mobile_unauthorized" == true ]]; then
267+
[[ "$test_type" == "app" && "$mobile_unauthorized" == true ]]; then
248268
log_msg_to "❌ Unauthorized to fetch required plan(s). Exiting."
249269
exit 1
250270
fi
271+
272+
if [[ "$RUN_MODE" == *"--silent"* ]]; then
273+
if [[ "$test_type" == "web" ]]; then
274+
TEAM_PARALLELS_MAX_ALLOWED_WEB=5
275+
export TEAM_PARALLELS_MAX_ALLOWED_WEB=5
276+
else
277+
TEAM_PARALLELS_MAX_ALLOWED_MOBILE=5
278+
export TEAM_PARALLELS_MAX_ALLOWED_MOBILE=5
279+
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)"
281+
fi
251282
}
252283

253284
# Function to check if IP is private
@@ -270,7 +301,7 @@ is_domain_private() {
270301
export CX_TEST_URL="$CX_TEST_URL"
271302

272303
# Resolve domain using Cloudflare DNS
273-
IP_ADDRESS=$(dig +short "$domain" @1.1.1.1 | head -n1)
304+
IP_ADDRESS=$(resolve_ip "$domain")
274305

275306
# Determine if domain is private
276307
if is_private_ip "$IP_ADDRESS"; then
@@ -284,6 +315,31 @@ is_domain_private() {
284315
return $is_cx_domain_private
285316
}
286317

318+
resolve_ip() {
319+
local domain=$1
320+
local ip=""
321+
322+
# Try dig first (standard on macOS/Linux, optional on Windows)
323+
if command -v dig >/dev/null 2>&1; then
324+
ip=$(dig +short "$domain" @1.1.1.1 | head -n1)
325+
fi
326+
327+
# Try Python if dig failed or missing
328+
if [ -z "$ip" ] && command -v python3 >/dev/null 2>&1; then
329+
ip=$(python3 -c "import socket; print(socket.gethostbyname('$domain'))" 2>/dev/null)
330+
fi
331+
332+
# Try nslookup as last resort (parsing is fragile)
333+
if [ -z "$ip" ] && command -v nslookup >/dev/null 2>&1; then
334+
# Windows/Generic nslookup parsing
335+
# Look for "Address:" or "Addresses:" after "Name:"
336+
# This is a best-effort attempt
337+
ip=$(nslookup "$domain" 2>/dev/null | grep -A 10 "Name:" | grep "Address" | tail -n1 | awk '{print $NF}')
338+
fi
339+
340+
echo "$ip"
341+
}
342+
287343

288344
identify_run_status_java() {
289345
local log_file=$1
@@ -401,4 +457,3 @@ detect_os() {
401457

402458
export NOW_OS=$response
403459
}
404-

mac/env-setup-run.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ setup_environment() {
2323

2424
# Calculate parallels
2525
local total_parallels
26-
total_parallels=$(echo "$max_parallels" | bc | cut -d'.' -f1)
26+
total_parallels=$(awk -v n="$max_parallels" 'BEGIN { printf "%d", n }')
2727
[ -z "$total_parallels" ] && total_parallels=1
2828
local parallels_per_platform=$total_parallels
2929

@@ -536,7 +536,13 @@ detect_setup_python_env() {
536536
exit 1
537537
}
538538

539-
# shellcheck source=/dev/null
540-
source .venv/bin/activate
539+
# Activate virtual environment (handle Windows/Unix paths)
540+
if [ -f ".venv/Scripts/activate" ]; then
541+
# shellcheck source=/dev/null
542+
source .venv/Scripts/activate
543+
else
544+
# shellcheck source=/dev/null
545+
source .venv/bin/activate
546+
fi
541547
log_success "Virtual environment created and activated."
542-
}
548+
}

mac/user-interaction.sh

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,29 @@ get_browserstack_credentials() {
1010
access_key="$BROWSERSTACK_ACCESS_KEY"
1111
log_info "BrowserStack credentials loaded from environment variables for user: $username"
1212
else
13+
if [[ "$NOW_OS" == "macos" ]]; then
1314
username=$(osascript -e 'Tell application "System Events" to display dialog "Please enter your BrowserStack Username.\n\nNote: Locate it in your BrowserStack account profile page.\nhttps://www.browserstack.com/accounts/profile/details" default answer "" with title "BrowserStack Setup" buttons {"OK"} default button "OK"' \
1415
-e 'text returned of result')
16+
else
17+
echo "Please enter your BrowserStack Username."
18+
echo "Note: Locate it in your BrowserStack account profile page: https://www.browserstack.com/accounts/profile/details"
19+
read -r username
20+
fi
1521

1622
if [ -z "$username" ]; then
1723
log_msg_to "❌ Username empty"
1824
return 1
1925
fi
2026

27+
if [[ "$NOW_OS" == "macos" ]]; then
2128
access_key=$(osascript -e 'Tell application "System Events" to display dialog "Please enter your BrowserStack Access Key.\n\nNote: Locate it in your BrowserStack account page.\nhttps://www.browserstack.com/accounts/profile/details" default answer "" with hidden answer with title "BrowserStack Setup" buttons {"OK"} default button "OK"' \
2229
-e 'text returned of result')
30+
else
31+
echo "Please enter your BrowserStack Access Key."
32+
echo "Note: Locate it in your BrowserStack account page: https://www.browserstack.com/accounts/profile/details"
33+
read -rs access_key
34+
echo "" # Newline after secret input
35+
fi
2336
if [ -z "$access_key" ]; then
2437
log_msg_to "❌ Access Key empty"
2538
return 1
@@ -41,8 +54,18 @@ get_tech_stack() {
4154
tech_stack="$TSTACK"
4255
log_msg_to "✅ Selected Tech Stack from environment: $tech_stack"
4356
else
57+
if [[ "$NOW_OS" == "macos" ]]; then
4458
tech_stack=$(osascript -e 'Tell application "System Events" to display dialog "Select installed tech stack:" buttons {"java", "python", "nodejs"} default button "java" with title "Testing Framework Technology Stack"' \
4559
-e 'button returned of result')
60+
else
61+
echo "Select installed tech stack:"
62+
select opt in "java" "python" "nodejs"; do
63+
case $opt in
64+
"java"|"python"|"nodejs") tech_stack=$opt; break ;;
65+
*) echo "Invalid option";;
66+
esac
67+
done
68+
fi
4669
fi
4770
log_msg_to "✅ Selected Tech Stack: $tech_stack"
4871
log_info "Tech Stack: $tech_stack"
@@ -56,8 +79,14 @@ get_tech_stack() {
5679
get_test_url() {
5780
local test_url=$DEFAULT_TEST_URL
5881

59-
test_url=$(osascript -e 'Tell application "System Events" to display dialog "Enter the URL you want to test with BrowserStack:\n(Leave blank for default: '"$DEFAULT_TEST_URL"')" default answer "" with title "Test URL Setup" buttons {"OK"} default button "OK"' \
60-
-e 'text returned of result')
82+
if [[ "$NOW_OS" == "macos" ]]; then
83+
test_url=$(osascript -e 'Tell application "System Events" to display dialog "Enter the URL you want to test with BrowserStack:\n(Leave blank for default: '"$DEFAULT_TEST_URL"')" default answer "" with title "Test URL Setup" buttons {"OK"} default button "OK"' \
84+
-e 'text returned of result')
85+
else
86+
echo "Enter the URL you want to test with BrowserStack:"
87+
echo "(Leave blank for default: $DEFAULT_TEST_URL)"
88+
read -r test_url
89+
fi
6190

6291
if [ -n "$test_url" ]; then
6392
log_msg_to "🌐 Using custom test URL: $test_url"
@@ -79,8 +108,18 @@ get_test_type() {
79108
test_type=$TT
80109
log_msg_to "✅ Selected Testing Type from environment: $TEST_TYPE"
81110
else
111+
if [[ "$NOW_OS" == "macos" ]]; then
82112
test_type=$(osascript -e 'Tell application "System Events" to display dialog "Select testing type:" buttons {"web", "app"} default button "web" with title "Testing Type"' \
83113
-e 'button returned of result')
114+
else
115+
echo "Select testing type:"
116+
select opt in "web" "app"; do
117+
case $opt in
118+
"web"|"app") test_type=$opt; break ;;
119+
*) echo "Invalid option";;
120+
esac
121+
done
122+
fi
84123
log_msg_to "✅ Selected Testing Type: $TEST_TYPE"
85124
RUN_MODE=$test_type
86125
log_info "Run Mode: ${RUN_MODE:-default}"
@@ -98,10 +137,6 @@ perform_next_steps_based_on_test_type() {
98137
"app")
99138
get_upload_app
100139
;;
101-
"both")
102-
get_test_url
103-
get_upload_app
104-
;;
105140
esac
106141
}
107142

0 commit comments

Comments
 (0)