Skip to content

Commit f8c8696

Browse files
committed
linter checks
1 parent 76ba173 commit f8c8696

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

mac/common-utils.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

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

56
# # ===== Global Variables =====
@@ -41,20 +42,21 @@ log_msg_to() {
4142
# write to dest file if provided
4243
if [ -n "$dest_file" ]; then
4344
mkdir -p "$(dirname "$dest_file")"
44-
echo "$line" >> $NOW_RUN_LOG_FILE
45+
echo "$line" >> "$NOW_RUN_LOG_FILE"
4546
fi
4647
}
4748

4849
# Spinner function for long-running processes
4950
show_spinner() {
5051
local pid=$1
52+
# shellcheck disable=SC1003
5153
local spin='|/-\'
5254
local i=0
5355
local ts
5456
ts="$(date +"%Y-%m-%d %H:%M:%S")"
5557
while kill -0 "$pid" 2>/dev/null; do
5658
i=$(( (i+1) %4 ))
57-
printf "\r⏳ Processing... ${spin:$i:1}"
59+
printf "\r⏳ Processing... %s" "${spin:$i:1}"
5860
sleep 0.1
5961
done
6062
echo ""
@@ -119,7 +121,7 @@ upload_sample_app() {
119121
log_msg_to "Exported BROWSERSTACK_APP=$BROWSERSTACK_APP"
120122

121123
if [ -z "$app_url" ]; then
122-
log_msg_to "❌ Upload failed. Response: $UPLOAD_RESPONSE"
124+
log_msg_to "❌ Upload failed. Response: $upload_response"
123125
return 1
124126
fi
125127

@@ -292,7 +294,7 @@ identify_run_status_java() {
292294
skipped=$(echo "$line" | grep -m 1 -oE "Skipped: [0-9]+" | awk '{print $2}')
293295

294296
# Calculate passed tests
295-
passed=$(( $tests_run - ($failures + $errors + $skipped) ))
297+
passed=$(( tests_run-(failures+errors+skipped) ))
296298

297299
# Check condition
298300
if (( passed > 0 )); then
@@ -302,8 +304,6 @@ identify_run_status_java() {
302304
log_error "Error: No tests passed (Tests run: $tests_run, Failures: $failures, Errors: $errors, Skipped: $skipped)"
303305
return 1
304306
fi
305-
306-
return 1
307307
}
308308

309309

mac/env-prequisite-checks.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ parse_proxy() {
2626

2727
set_proxy_in_env() {
2828
log_section "🌐 Network & Proxy Validation"
29-
base64_encoded_creds=$(printf "%s" $BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY | base64 | tr -d '\n')
29+
base64_encoded_creds=$(printf "%s" "$BROWSERSTACK_USERNAME":"$BROWSERSTACK_ACCESS_KEY" | base64 | tr -d '\n')
3030

3131

3232
# If no proxy configured, exit early
3333
if [ -z "$PROXY" ]; then
3434
log_warn "No proxy found. Using direct connection."
3535
export PROXY_HOST=""
3636
export PROXY_PORT=""
37-
return 0 2>/dev/null || exit 0
37+
return 0 2>/dev/null
3838
fi
3939

4040
log_msg_to "Proxy detected: $PROXY"

mac/env-setup-run.sh

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# shellcheck shell=bash
33

44
setup_environment() {
5-
local setup_type=$1 # "web" or "mobile"
5+
local setup_type=$1
66
local tech_stack=$2
77
local max_parallels
88

@@ -17,7 +17,7 @@ setup_environment() {
1717
max_parallels=$TEAM_PARALLELS_MAX_ALLOWED_MOBILE
1818
fi
1919

20-
log_msg_to "Starting ${setup_type} setup for $TECH_STACK" "$NOW_RUN_LOG_FILE"
20+
log_msg_to "Starting ${setup_type} setup for " "$tech_stack" "$NOW_RUN_LOG_FILE"
2121

2222
local local_flag=false
2323

@@ -134,7 +134,7 @@ setup_app_java() {
134134
local app_url=$BROWSERSTACK_APP
135135
log_msg_to "APP_PLATFORM: $APP_PLATFORM" >> "$NOW_RUN_LOG_FILE" 2>&1
136136

137-
clone_repository $REPO $TARGET_DIR
137+
clone_repository "$REPO" "$TARGET_DIR"
138138

139139
if [[ "$APP_PLATFORM" == "all" || "$APP_PLATFORM" == "android" ]]; then
140140
cd "android/testng-examples" || return 1
@@ -145,7 +145,7 @@ setup_app_java() {
145145

146146
# YAML config path
147147
export BROWSERSTACK_CONFIG_FILE="./browserstack.yml"
148-
platform_yaml=$(generate_mobile_platforms $TEAM_PARALLELS_MAX_ALLOWED_MOBILE "yaml")
148+
platform_yaml=$(generate_mobile_platforms "$TEAM_PARALLELS_MAX_ALLOWED_MOBILE" "yaml")
149149

150150
cat >> "$BROWSERSTACK_CONFIG_FILE" <<EOF
151151
app: ${app_url}
@@ -182,7 +182,7 @@ EOF
182182
show_spinner "$cmd_pid"
183183
wait "$cmd_pid"
184184

185-
cd "$WORKSPACE_DIR/$PROJECT_FOLDER"
185+
cd "$WORKSPACE_DIR/$PROJECT_FOLDER" || return 1
186186
return 0
187187
}
188188

@@ -232,14 +232,14 @@ EOF
232232
print_tests_running_log_section "browserstack-sdk pytest -s src/test/suites/*.py --browserstack.config ./src/conf/browserstack_parallel.yml"
233233
log_msg_to "🚀 Running 'browserstack-sdk pytest -s tests/bstack-sample-test.py'. This could take a few minutes. Follow the Automaton build here: https://automation.browserstack.com/"
234234
# Run tests
235-
browserstack-sdk pytest -s src/test/suites/*.py --browserstack.config ./src/conf/browserstack_parallel.yml >> $NOW_RUN_LOG_FILE 2>&1
235+
browserstack-sdk pytest -s src/test/suites/*.py --browserstack.config ./src/conf/browserstack_parallel.yml >> "$NOW_RUN_LOG_FILE" 2>&1
236236
# &
237237
# cmd_pid=$!|| return 1
238238

239239
# show_spinner "$cmd_pid"
240240
# wait "$cmd_pid"
241241

242-
cd "$WORKSPACE_DIR/$PROJECT_FOLDER"
242+
cd "$WORKSPACE_DIR/$PROJECT_FOLDER" || return 1
243243
return 0
244244
}
245245

@@ -251,24 +251,20 @@ setup_app_python() {
251251
REPO="now-pytest-appium-app-browserstack"
252252
TARGET_DIR="$WORKSPACE_DIR/$PROJECT_FOLDER/$REPO"
253253

254-
clone_repository $REPO $TARGET_DIR
254+
clone_repository "$REPO" "$TARGET_DIR"
255255

256256
detect_setup_python_env
257257

258258
# Install dependencies
259259
pip install -r requirements.txt >> "$NOW_RUN_LOG_FILE" 2>&1
260260
log_success "Dependencies installed"
261261

262-
263-
# Prepare platform-specific YAMLs in android/ and ios/
264-
local original_platform="$APP_PLATFORM"
265-
266262
local app_url=$BROWSERSTACK_APP
267263
local platform_yaml
268264

269265
export BSTACK_PARALLELS=1
270266
export BROWSERSTACK_CONFIG_FILE="./android/browserstack.yml"
271-
platform_yaml=$(generate_mobile_platforms $TEAM_PARALLELS_MAX_ALLOWED_MOBILE "yaml")
267+
platform_yaml=$(generate_mobile_platforms "$TEAM_PARALLELS_MAX_ALLOWED_MOBILE" "yaml")
272268

273269
cat >> "$BROWSERSTACK_CONFIG_FILE" <<EOF
274270
@@ -312,13 +308,13 @@ setup_web_nodejs() {
312308
TARGET_DIR="$WORKSPACE_DIR/$PROJECT_FOLDER/$REPO"
313309
mkdir -p "$WORKSPACE_DIR/$PROJECT_FOLDER"
314310

315-
clone_repository $REPO $TARGET_DIR
311+
clone_repository "$REPO" "$TARGET_DIR"
316312

317313

318314
# === 2️⃣ Install Dependencies ===
319315
log_msg_to "⚙️ Running 'npm install'"
320316
log_info "Installing dependencies"
321-
npm install >> $NOW_RUN_LOG_FILE 2>&1 || return 1
317+
npm install >> "$NOW_RUN_LOG_FILE" 2>&1 || return 1
322318
log_success "Dependencies installed"
323319

324320
local caps_json=""
@@ -345,7 +341,7 @@ setup_web_nodejs() {
345341
# === 8️⃣ Run Tests ===
346342
log_msg_to "🚀 Running 'npm run test'. This could take a few minutes. Follow the Automaton build here: https://automation.browserstack.com/"
347343
print_tests_running_log_section "npm run test"
348-
npm run test >> $NOW_RUN_LOG_FILE 2>&1 || return 1 &
344+
npm run test >> "$NOW_RUN_LOG_FILE" 2>&1 || return 1 &
349345
cmd_pid=$!|| return 1
350346

351347
show_spinner "$cmd_pid"
@@ -367,15 +363,15 @@ setup_app_nodejs() {
367363
TARGET_DIR="$WORKSPACE_DIR/$PROJECT_FOLDER/$REPO"
368364
TEST_FOLDER="/test"
369365

370-
clone_repository $REPO $TARGET_DIR $TEST_FOLDER
366+
clone_repository $REPO "$TARGET_DIR" "$TEST_FOLDER"
371367

372368
# === 2️⃣ Install Dependencies ===
373369
log_info "Installing dependencies"
374370
log_msg_to "⚙️ Running 'npm install'"
375-
npm install >> $NOW_RUN_LOG_FILE 2>&1 || return 1
371+
npm install >> "$NOW_RUN_LOG_FILE" 2>&1 || return 1
376372
log_success "Dependencies installed"
377373

378-
caps_json=$(generate_mobile_platforms $TEAM_PARALLELS_MAX_ALLOWED_MOBILE "json")
374+
caps_json=$(generate_mobile_platforms "$TEAM_PARALLELS_MAX_ALLOWED_MOBILE" "json")
379375

380376

381377
export BSTACK_CAPS_JSON=$caps_json
@@ -444,7 +440,7 @@ run_setup_wrapper() {
444440
fi
445441
;;
446442
*)
447-
log_msg_to "❌ Invalid TEST_TYPE: $TEST_TYPE"
443+
log_msg_to "❌ Invalid TEST_TYPE: $test_type"
448444
exit 1
449445
;;
450446
esac

mac/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ source "$(dirname "$0")/env-prequisite-checks.sh"
1818
run_setup() {
1919
local test_type=$1
2020
local tech_stack=$2
21-
setup_environment $test_type $tech_stack
21+
setup_environment "$test_type" "$tech_stack"
2222
}
2323

2424
# ===== Main flow (baseline steps then run) =====

0 commit comments

Comments
 (0)