fix: move scripts folder to correct location
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env node
|
||||
const fs = require('fs');
|
||||
|
||||
const [, , resultsPath, label] = process.argv;
|
||||
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('');
|
||||
}
|
||||
|
||||
const summaryPath = process.env.GITEA_STEP_SUMMARY || process.env.GITHUB_STEP_SUMMARY;
|
||||
if (summaryPath) {
|
||||
fs.appendFileSync(summaryPath, lines.join('\n') + '\n');
|
||||
} else {
|
||||
console.log(lines.join('\n'));
|
||||
}
|
||||
|
||||
process.exit(data.numFailedTests > 0 ? 1 : 0);
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env node
|
||||
const fs = require('fs');
|
||||
|
||||
const [, , resultsPath] = process.argv;
|
||||
const raw = fs.readFileSync(resultsPath, 'utf-8');
|
||||
const data = JSON.parse(raw);
|
||||
const stats = data.stats || {};
|
||||
|
||||
const lines = [];
|
||||
lines.push('## Playwright E2E Results');
|
||||
lines.push('');
|
||||
lines.push('| | Count |');
|
||||
lines.push('|---|---|');
|
||||
lines.push(`| ✅ Passed | ${stats.expected || 0} |`);
|
||||
lines.push(`| ❌ Failed | ${stats.unexpected || 0} |`);
|
||||
lines.push(`| ⚠️ Flaky | ${stats.flaky || 0} |`);
|
||||
lines.push(`| ⏭️ Skipped | ${stats.skipped || 0} |`);
|
||||
lines.push('');
|
||||
|
||||
function collectFailures(suites, path) {
|
||||
path = path || [];
|
||||
let failures = [];
|
||||
for (const suite of suites || []) {
|
||||
const currentPath = path.concat(suite.title).filter(Boolean);
|
||||
for (const spec of suite.specs || []) {
|
||||
for (const test of spec.tests || []) {
|
||||
for (const result of test.results || []) {
|
||||
if (result.status !== 'passed' && result.status !== 'skipped') {
|
||||
failures.push(`${currentPath.join(' > ')} > ${spec.title}: ${result.status}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (suite.suites) failures = failures.concat(collectFailures(suite.suites, currentPath));
|
||||
}
|
||||
return failures;
|
||||
}
|
||||
|
||||
const failures = collectFailures(data.suites);
|
||||
if (failures.length) {
|
||||
lines.push('### Failures');
|
||||
lines.push('');
|
||||
for (const f of failures) lines.push(`- ${f}`);
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
const summaryPath = process.env.GITEA_STEP_SUMMARY || process.env.GITHUB_STEP_SUMMARY;
|
||||
if (summaryPath) {
|
||||
fs.appendFileSync(summaryPath, lines.join('\n') + '\n');
|
||||
} else {
|
||||
console.log(lines.join('\n'));
|
||||
}
|
||||
|
||||
process.exit((stats.unexpected || 0) > 0 ? 1 : 0);
|
||||
Reference in New Issue
Block a user