Files
redefined-designs/scripts/summarize-jest.js
T
bermudalambandClaude Opus 5 ec63b9cdb0 fix: unset NODE_ENV in e2e job so devDependencies install
npm treats NODE_ENV=production as --omit=dev, so `npm install` in the
frontend-e2e job skipped typescript and the build died on `tsc: not found`.
The same env var would have stripped vite and @playwright/test from the
frontend install, and flipped the session cookie to Secure on a run served
over plain http.

The reported summarize crash was a symptom: the job aborted before Playwright
ran, but Summarize is `if: always()` and threw ENOENT on the missing JSON,
burying the real failure. Both summarize scripts now report the missing file
and exit 0 -- the job still fails via its own step.

Also split build from start, replaced `sleep 3` with a readiness poll against
/api/config, and dump the backend log when e2e fails.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-15 08:56:25 -05:00

56 lines
1.7 KiB
JavaScript

#!/usr/bin/env node
const fs = require('fs');
const [, , resultsPath, label] = process.argv;
// This runs with `if: always()`, so it also fires when an earlier step failed and
// no results file was ever written. Report that plainly and exit 0 — the job still
// fails on the real step, and a stack trace here would only bury it.
if (!fs.existsSync(resultsPath)) {
report([`## ${label || 'Test'} Results`, '', `No results file at \`${resultsPath}\` — the test step failed before writing one.`, '']);
process.exit(0);
}
const raw = fs.readFileSync(resultsPath, 'utf-8');
const data = JSON.parse(raw);
const lines = [];
lines.push(`## ${label || 'Test'} Results`);
lines.push('');
lines.push('| | Count |');
lines.push('|---|---|');
lines.push(`| ✅ Passed | ${data.numPassedTests} |`);
lines.push(`| ❌ Failed | ${data.numFailedTests} |`);
lines.push(`| ⏭️ Skipped | ${data.numPendingTests} |`);
lines.push(`| **Total** | **${data.numTotalTests}** |`);
lines.push('');
if (data.numFailedTests > 0) {
lines.push('### Failures');
lines.push('');
for (const suite of data.testResults) {
for (const t of suite.testResults) {
if (t.status === 'failed') {
lines.push(`- **${t.fullName}**`);
const msg = t.failureMessages && t.failureMessages[0]
? t.failureMessages[0].split('\n')[0]
: 'see job log for details';
lines.push(` \`${msg}\``);
}
}
}
lines.push('');
}
report(lines);
process.exit(data.numFailedTests > 0 ? 1 : 0);
function report(out) {
const summaryPath = process.env.GITEA_STEP_SUMMARY || process.env.GITHUB_STEP_SUMMARY;
if (summaryPath) {
fs.appendFileSync(summaryPath, out.join('\n') + '\n');
} else {
console.log(out.join('\n'));
}
}