mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-05-24 10:35:18 +00:00
fix(ci): aggregate e2e pass/fail across all suites instead of broken digits-before-slash regex (#1298)
RED33d789c4f3(test) → GREENb43bd70f43(fix). CI: https://github.com/Kpa-clawbot/CoreScope/actions/workflows/deploy.yml?query=branch%3Afix%2Fe2e-badge-aggregate Fixes #1296 ## Problem `.github/workflows/deploy.yml` was computing the e2e-tests badge with: ``` E2E_PASS=$(grep -oP '[0-9]+(?=/)' e2e-output.txt | tail -1 || echo "0") ``` This regex matched any digit-run immediately followed by `/` anywhere in the combined output of 45+ Playwright suites, then took the **last** match. The result was usually a small number scraped out of intermediate per-suite progress text (often `2` from something like `2/3 …`), so the badge perpetually showed `{"label":"e2e tests","message":"2 passed","color":"brightgreen"}` regardless of how many tests actually ran. ## Fix - New `scripts/aggregate-e2e-pass.sh` parses every per-suite summary shape emitted by `test-*-e2e.js` (`N passed, M failed` / `passed N failed M` / `N/T tests passed` / `N/T PASS` / `<file>.js: PASS|FAIL`) and sums them. Per-test progress lines (`✓`, `PASS:`) are skipped so they can't double-count. - `deploy.yml` sources the aggregator, sets the badge to `"X passed"` (brightgreen) when `FAIL=0` and `"X passed, Y failed"` (red) otherwise. Badge schema (`schemaVersion / label / message / color`) unchanged. ## TDD - **RED**33d789c4f3: adds `test-e2e-badge-aggregate.sh` + vendored fixture `test-fixtures/e2e-output-sample.txt` (45 suites of realistic output). Aggregator stub returns zeros → test fails on assertion (`PASS=108 FAIL=0` expected, `PASS=0 FAIL=0` got). - **GREEN**b43bd70f43: real aggregator implementation → all five sub-tests pass (fixture aggregate, broken-regex sanity, synthetic mixed pass/fail, per-test-progress-line guard, missing-file fallback). No force-push. PII preflight clean. --------- Co-authored-by: openclaw-bot <bot@openclaw.local>
This commit is contained in:
Executable
+78
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bash
|
||||
# Aggregate E2E pass/fail counts across all per-suite summary lines.
|
||||
#
|
||||
# Each test-*-e2e.js emits a summary line in one of these shapes:
|
||||
# "N passed, M failed" — most suites (=== Results: 4 passed, 0 failed ===)
|
||||
# "passed N failed M" — observer-iata style
|
||||
# "N/T tests passed[, M failed]" — issue-1224 / 1236 / 1273 style
|
||||
# "N/T PASS" — logo-* suites
|
||||
# "N/T passed" — nav-fluid / nav-priority / nav-more-floor
|
||||
# "<file>.js: PASS" — single-test suites (hamburger-dropdown)
|
||||
# "<file>.js: FAIL ..." — suite-level failure
|
||||
#
|
||||
# Per-test progress lines (leading whitespace + PASS:/FAIL:/✓/✗) are skipped to
|
||||
# avoid double-counting. Each suite's summary is matched by the FIRST pattern
|
||||
# that fits, so a single line cannot contribute to two counters.
|
||||
#
|
||||
# Usage: aggregate-e2e-pass.sh [path-to-e2e-output.txt]
|
||||
# Prints: PASS=<n> FAIL=<n>
|
||||
set -u
|
||||
file=${1:-e2e-output.txt}
|
||||
pass=0
|
||||
fail=0
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "PASS=0 FAIL=0"
|
||||
exit 0
|
||||
fi
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
# Skip per-test progress lines (leading whitespace + marker).
|
||||
case "$line" in
|
||||
*"✓"*|*"✗"*) continue;;
|
||||
" "*"PASS"*|" "*"FAIL"*) continue;;
|
||||
esac
|
||||
|
||||
# "N/T tests passed[, M failed]" (must come BEFORE "N passed" to avoid
|
||||
# capturing T as the pass count)
|
||||
if [[ "$line" =~ ([0-9]+)/[0-9]+\ tests\ passed(,\ ([0-9]+)\ failed)? ]]; then
|
||||
pass=$((pass + BASH_REMATCH[1]))
|
||||
if [ -n "${BASH_REMATCH[3]:-}" ]; then
|
||||
fail=$((fail + BASH_REMATCH[3]))
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
# "N/T PASS"
|
||||
if [[ "$line" =~ ([0-9]+)/[0-9]+\ PASS ]]; then
|
||||
pass=$((pass + BASH_REMATCH[1]))
|
||||
continue
|
||||
fi
|
||||
# "N/T passed" (no "tests" between)
|
||||
if [[ "$line" =~ ([0-9]+)/[0-9]+\ passed ]]; then
|
||||
pass=$((pass + BASH_REMATCH[1]))
|
||||
continue
|
||||
fi
|
||||
# "N passed, M failed" / "N passed" (most suites)
|
||||
if [[ "$line" =~ ([0-9]+)\ passed(,\ ([0-9]+)\ failed)? ]]; then
|
||||
pass=$((pass + BASH_REMATCH[1]))
|
||||
if [ -n "${BASH_REMATCH[3]:-}" ]; then
|
||||
fail=$((fail + BASH_REMATCH[3]))
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
# "passed N failed M"
|
||||
if [[ "$line" =~ passed\ ([0-9]+)\ failed\ ([0-9]+) ]]; then
|
||||
pass=$((pass + BASH_REMATCH[1]))
|
||||
fail=$((fail + BASH_REMATCH[2]))
|
||||
continue
|
||||
fi
|
||||
# Standalone single-suite "<file>.js: PASS"
|
||||
if [[ "$line" =~ \.js:\ PASS$ ]]; then
|
||||
pass=$((pass + 1))
|
||||
continue
|
||||
fi
|
||||
# Standalone single-suite "<file>.js: FAIL ..."
|
||||
if [[ "$line" =~ \.js:\ FAIL ]]; then
|
||||
fail=$((fail + 1))
|
||||
continue
|
||||
fi
|
||||
done < "$file"
|
||||
echo "PASS=$pass FAIL=$fail"
|
||||
Reference in New Issue
Block a user