3737 run : |
3838 # Only try to merge if blob-report exists (it should, thanks to reporters config)
3939 if [[ -d blob-report ]]; then
40- PLAYWRIGHT_HTML_OUTPUT_DIR=playwright-report \
40+ # Build HTML
41+ PLAYWRIGHT_HTML_REPORT=playwright-report \
4142 npx playwright merge-reports --reporter=html blob-report
43+
44+ # Also emit machine-readable summary for stats
45+ npx playwright merge-reports --reporter=json blob-report > playwright-report/summary.json
4246 else
4347 echo "No blob-report directory found; will fall back to placeholder."
4448 fi
@@ -89,26 +93,50 @@ jobs:
8993 COMMIT_SUBJECT="$(git log -1 --pretty=%s || true)"
9094 COMMIT_URL="https://github.com/${REPO}/commit/${SHA}"
9195
92- # Optional stats from report.json (if present)
96+ # Derive stats from merged JSON (preferred), else fall back to HTML's data json/gz
9397 STATS='null'
94- if [[ -f "./playwright-report/data/report.json" ]]; then
98+ if [[ -f "./playwright-report/summary.json" ]]; then
99+ # JSON reporter shape
100+ STATS=$(jq -c '
101+ def collect(s):
102+ (s.tests // []) + ((s.suites // []) | map(collect(.)) | add // []);
103+ (collect(.)) as $t
104+ | {
105+ total: ($t | length),
106+ failed: ($t | map(select((.outcome // .status) as $x | $x=="unexpected" or $x=="failed")) | length),
107+ skipped: ($t | map(select((.outcome // .status)=="skipped")) | length),
108+ flaky: ($t | map(select((.outcome // .status)=="flaky")) | length)
109+ } as $b
110+ | $b + { passed: ($b.total - $b.failed - $b.skipped - $b.flaky) }
111+ ' ./playwright-report/summary.json)
112+ elif [[ -f "./playwright-report/data/report.json" ]]; then
113+ # HTML reporter (some versions)
95114 STATS=$(jq -c '
96- if .stats then
97- .stats as $s
98- | {
99- total: ($s.total // (($s.passed // 0) + ($s.failed // 0) + ($s.skipped // 0) + ($s.flaky // 0))),
100- failed: ($s.failed // $s.unexpected // 0),
101- skipped: ($s.skipped // 0),
102- flaky: ($s.flaky // 0)
103- } as $b
104- | $b + {
105- passed: ($s.passed
106- // (($s.expected // 0) - $b.skipped - $b.flaky)
107- // ($b.total - $b.failed - $b.skipped - $b.flaky)
108- // 0)
109- }
110- else null end
115+ def collect(s):
116+ (s.tests // []) + ((s.suites // []) | map(collect(.)) | add // []);
117+ (collect(.)) as $t
118+ | {
119+ total: ($t | length),
120+ failed: ($t | map(select(.outcome=="unexpected")) | length),
121+ skipped: ($t | map(select(.outcome=="skipped")) | length),
122+ flaky: ($t | map(select(.outcome=="flaky")) | length)
123+ } as $b
124+ | $b + { passed: ($b.total - $b.failed - $b.skipped - $b.flaky) }
111125 ' ./playwright-report/data/report.json)
126+ elif [[ -f "./playwright-report/data/report.json.gz" ]]; then
127+ # HTML reporter (gzipped data)
128+ STATS=$(gzip -cd ./playwright-report/data/report.json.gz | jq -c '
129+ def collect(s):
130+ (s.tests // []) + ((s.suites // []) | map(collect(.)) | add // []);
131+ (collect(.)) as $t
132+ | {
133+ total: ($t | length),
134+ failed: ($t | map(select(.outcome=="unexpected")) | length),
135+ skipped: ($t | map(select(.outcome=="skipped")) | length),
136+ flaky: ($t | map(select(.outcome=="flaky")) | length)
137+ } as $b
138+ | $b + { passed: ($b.total - $b.failed - $b.skipped - $b.flaky) }
139+ ')
112140 fi
113141
114142 # If no stats and tests failed, set a minimal failed summary so UI can badge it
@@ -117,6 +145,7 @@ jobs:
117145 fi
118146
119147
148+
120149 # --- Write meta.json into the report folder
121150 jq -n \
122151 --arg branch "$BRANCH" \
0 commit comments