| 122 | const errorsPerTests = new Map() |
| 123 | |
| 124 | async function maybeLogSummary() { |
| 125 | if (process.env.CI && errorsPerTests.size > 0) { |
| 126 | const outputTemplate = ` |
| 127 | ${Array.from(errorsPerTests.entries()) |
| 128 | .map(([test, { output }]) => { |
| 129 | return ` |
| 130 | <details> |
| 131 | <summary>${test}</summary> |
| 132 | |
| 133 | \`\`\` |
| 134 | ${output} |
| 135 | \`\`\` |
| 136 | |
| 137 | </details> |
| 138 | ` |
| 139 | }) |
| 140 | .join('\n')}` |
| 141 | |
| 142 | // Build table rows with one row per failed test case |
| 143 | const tableRows = [] |
| 144 | for (const [test, { failedCases }] of errorsPerTests.entries()) { |
| 145 | const testLink = `<a href="https://github.com/vercel/next.js/blob/canary/${test}">${test}</a>` |
| 146 | if (failedCases.length === 0) { |
| 147 | tableRows.push(['Unknown', testLink]) |
| 148 | } else { |
| 149 | for (const caseName of failedCases) { |
| 150 | tableRows.push([caseName, testLink]) |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | await core.summary |
| 156 | .addHeading('Tests failures') |
| 157 | .addTable([ |
| 158 | [ |
| 159 | { data: 'Test Name', header: true }, |
| 160 | { data: 'Test Path', header: true }, |
| 161 | ], |
| 162 | ...tableRows, |
| 163 | ]) |
| 164 | .addRaw(outputTemplate) |
| 165 | .write() |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | let exiting = false |
| 170 | |