@@ -11,6 +11,7 @@ const { spawn, exec: execOrig } = require('child_process')
11
11
const { createNextInstall } = require ( './test/lib/create-next-install' )
12
12
const glob = promisify ( _glob )
13
13
const exec = promisify ( execOrig )
14
+ const core = require ( '@actions/core' )
14
15
15
16
function escapeRegexp ( str ) {
16
17
return str . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' )
@@ -73,6 +74,45 @@ const mockTrace = () => ({
73
74
74
75
// which types we have configured to run separate
75
76
const configuredTestTypes = Object . values ( testFilters )
77
+ const errorsPerTests = new Map ( )
78
+
79
+ async function maybeLogSummary ( ) {
80
+ if ( process . env . CI && errorsPerTests . size > 0 ) {
81
+ const outputTemplate = `
82
+ ${ Array . from ( errorsPerTests . entries ( ) )
83
+ . map ( ( [ test , output ] ) => {
84
+ return `
85
+ <details>
86
+ <summary>${ test } </summary>
87
+
88
+ \`\`\`
89
+ ${ output }
90
+ \`\`\`
91
+
92
+ </details>
93
+ `
94
+ } )
95
+ . join ( '\n' ) } `
96
+
97
+ await core . summary
98
+ . addHeading ( 'Tests failures' )
99
+ . addTable ( [
100
+ [
101
+ {
102
+ data : 'Test suite' ,
103
+ header : true ,
104
+ } ,
105
+ ] ,
106
+ ...Array . from ( errorsPerTests . entries ( ) ) . map ( ( [ test ] ) => {
107
+ return [
108
+ `<a href="https://github.com/vercel/next.js/blob/canary/${ test } ">${ test } </a>` ,
109
+ ]
110
+ } ) ,
111
+ ] )
112
+ . addRaw ( outputTemplate )
113
+ . write ( )
114
+ }
115
+ }
76
116
77
117
const cleanUpAndExit = async ( code ) => {
78
118
if ( process . env . NEXT_TEST_STARTER ) {
@@ -81,6 +121,9 @@ const cleanUpAndExit = async (code) => {
81
121
if ( process . env . NEXT_TEST_TEMP_REPO ) {
82
122
await fs . remove ( process . env . NEXT_TEST_TEMP_REPO )
83
123
}
124
+ if ( process . env . CI ) {
125
+ await maybeLogSummary ( )
126
+ }
84
127
console . log ( `exiting with code ${ code } ` )
85
128
86
129
setTimeout ( ( ) => {
@@ -472,11 +515,19 @@ ${ENDGROUP}`)
472
515
} else {
473
516
process . stdout . write ( `${ GROUP } ❌ ${ test . file } output\n` )
474
517
}
518
+
519
+ let output = ''
475
520
// limit out to last 64kb so that we don't
476
521
// run out of log room in CI
477
522
for ( const { chunk } of outputChunks ) {
478
523
process . stdout . write ( chunk )
524
+ output += chunk . toString ( )
479
525
}
526
+
527
+ if ( process . env . CI && ! killed ) {
528
+ errorsPerTests . set ( test . file , output )
529
+ }
530
+
480
531
if ( isExpanded ) {
481
532
process . stdout . write ( `end of ${ test . file } output\n` )
482
533
} else {
0 commit comments