Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions mac/common-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ is_private_ip() {
}

is_domain_private() {
local is_cx_domain_private=100
domain=${CX_TEST_URL#*://} # remove protocol
domain=${domain%%/*} # remove everything after first "/"
log_msg_to "Website domain: $domain"
Expand Down Expand Up @@ -466,6 +467,8 @@ detect_os() {
}

print_env_vars() {
local test_type=$1
local tech_stack=$2
log_section "✅ Environment Variables"
log_info "BrowserStack Username: $BROWSERSTACK_USERNAME"
log_info "BrowserStack Project Name: $BROWSERSTACK_PROJECT_NAME"
Expand All @@ -490,23 +493,24 @@ print_env_vars() {

clean_env_vars() {
log_section "✅ Clean Environment Variables"
export BROWSERSTACK_USERNAME=""
export BROWSERSTACK_ACCESS_KEY=""
export BROWSERSTACK_APP=""
export BSTACK_CAPS_JSON=""
export BSTACK_PLATFORMS=""
export CX_TEST_URL=""
export NOW_WEB_DOMAIN=""
export BROWSERSTACK_PROJECT_NAME=""
export BROWSERSTACK_BUILD_NAME=""
export BROWSERSTACK_LOCAL_CUSTOM=""
export BROWSERSTACK_LOCAL=""
export BSTACK_PARALLELS=""
export APP_PLATFORM=""
export NOW_PLATFORM=""
export BSTACK_CAPS_JSON=""
export BSTACK_PLATFORMS=""
export BROWSERSTACK_APP

# list of variables to unset
vars=(
BSTACK_CAPS_JSON
BSTACK_PLATFORMS
BROWSERSTACK_PROJECT_NAME
BROWSERSTACK_BUILD_NAME
BROWSERSTACK_LOCAL_CUSTOM
BROWSERSTACK_LOCAL
)

# unset each variable safely
for var in "${vars[@]}"; do
unset "$var"
done

log_info "Cleared environment variables."

log_info "Terminating any running BrowserStack Local instances."
pgrep '[B]rowserStack' | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 || true
}
15 changes: 8 additions & 7 deletions mac/env-setup-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ EOF
mvn install -DskipTests >> "$NOW_RUN_LOG_FILE" 2>&1 || return 1
log_success "Dependencies installed"

print_env_vars
print_env_vars "$test_type" "$tech_stack"


print_tests_running_log_section "mvn test -P sample-test"
Expand Down Expand Up @@ -163,7 +163,7 @@ EOF
fi
log_success "Dependencies installed"

print_env_vars
print_env_vars "$test_type" "$tech_stack"

log_msg_to "🚀 Running 'mvn test -P sample-test'. This could take a few minutes. Follow the Automaton build here: https://automation.browserstack.com/"
print_tests_running_log_section "mvn test -P sample-test"
Expand Down Expand Up @@ -217,7 +217,7 @@ EOF

report_bstack_local_status "$local_flag"

print_env_vars
print_env_vars "$test_type" "$tech_stack"

print_tests_running_log_section "browserstack-sdk pytest -s tests/*.py"
log_msg_to "🚀 Running 'browserstack-sdk pytest -s tests/*.py'. This could take a few minutes. Follow the Automaton build here: https://automation.browserstack.com/"
Expand Down Expand Up @@ -271,7 +271,7 @@ EOF
export BROWSERSTACK_BUILD_NAME="now-$NOW_OS-app-python-pytest"
export BROWSERSTACK_PROJECT_NAME="now-$NOW_OS-app"

print_env_vars
print_env_vars "$test_type" "$tech_stack"

print_tests_running_log_section "cd $run_dir && browserstack-sdk pytest -s bstack-sample.py"
# Run pytest with BrowserStack SDK from the chosen platform directory
Expand Down Expand Up @@ -311,7 +311,8 @@ setup_web_nodejs() {
export BSTACK_PARALLELS=$parallels

if is_domain_private; then
local_flag=true
log_msg_to "Entered in Is domain private condition"
local_flag="true"
fi

export BROWSERSTACK_LOCAL_CUSTOM=$local_flag
Expand All @@ -320,7 +321,7 @@ setup_web_nodejs() {

report_bstack_local_status "$local_flag"

print_env_vars
print_env_vars "$test_type" "$tech_stack"

# === 8️⃣ Run Tests ===
log_msg_to "🚀 Running 'npm run test'. This could take a few minutes. Follow the Automaton build here: https://automation.browserstack.com/"
Expand Down Expand Up @@ -368,7 +369,7 @@ setup_app_nodejs() {
export BROWSERSTACK_BUILD_NAME="now-$NOW_OS-app-nodejs-wdio"
export BROWSERSTACK_PROJECT_NAME="now-$NOW_OS-app"

print_env_vars
print_env_vars "$test_type" "$tech_stack"

# === 8️⃣ Run Tests ===
log_msg_to "🚀 Running 'npm run test'. This could take a few minutes. Follow the Automaton build here: https://automation.browserstack.com/"
Expand Down
1 change: 1 addition & 0 deletions mac/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ TSTACK=$3 # Tech Stack from env (for silent mode)
log_section "🧭 Setup Summary – BrowserStack NOW"
log_info "Timestamp: $(date '+%Y-%m-%d %H:%M:%S')"

trap clean_env_vars EXIT # runs cleanup on script exit
clean_env_vars
detect_os
setup_workspace
Expand Down
Loading