Skip to content

Commit 61e016d

Browse files
brabojclaude
andcommitted
fix: handle nested lhr structure and skip non-report JSON files
Lighthouse CI may wrap reports under .lhr key. Skip files without categories to avoid errors on manifest or other metadata files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d6f6f93 commit 61e016d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

.github/workflows/lighthouse.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ jobs:
4747
const path = require('path');
4848
const dir = '.lighthouseci';
4949
const files = fs.readdirSync(dir).filter(f => f.endsWith('.json') && !f.startsWith('manifest'));
50-
const rows = files.map(f => {
51-
const r = JSON.parse(fs.readFileSync(path.join(dir, f), 'utf8'));
50+
const rows = [];
51+
for (const f of files) {
52+
const raw = JSON.parse(fs.readFileSync(path.join(dir, f), 'utf8'));
53+
const r = raw.lhr || raw;
54+
if (!r.categories) continue;
5255
const rawUrl = r.finalDisplayedUrl || r.finalUrl || r.requestedUrl || '';
5356
const pagePath = rawUrl.startsWith('http') ? new URL(rawUrl).pathname : rawUrl || f;
5457
const scores = r.categories;
@@ -58,8 +61,8 @@ jobs:
5861
const icon = s >= 90 ? '🟢' : s >= 50 ? '🟠' : '🔴';
5962
return `${icon} ${s}`;
6063
};
61-
return `| ${pagePath} | ${fmt('performance')} | ${fmt('accessibility')} | ${fmt('best-practices')} | ${fmt('seo')} |`;
62-
});
64+
rows.push(`| ${pagePath} | ${fmt('performance')} | ${fmt('accessibility')} | ${fmt('best-practices')} | ${fmt('seo')} |`);
65+
}
6366
const body = [
6467
'## Lighthouse Results',
6568
'',

0 commit comments

Comments
 (0)