@@ -6,7 +6,6 @@ import path from 'node:path'
66import { buildTestReport } from './test-report.js'
77
88const TEST_COMMENT_MARKER = '<!-- __NEXT_TEST_REPORT_COMMENT__ -->'
9- const STATS_COMMENT_MARKER = '<!-- __NEXT_STATS_COMMENT__ -->'
109const MAX_COMMENT_LENGTH = 62_000
1110const MAX_RESULT_MESSAGE_LENGTH = 12_000
1211
@@ -296,11 +295,6 @@ async function main() {
296295 return
297296 }
298297
299- if ( workflowRun . name === 'Generate Stats' ) {
300- await handleStatsWorkflow ( { github, workflowRun, pr, phase } )
301- return
302- }
303-
304298 if ( workflowRun . name === 'build-and-test' ) {
305299 await handleBuildAndTestWorkflow ( {
306300 github,
@@ -457,115 +451,6 @@ async function readPullRequestMetadataArtifact() {
457451 }
458452}
459453
460- async function handleStatsWorkflow ( { github, workflowRun, pr, phase } ) {
461- if ( phase === 'requested' ) {
462- const sha = pr . headSha || workflowRun . head_sha
463- const body = [
464- STATS_COMMENT_MARKER ,
465- '## Stats in progress' ,
466- '' ,
467- `Commit: ${ sha } ` ,
468- `[View workflow run](${ workflowRun . html_url } )` ,
469- '' ,
470- ] . join ( '\n' )
471-
472- await github . insertIssueCommentIfMissing (
473- pr . number ,
474- STATS_COMMENT_MARKER ,
475- body ,
476- [ '## Stats from current PR' ]
477- )
478- return
479- }
480-
481- // Look for a stats block before reacting to the run conclusion. A single
482- // bundler timing out cancels its job and marks the whole run "cancelled", but
483- // the aggregate still emits stats for the bundlers that finished. Treating a
484- // cancelled run as "no data" up front would discard that partial comment, so
485- // we post whatever the aggregate produced first and only fall back to a
486- // cancelled/skipped notice when there is genuinely no block.
487- const jobs = await github . listJobsForRunAttempt (
488- workflowRun . id ,
489- workflowRun . run_attempt || 1
490- )
491- const candidates = jobs . filter ( ( job ) => / a g g r e g a t e s t a t s / i. test ( job . name ) )
492-
493- for ( const job of candidates ) {
494- let logs
495- try {
496- logs = await github . downloadJobLogs ( job . id )
497- } catch ( err ) {
498- // A cancelled or skipped aggregate job may have no retrievable logs.
499- console . log ( `Failed to download logs for job ${ job . id } ` , err )
500- continue
501- }
502-
503- const stats = extractDelimitedBlock (
504- logs ,
505- '--stats start--' ,
506- '--stats end--'
507- )
508-
509- if ( ! stats ) {
510- continue
511- }
512-
513- let body = stats
514- . replace ( 'âš ï¸' , '\u26a0\ufe0f' )
515- . replace ( '✓' , '\u2713' )
516- . trim ( )
517-
518- if ( ! body . includes ( STATS_COMMENT_MARKER ) ) {
519- body = `${ STATS_COMMENT_MARKER } \n${ body } `
520- }
521-
522- body += `\n\nCommit: ${ pr . headSha || workflowRun . head_sha } `
523-
524- await github . upsertIssueComment ( pr . number , STATS_COMMENT_MARKER , body , [
525- '## Stats from current PR' ,
526- ] )
527- return
528- }
529-
530- const sha = pr . headSha || workflowRun . head_sha
531-
532- // No stats block. A cancelled conclusion here means the whole run was
533- // cancelled (superseded, or every bundler cancelled) rather than an
534- // individual bundler, since a partial run would have produced a block above.
535- if ( workflowRun . conclusion === 'cancelled' ) {
536- console . log ( 'No stats block found and the run was cancelled.' )
537- const body = [
538- STATS_COMMENT_MARKER ,
539- '## Stats cancelled' ,
540- '' ,
541- `Commit: ${ sha } ` ,
542- `[View workflow run](${ workflowRun . html_url } )` ,
543- '' ,
544- ] . join ( '\n' )
545-
546- await github . upsertIssueComment ( pr . number , STATS_COMMENT_MARKER , body , [
547- '## Stats from current PR' ,
548- ] )
549- return
550- }
551-
552- console . log (
553- 'No stats block found in the completed stats workflow. Assuming stats were skipped.'
554- )
555-
556- const body = [
557- STATS_COMMENT_MARKER ,
558- '## Stats skipped' ,
559- '' ,
560- `Commit: ${ sha } ` ,
561- `[View workflow run](${ workflowRun . html_url } )` ,
562- '' ,
563- ] . join ( '\n' )
564- await github . upsertIssueComment ( pr . number , STATS_COMMENT_MARKER , body , [
565- '## Stats from current PR' ,
566- ] )
567- }
568-
569454async function handleBuildAndTestWorkflow ( {
570455 github,
571456 workflowRun,
@@ -716,21 +601,6 @@ function extractJsonBlocks(logs) {
716601 return blocks
717602}
718603
719- function extractDelimitedBlock ( logs , start , end ) {
720- const startIndex = logs . indexOf ( start )
721- if ( startIndex === - 1 ) {
722- return null
723- }
724-
725- const contentStart = startIndex + start . length
726- const endIndex = logs . indexOf ( end , contentStart )
727- if ( endIndex === - 1 ) {
728- return null
729- }
730-
731- return logs . slice ( contentStart , endIndex ) . trim ( )
732- }
733-
734604function buildTestReportComment ( {
735605 failedSuites,
736606 otherFailures,
0 commit comments