Skip to content

Commit 0b66021

Browse files
author
Matthew Valancy
committed
fix: make installation test script POSIX sh compatible for broader platform support
Replaced bash-specific syntax with POSIX sh equivalents: - Arrays replaced with newline-separated strings - Array append (+=) replaced with string concatenation - for loop over array replaced with while read loop - Substring extraction replaced with cut command This ensures compatibility with GitHub Actions and other platforms that use dash or older sh implementations instead of bash.
1 parent f2b28bd commit 0b66021

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

scripts/test-installation-simple.sh

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ TEST_RUN_UUID=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid 2>/dev/n
2424
GIT_COMMIT_SHORT=$(cd "$PROJECT_ROOT" && git rev-parse --short HEAD 2>/dev/null || echo "unknown")
2525
INSTALL_SCRIPT_CRC=$(cksum "$INSTALL_SCRIPT" 2>/dev/null | awk '{print $1}' || echo "unknown")
2626
HTML_REPORT="$REPORT_DIR/report_${TIMESTAMP}_${GIT_COMMIT_SHORT}.html"
27-
TEST_RESULTS=()
27+
TEST_RESULTS=""
2828

2929
# Create directories
3030
mkdir -p "$REPORT_DIR"
@@ -91,16 +91,19 @@ EOF
9191
if grep -q "INSTALLATION_SCRIPT_TEST: SUCCESS" "$REPORT_DIR/${name// /_}.log"; then
9292
echo "${GREEN}${NC} $name - PASSED"
9393
PASSED=$((PASSED + 1))
94-
TEST_RESULTS+=("PASS|$name")
94+
TEST_RESULTS="${TEST_RESULTS}PASS|$name
95+
"
9596
else
9697
echo "${RED}${NC} $name - FAILED (script error)"
9798
FAILED=$((FAILED + 1))
98-
TEST_RESULTS+=("FAIL|$name|Script execution error")
99+
TEST_RESULTS="${TEST_RESULTS}FAIL|$name|Script execution error
100+
"
99101
fi
100102
else
101103
echo "${RED}${NC} $name - FAILED (docker error)"
102104
FAILED=$((FAILED + 1))
103-
TEST_RESULTS+=("FAIL|$name|Docker container error")
105+
TEST_RESULTS="${TEST_RESULTS}FAIL|$name|Docker container error
106+
"
104107
fi
105108

106109
# Cleanup
@@ -422,19 +425,23 @@ generate_html_report() {
422425
HTMLEOF
423426

424427
# Generate test results HTML
425-
local results_html=""
426-
for result in "${TEST_RESULTS[@]}"; do
427-
IFS='|' read -r status name error <<< "$result"
428+
results_html=""
429+
printf '%s\n' "$TEST_RESULTS" | while IFS='|' read -r status name error; do
430+
test -z "$status" && continue
428431
if [ "$status" = "PASS" ]; then
429-
results_html="${results_html}<div class='test-item'><div class='test-status pass'>✓</div><div class='test-name'>$name</div></div>"
432+
printf '<div class="test-item"><div class="test-status pass">✓</div><div class="test-name">%s</div></div>' "$name"
430433
else
431-
results_html="${results_html}<div class='test-item'><div class='test-status fail'>✗</div><div class='test-name'>$name</div><div class='test-error'>$error</div></div>"
434+
printf '<div class="test-item"><div class="test-status fail">✗</div><div class="test-name">%s</div><div class="test-error">%s</div></div>' "$name" "$error"
432435
fi
433-
done
434-
436+
done > "$REPORT_DIR/results_fragment.html"
437+
results_html=$(cat "$REPORT_DIR/results_fragment.html")
438+
439+
# Get first 8 chars of UUID (POSIX-compliant)
440+
uuid_short=$(printf '%s' "$TEST_RUN_UUID" | cut -c1-8)
441+
435442
# Replace placeholders
436443
sed -i.bak \
437-
-e "s/REPLACE_UUID/${TEST_RUN_UUID:0:8}/g" \
444+
-e "s/REPLACE_UUID/$uuid_short/g" \
438445
-e "s/REPLACE_COMMIT/$GIT_COMMIT_SHORT/g" \
439446
-e "s/REPLACE_CRC/$INSTALL_SCRIPT_CRC/g" \
440447
-e "s/REPLACE_TIME/$TIMESTAMP/g" \

0 commit comments

Comments
 (0)